Skip to content

Commit

Permalink
[FIX] account_fiscal_year_closing: create/write
Browse files Browse the repository at this point in the history
When creating from scratch, Mapping is used as an Array instead of simple id (due to many in another many).
When coming from a template, id is used
To take into account this particularity, check the type before taking the id of the array.
  • Loading branch information
Borruso committed Jul 26, 2024
1 parent 14b7991 commit 4c886b7
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,13 +553,17 @@ class AccountFiscalyearClosingMapping(models.Model):
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals.get("dest_account_id", False):
if vals.get("dest_account_id", False) and isinstance(
vals["dest_account_id"], list
):
vals["dest_account_id"] = vals["dest_account_id"][0]
res = super(AccountFiscalyearClosingMapping, self).create(vals_list)
return res

def write(self, vals):
if vals.get("dest_account_id", False):
if vals.get("dest_account_id", False) and isinstance(
vals["dest_account_id"], list
):
vals["dest_account_id"] = vals["dest_account_id"][0]
res = super(AccountFiscalyearClosingMapping, self).write(vals)
return res

Check warning on line 569 in account_fiscal_year_closing/models/account_fiscalyear_closing.py

View check run for this annotation

Codecov / codecov/patch

account_fiscal_year_closing/models/account_fiscalyear_closing.py#L567-L569

Added lines #L567 - L569 were not covered by tests
Expand Down

0 comments on commit 4c886b7

Please sign in to comment.