mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[MIG] contract_mandate: Migration to 13.0
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user