From fb4c3ee760231b066f4085984e8abcbf8f4b2b56 Mon Sep 17 00:00:00 2001 From: "Docker @ kuntrawant" Date: Wed, 13 Jul 2022 11:17:07 +0200 Subject: [PATCH] [FIX][account_fiscal_year_closing] fix create and write --- .../models/account_fiscalyear_closing.py | 13 +++++++++++++ .../tests/test_account_fiscal_year_closing.py | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/account_fiscal_year_closing/models/account_fiscalyear_closing.py b/account_fiscal_year_closing/models/account_fiscalyear_closing.py index 5e136002cb8..c8f2e3c8400 100644 --- a/account_fiscal_year_closing/models/account_fiscalyear_closing.py +++ b/account_fiscal_year_closing/models/account_fiscalyear_closing.py @@ -551,6 +551,19 @@ class AccountFiscalyearClosingMapping(models.Model): string="Destination account", ) + @api.model + def create(self, vals): + if "dest_account_id" in vals: + vals["dest_account_id"] = vals["dest_account_id"][0] + res = super(AccountFiscalyearClosingMapping, self).create(vals) + return res + + def write(self, vals): + if "dest_account_id" in vals: + vals["dest_account_id"] = vals["dest_account_id"][0] + res = super(AccountFiscalyearClosingMapping, self).write(vals) + return res + def dest_move_line_prepare(self, dest, balance, partner_id=False): self.ensure_one() move_line = {} diff --git a/account_fiscal_year_closing/tests/test_account_fiscal_year_closing.py b/account_fiscal_year_closing/tests/test_account_fiscal_year_closing.py index fca6c1441b7..71cdfbb4674 100644 --- a/account_fiscal_year_closing/tests/test_account_fiscal_year_closing.py +++ b/account_fiscal_year_closing/tests/test_account_fiscal_year_closing.py @@ -5,10 +5,12 @@ from dateutil.relativedelta import relativedelta from odoo import fields +from odoo.tests import tagged from odoo.addons.account.tests.common import AccountTestInvoicingCommon +@tagged("post_install") class TestAccountFiscalYearClosing(AccountTestInvoicingCommon): @classmethod def setUpClass(cls, chart_template_ref=None): @@ -296,7 +298,7 @@ def test_account_closing(self): 0, { "src_accounts": w, - "dest_account_id": self.a_pf_closing.id, + "dest_account_id": [self.a_pf_closing.id], }, ) for w in inc_accounts + exp_accounts @@ -321,7 +323,7 @@ def test_account_closing(self): { "name": "profit & loss", "src_accounts": "pf_acc", - "dest_account_id": self.a_bal_closing.id, + "dest_account_id": [self.a_bal_closing.id], }, ), ],