modifity to wizzard 'CreateSubscriptionInvoice'
This commit is contained in:
parent
6a3ce61e06
commit
e9f288bfbd
@ -27,4 +27,5 @@ def register():
|
|||||||
module='optical_equipment', type_='model')
|
module='optical_equipment', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
sale.CreateSubscription,
|
sale.CreateSubscription,
|
||||||
|
subscription.CreateSubscriptionInvoice,
|
||||||
module='optical_equipment', type_='wizard')
|
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,
|
sale_destination = fields.Reference("Sale Destination", selection='get_destination',select=True,
|
||||||
states={'readonly': 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
|
del _states_serial, _states, _depends
|
||||||
|
|
||||||
|
47
move.py
47
move.py
@ -63,21 +63,18 @@ class ShipmentOut(metaclass=PoolMeta):
|
|||||||
__name__ = 'stock.shipment.out'
|
__name__ = 'stock.shipment.out'
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
def get_outgoing_moves(self, name):
|
||||||
@ModelView.button
|
moves = []
|
||||||
@Workflow.transition('picked')
|
if self.state == 'done':
|
||||||
@set_employee('picked_by')
|
for move in self.inventory_moves:
|
||||||
def pick(cls, shipments):
|
moves.append(move.id)
|
||||||
pool = Pool()
|
return moves
|
||||||
Move = pool.get('stock.move')
|
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
|
@classmethod
|
||||||
@ModelView.button
|
@ModelView.button
|
||||||
@ -86,37 +83,21 @@ class ShipmentOut(metaclass=PoolMeta):
|
|||||||
def done(cls, shipments):
|
def done(cls, shipments):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Move = pool.get('stock.move')
|
Move = pool.get('stock.move')
|
||||||
#raise UserError(str(dir(cls)))
|
|
||||||
#cls.store_cache(shipments)
|
|
||||||
Date = pool.get('ir.date')
|
Date = pool.get('ir.date')
|
||||||
|
|
||||||
Equipments = pool.get('optical_equipment.equipment')
|
Equipments = pool.get('optical_equipment.equipment')
|
||||||
|
|
||||||
for shipment in shipments:
|
for shipment in shipments:
|
||||||
for move in shipment.moves:
|
for move in shipment.inventory_moves:
|
||||||
raise UserError(str(move.id))
|
if move.equipment:
|
||||||
#move = Move.search(['id', '=', move.id])[0]
|
|
||||||
if move.product_equipment:
|
|
||||||
|
|
||||||
equipment = move.equipment
|
equipment = move.equipment
|
||||||
Id = equipment.id
|
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]
|
equipment = Equipments.search(['id', '=',Id])[0]
|
||||||
#raise UserError(str(equipment))
|
|
||||||
#raise UserError(str(Id.id))
|
|
||||||
equipment.propietary = shipment.customer.id
|
equipment.propietary = shipment.customer.id
|
||||||
equipment.propietary_address= shipment.delivery_address.id
|
equipment.propietary_address= shipment.delivery_address.id
|
||||||
equipment.state="uncontrated"
|
equipment.state="uncontrated"
|
||||||
#equipment.shipment_destination = move
|
equipment.shipment_destination = shipment
|
||||||
equipment.maintenance_frequency = "6" if shipment.customer.client_type == "ips" else "12"
|
equipment.maintenance_frequency = "6" if shipment.customer.client_type == "ips" else "12"
|
||||||
#raise UserError(str(equipment.propietary))
|
|
||||||
equipment.save()
|
equipment.save()
|
||||||
|
|
||||||
Move.delete([
|
Move.delete([
|
||||||
|
@ -42,55 +42,67 @@ class Subscription(metaclass=PoolMeta):
|
|||||||
Line.save(lines)
|
Line.save(lines)
|
||||||
cls.save(subscriptions)
|
cls.save(subscriptions)
|
||||||
|
|
||||||
"""
|
|
||||||
class CreateContractInvoice(Wizard):
|
|
||||||
"Create Contract Invoice"
|
class CreateSubscriptionInvoice(Wizard):
|
||||||
__name__ = 'sale.subscription.create_invoice_contract'
|
"Create Subscription Invoice"
|
||||||
|
__name__ = 'sale.subscription.create_invoice'
|
||||||
|
|
||||||
start = StateView(
|
start = StateView(
|
||||||
'sale.subscription.create_invoice_contract.start',
|
'sale.subscription.create_invoice.start',
|
||||||
'optical_equipment.create_invoice_contract_start_view_form',[
|
'sale_subscription.create_invoice_start_view_form', [
|
||||||
Button("Cancel", 'end', 'tryton-cancel'),
|
Button("Cancel", 'end', 'tryton-cancel'),
|
||||||
Button("Create", 'create_invoice', 'tryton-ok', default=True),
|
Button("Create", 'create_', 'tryton-ok', default=True),
|
||||||
])
|
])
|
||||||
|
|
||||||
create_invoice = StateAction('account_invoice.act_invoice_form')
|
create_ = StateTransition()
|
||||||
|
|
||||||
|
def generate_invoice(self, date=None):
|
||||||
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):
|
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Date = pool.get('ir.date')
|
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):
|
class SubscriptionEquipment(ModelSQL):
|
||||||
'Optical Equipment - Subscription'
|
'Optical Equipment - Subscription'
|
||||||
|
@ -12,21 +12,14 @@
|
|||||||
<record model="ir.ui.menu" id="sale_subscription.menu_create_invoice">
|
<record model="ir.ui.menu" id="sale_subscription.menu_create_invoice">
|
||||||
<field name="active" eval="False"/>
|
<field name="active" eval="False"/>
|
||||||
</record>
|
</record>
|
||||||
<!--
|
<record model="ir.action.wizard" id="create_invoice">
|
||||||
<record model="ir.ui.view" id="create_invoice_contract_start_view_form">
|
<field name="name">Create_Invoices</field>
|
||||||
<field name="model">sale.subscription.create_invoice_contract.start</field>
|
<field name="wiz_name">sale.subscription.create_invoice</field>
|
||||||
<field name="type">form</field>
|
|
||||||
<field name="name">create_invoice_contract_form</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>
|
<field name="model">sale.subscription</field>
|
||||||
</record>
|
</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="keyword">form_action</field>
|
||||||
<field name="model">sale.subscription,-1</field>
|
<field name="model">sale.subscription,-1</field>
|
||||||
<field name="action" ref="create_invoice_contract"/>
|
<field name="action" ref="create_invoice"/>
|
||||||
</record>
|
</record>
|
||||||
-->
|
|
||||||
</tryton>
|
</tryton>
|
||||||
|
Loading…
Reference in New Issue
Block a user