diff options
| author | Laurent Smet <las@odoo.com> | 2020-11-10 08:31:25 +0000 |
|---|---|---|
| committer | Laurent Smet <las@odoo.com> | 2020-11-10 08:35:50 +0000 |
| commit | 1fe852e032876f2f3212a43fc3115e49f4de618d (patch) | |
| tree | 66b0e6725eac23be5109a96be68f6ba3f816a8d0 /addons/l10n_mx | |
| parent | 42b3ad10e0b32b7fc72f801e2c67d6baf938c566 (diff) | |
[FIX] account,l10n_: Restore journal liquidity account hook
The overrides in l10n_ modules are broken since 14.0 because the hook no longer exists.
closes odoo/odoo#61564
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Diffstat (limited to 'addons/l10n_mx')
| -rw-r--r-- | addons/l10n_mx/models/account.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/addons/l10n_mx/models/account.py b/addons/l10n_mx/models/account.py index c1230969cd2..7c038c127d6 100644 --- a/addons/l10n_mx/models/account.py +++ b/addons/l10n_mx/models/account.py @@ -9,20 +9,18 @@ from odoo import models, api, fields, _ class AccountJournal(models.Model): _inherit = 'account.journal' - @api.model - def _prepare_liquidity_account(self, name, company, currency_id, type): - ''' - When preparing the values to use when creating the default debit and credit accounts of a - liquidity journal, set the correct tags for the mexican localization. - ''' - res = super(AccountJournal, self)._prepare_liquidity_account(name, company, currency_id, type) - if company.country_id.code == "MX": - mx_tags = self.env['account.account'].mx_search_tags(res.get('code', '')) - if mx_tags: - res.update({ - 'tag_ids': [(6, 0, [tag.id for tag in mx_tags])] - }) - return res + def _prepare_liquidity_account_vals(self, company, code, vals): + # OVERRIDE + account_vals = super()._prepare_liquidity_account_vals(company, code, vals) + + if company.country_id.code == 'MX': + # When preparing the values to use when creating the default debit and credit accounts of a + # liquidity journal, set the correct tags for the mexican localization. + account_vals.setdefault('tag_ids', []) + account_vals['tag_ids'] += [(4, tag_id) for tag_id in self.env['account.account'].mx_search_tags(code).ids] + + return account_vals + class AccountAccount(models.Model): _inherit = 'account.account' |
