[12.0][FIX] - Run onchange contract_type when changing the contract template

Fix this use-case:

If the contract journal is not set on the contract template the contract is created
without a journal when confirming the sale order
This commit is contained in:
sbejaoui
2019-11-26 09:54:55 +01:00
parent 455fb5d6f3
commit 1e9755d1e0
2 changed files with 3 additions and 1 deletions

View File

@@ -209,6 +209,7 @@ class ContractContract(models.Model):
field.name in self.NO_SYNC, field.name in self.NO_SYNC,
) )
): ):
if self.contract_template_id[field_name]:
self[field_name] = self.contract_template_id[field_name] self[field_name] = self.contract_template_id[field_name]
@api.onchange('partner_id') @api.onchange('partner_id')

View File

@@ -82,6 +82,7 @@ class SaleOrder(models.Model):
) )
contracts |= contract contracts |= contract
contract._onchange_contract_template_id() contract._onchange_contract_template_id()
contract._onchange_contract_type()
order_lines.create_contract_line(contract) order_lines.create_contract_line(contract)
order_lines.write({'contract_id': contract.id}) order_lines.write({'contract_id': contract.id})
for line in line_to_update_contract: for line in line_to_update_contract: