modifity to wizzard 'CreateSubscriptionInvoice'
This commit is contained in:
parent
6a3ce61e06
commit
e9f288bfbd
@ -27,4 +27,5 @@ def register():
|
||||
module='optical_equipment', type_='model')
|
||||
Pool.register(
|
||||
sale.CreateSubscription,
|
||||
subscription.CreateSubscriptionInvoice,
|
||||
module='optical_equipment', type_='wizard')
|
||||
|
@ -108,7 +108,8 @@ class OpticalEquipment(DeactivableMixin, Workflow, ModelSQL, ModelView):
|
||||
sale_destination = fields.Reference("Sale Destination", selection='get_destination',select=True,
|
||||
states={'readonly': True}
|
||||
)
|
||||
shipment_destination = fields.Reference("Stock Move", selection='get_shipment', select=True)
|
||||
shipment_destination = fields.Reference("Stock Move", selection='get_shipment', select=True,
|
||||
states={'readonly': True})
|
||||
|
||||
del _states_serial, _states, _depends
|
||||
|
||||
|
51
move.py
51
move.py
@ -63,22 +63,19 @@ class ShipmentOut(metaclass=PoolMeta):
|
||||
__name__ = 'stock.shipment.out'
|
||||
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('picked')
|
||||
@set_employee('picked_by')
|
||||
def pick(cls, shipments):
|
||||
pool = Pool()
|
||||
Move = pool.get('stock.move')
|
||||
def get_outgoing_moves(self, name):
|
||||
moves = []
|
||||
if self.state == 'done':
|
||||
for move in self.inventory_moves:
|
||||
moves.append(move.id)
|
||||
return moves
|
||||
else:
|
||||
for move in self.moves:
|
||||
if move.from_location == self.warehouse_output:
|
||||
moves.append(move.id)
|
||||
return moves
|
||||
|
||||
raise UserError(str(dir(Move)))
|
||||
|
||||
Move.delete([
|
||||
m for s in shipments for m in s.inventory_moves
|
||||
if m.state == 'staging'])
|
||||
Move.do([m for s in shipments for m in s.inventory_moves])
|
||||
cls._sync_inventory_to_outgoing(shipments, quantity=True)
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('done')
|
||||
@ -86,38 +83,22 @@ class ShipmentOut(metaclass=PoolMeta):
|
||||
def done(cls, shipments):
|
||||
pool = Pool()
|
||||
Move = pool.get('stock.move')
|
||||
#raise UserError(str(dir(cls)))
|
||||
#cls.store_cache(shipments)
|
||||
Date = pool.get('ir.date')
|
||||
|
||||
Equipments = pool.get('optical_equipment.equipment')
|
||||
|
||||
|
||||
for shipment in shipments:
|
||||
for move in shipment.moves:
|
||||
raise UserError(str(move.id))
|
||||
#move = Move.search(['id', '=', move.id])[0]
|
||||
if move.product_equipment:
|
||||
|
||||
for move in shipment.inventory_moves:
|
||||
if move.equipment:
|
||||
equipment = move.equipment
|
||||
Id = equipment.id
|
||||
serial = equipment.serial
|
||||
move.equipment = Id
|
||||
move.serial = serial
|
||||
move.save()
|
||||
#raise UserError(str(Id))
|
||||
#raise UserError(str((equipment.id)))
|
||||
#raise UserError(str(dir(move.equipment.propietary)))
|
||||
#Id=int(move.equipment.id)
|
||||
equipment = Equipments.search(['id', '=',Id])[0]
|
||||
#raise UserError(str(equipment))
|
||||
#raise UserError(str(Id.id))
|
||||
equipment.propietary = shipment.customer.id
|
||||
equipment.propietary_address= shipment.delivery_address.id
|
||||
equipment.state="uncontrated"
|
||||
#equipment.shipment_destination = move
|
||||
equipment.shipment_destination = shipment
|
||||
equipment.maintenance_frequency = "6" if shipment.customer.client_type == "ips" else "12"
|
||||
#raise UserError(str(equipment.propietary))
|
||||
equipment.save()
|
||||
equipment.save()
|
||||
|
||||
Move.delete([
|
||||
m for s in shipments for m in s.outgoing_moves
|
||||
|
@ -42,55 +42,67 @@ class Subscription(metaclass=PoolMeta):
|
||||
Line.save(lines)
|
||||
cls.save(subscriptions)
|
||||
|
||||
"""
|
||||
class CreateContractInvoice(Wizard):
|
||||
"Create Contract Invoice"
|
||||
__name__ = 'sale.subscription.create_invoice_contract'
|
||||
|
||||
|
||||
class CreateSubscriptionInvoice(Wizard):
|
||||
"Create Subscription Invoice"
|
||||
__name__ = 'sale.subscription.create_invoice'
|
||||
|
||||
start = StateView(
|
||||
'sale.subscription.create_invoice_contract.start',
|
||||
'optical_equipment.create_invoice_contract_start_view_form',[
|
||||
Button("Cancel", 'end', 'tryton-cancel'),
|
||||
Button("Create", 'create_invoice', 'tryton-ok', default=True),
|
||||
])
|
||||
'sale.subscription.create_invoice.start',
|
||||
'sale_subscription.create_invoice_start_view_form', [
|
||||
Button("Cancel", 'end', 'tryton-cancel'),
|
||||
Button("Create", 'create_', 'tryton-ok', default=True),
|
||||
])
|
||||
|
||||
create_invoice = StateAction('account_invoice.act_invoice_form')
|
||||
create_ = StateTransition()
|
||||
|
||||
|
||||
def do_create_invoice(self, action):
|
||||
'Create and return an invoice'
|
||||
raise UserError(str(dir(action)))
|
||||
|
||||
invoice_lines = []
|
||||
for line in self.lines:
|
||||
invoice_lines.append(line.get_invoice_line())
|
||||
invoice_lines = list(chain(*invoice_lines))
|
||||
|
||||
if not invoice_lines:
|
||||
return
|
||||
|
||||
|
||||
invoice = self._get_invoice_sale()
|
||||
if getattr(invoice, 'lines', None):
|
||||
invoice_lines = list(invoice.lines) + invoice_lines
|
||||
invoice.lines = invoice_lines
|
||||
|
||||
return invoice
|
||||
|
||||
class CreateContractInvoiceStart(ModelView):
|
||||
"Create Subscription Invoice"
|
||||
__name__ = 'sale.subscription.create_invoice_contract.start'
|
||||
|
||||
date = fields.Date("Date")
|
||||
|
||||
@classmethod
|
||||
def default_date(cls):
|
||||
def generate_invoice(self, date=None):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
Configuration = pool.get('account.configuration')
|
||||
Config = Configuration(1)
|
||||
Journals = pool.get('account.journal')
|
||||
Invoice = pool.get('account.invoice')
|
||||
InvoiceLine = pool.get('account.invoice.line')
|
||||
subscription = self.records[0]
|
||||
invoice_lines = []
|
||||
|
||||
return Date.today()
|
||||
if date is None:
|
||||
date = Date.today()
|
||||
|
||||
for line in subscription.lines:
|
||||
invoice_lines.append(
|
||||
InvoiceLine(
|
||||
origin=line,
|
||||
product=line.service,
|
||||
account=line.service.product.account_revenue_used,
|
||||
quantity=line.quantity,
|
||||
unit=line.unit,
|
||||
unit_price=line.unit_price,
|
||||
)
|
||||
)
|
||||
|
||||
invoice = Invoice(
|
||||
type='out',
|
||||
journal=Journals.search(['type', '=', 'revenue'])[0],
|
||||
account=Config.default_account_receivable,
|
||||
party=subscription.party,
|
||||
invoice_date=date,
|
||||
invoice_address=subscription.invoice_address,
|
||||
lines=invoice_lines,
|
||||
)
|
||||
invoice.save()
|
||||
|
||||
|
||||
def transition_create_(self):
|
||||
pool = Pool()
|
||||
Subscription = pool.get('sale.subscription')
|
||||
|
||||
self.generate_invoice(date=self.start.date)
|
||||
|
||||
return 'end'
|
||||
|
||||
"""
|
||||
|
||||
class SubscriptionEquipment(ModelSQL):
|
||||
'Optical Equipment - Subscription'
|
||||
|
@ -12,21 +12,14 @@
|
||||
<record model="ir.ui.menu" id="sale_subscription.menu_create_invoice">
|
||||
<field name="active" eval="False"/>
|
||||
</record>
|
||||
<!--
|
||||
<record model="ir.ui.view" id="create_invoice_contract_start_view_form">
|
||||
<field name="model">sale.subscription.create_invoice_contract.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">create_invoice_contract_form</field>
|
||||
<record model="ir.action.wizard" id="create_invoice">
|
||||
<field name="name">Create_Invoices</field>
|
||||
<field name="wiz_name">sale.subscription.create_invoice</field>
|
||||
<field name="model">sale.subscription</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="create_invoice_contract">
|
||||
<field name="name">Invoice Contract</field>
|
||||
<field name="wiz_name">sale.subscription.create_invoice_contract</field>
|
||||
<field name="model">sale.subscription</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="create_invoice_contract_keyword">
|
||||
<record model="ir.action.keyword" id="create_invoice_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">sale.subscription,-1</field>
|
||||
<field name="action" ref="create_invoice_contract"/>
|
||||
</record>
|
||||
-->
|
||||
<field name="action" ref="create_invoice"/>
|
||||
</record>
|
||||
</tryton>
|
||||
|
Loading…
Reference in New Issue
Block a user