[MIG] contract_mandate: Migration to 13.0

This commit is contained in:
Guille
2020-10-21 12:32:04 +02:00
committed by Adrià Pallejà
parent b151c8b3c0
commit 2bea3d3349
7 changed files with 21 additions and 38 deletions

View File

@@ -24,16 +24,14 @@ class ContractContract(models.Model):
string="Commercial Entity",
)
@api.multi
@api.onchange("payment_mode_id")
def _onchange_payment_mode_id(self):
self.ensure_one()
if not self.mandate_required:
self.mandate_id = False
@api.multi
def _prepare_invoice(self, date_invoice, journal=None):
invoice_vals = super(ContractContract, self)._prepare_invoice(
invoice_vals, move_form = super()._prepare_invoice(
date_invoice, journal=journal
)
if self.mandate_id:
@@ -48,18 +46,4 @@ class ContractContract(models.Model):
limit=1,
)
invoice_vals["mandate_id"] = mandate.id
return invoice_vals
@api.model
def _finalize_invoice_creation(self, invoices):
"""
This override preserves the contract when calling the partner's
onchange.
"""
mandates_by_invoice = {}
for invoice in invoices:
mandates_by_invoice[invoice] = invoice.mandate_id
res = super(ContractContract, self)._finalize_invoice_creation(invoices)
for invoice in invoices:
invoice.mandate_id = mandates_by_invoice.get(invoice)
return res
return invoice_vals, move_form