Browse Source

[IMP] - _prepare_contract_value for sale order confirm

pull/208/head
sbejaoui 6 years ago
committed by Thomas Binsfeld
parent
commit
fc47a1edef
  1. 22
      product_contract/models/sale_order.py

22
product_contract/models/sale_order.py

@ -17,6 +17,18 @@ class SaleOrder(models.Model):
def _compute_is_contract(self): def _compute_is_contract(self):
self.is_contract = any(self.order_line.mapped('is_contract')) self.is_contract = any(self.order_line.mapped('is_contract'))
@api.multi
def _prepare_contract_value(self, contract_template):
self.ensure_one()
return {
'name': '{template_name}: {sale_name}'.format(
template_name=contract_template.name, sale_name=self.name
),
'partner_id': self.partner_id.id,
'recurring_invoices': True,
'contract_template_id': contract_template.id,
}
@api.multi @api.multi
def action_confirm(self): def action_confirm(self):
""" If we have a contract in the order, set it up """ """ If we have a contract in the order, set it up """
@ -36,15 +48,7 @@ class SaleOrder(models.Model):
== contract_template == contract_template
) )
contract = contract_env.create( contract = contract_env.create(
{
'name': '{template_name}: {sale_name}'.format(
template_name=contract_template.name,
sale_name=rec.name,
),
'partner_id': rec.partner_id.id,
'recurring_invoices': True,
'contract_template_id': contract_template.id,
}
rec._prepare_contract_value(contract_template)
) )
contract._onchange_contract_template_id() contract._onchange_contract_template_id()
order_lines.create_contract_line(contract) order_lines.create_contract_line(contract)

Loading…
Cancel
Save