Browse Source

[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
pull/422/head
sbejaoui 5 years ago
parent
commit
1e9755d1e0
  1. 3
      contract/models/contract.py
  2. 1
      product_contract/models/sale_order.py

3
contract/models/contract.py

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

1
product_contract/models/sale_order.py

@ -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:

Loading…
Cancel
Save