mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP] - _prepare_contract_value for sale order confirm
This commit is contained in:
@@ -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(
|
||||||
{
|
rec._prepare_contract_value(contract_template)
|
||||||
'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,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
contract._onchange_contract_template_id()
|
contract._onchange_contract_template_id()
|
||||||
order_lines.create_contract_line(contract)
|
order_lines.create_contract_line(contract)
|
||||||
|
|||||||
Reference in New Issue
Block a user