mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[FIX] account_move and account_banking_mandate is not overriding the create method in batch
This commit is contained in:
@@ -173,14 +173,16 @@ class AccountBankingMandate(models.Model):
|
|||||||
% mandate.unique_mandate_reference
|
% mandate.unique_mandate_reference
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model_create_multi
|
||||||
def create(self, vals=None):
|
def create(self, vals_list):
|
||||||
unique_mandate_reference = vals.get("unique_mandate_reference")
|
for vals in vals_list:
|
||||||
if not unique_mandate_reference or unique_mandate_reference == "New":
|
unique_mandate_reference = vals.get("unique_mandate_reference")
|
||||||
vals["unique_mandate_reference"] = (
|
if not unique_mandate_reference or unique_mandate_reference == "New":
|
||||||
self.env["ir.sequence"].next_by_code("account.banking.mandate") or "New"
|
vals["unique_mandate_reference"] = (
|
||||||
)
|
self.env["ir.sequence"].next_by_code("account.banking.mandate")
|
||||||
return super().create(vals)
|
or "New"
|
||||||
|
)
|
||||||
|
return super().create(vals_list)
|
||||||
|
|
||||||
@api.onchange("partner_bank_id")
|
@api.onchange("partner_bank_id")
|
||||||
def mandate_partner_bank_change(self):
|
def mandate_partner_bank_change(self):
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ class AccountMove(models.Model):
|
|||||||
related="payment_mode_id.payment_method_id.mandate_required", readonly=True
|
related="payment_mode_id.payment_method_id.mandate_required", readonly=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model_create_multi
|
||||||
def create(self, vals):
|
def create(self, vals_list):
|
||||||
"""Fill the mandate_id from the partner if none is provided on
|
"""Fill the mandate_id from the partner if none is provided on
|
||||||
creation, using same method as upstream."""
|
creation, using same method as upstream."""
|
||||||
onchanges = {
|
onchanges = {
|
||||||
@@ -29,16 +29,17 @@ class AccountMove(models.Model):
|
|||||||
"_onchange_payment_mode_id": ["mandate_id"],
|
"_onchange_payment_mode_id": ["mandate_id"],
|
||||||
}
|
}
|
||||||
for onchange_method, changed_fields in list(onchanges.items()):
|
for onchange_method, changed_fields in list(onchanges.items()):
|
||||||
if any(f not in vals for f in changed_fields):
|
for vals in vals_list:
|
||||||
move = self.new(vals)
|
if any(f not in vals for f in changed_fields):
|
||||||
move = move.with_company(move.company_id.id)
|
move = self.new(vals)
|
||||||
getattr(move, onchange_method)()
|
move = move.with_company(move.company_id.id)
|
||||||
for field in changed_fields:
|
getattr(move, onchange_method)()
|
||||||
if field not in vals and move[field]:
|
for field in changed_fields:
|
||||||
vals[field] = move._fields[field].convert_to_write(
|
if field not in vals and move[field]:
|
||||||
move[field], move
|
vals[field] = move._fields[field].convert_to_write(
|
||||||
)
|
move[field], move
|
||||||
return super().create(vals)
|
)
|
||||||
|
return super().create(vals_list)
|
||||||
|
|
||||||
def set_mandate(self):
|
def set_mandate(self):
|
||||||
if self.payment_mode_id.payment_method_id.mandate_required:
|
if self.payment_mode_id.payment_method_id.mandate_required:
|
||||||
|
|||||||
Reference in New Issue
Block a user