mirror of
https://github.com/bringout/oca-ocb-l10n_americas.git
synced 2026-04-27 11:32:06 +02:00
19.0 vanilla
This commit is contained in:
parent
89c6e82fe7
commit
1b82c20a58
572 changed files with 43570 additions and 53303 deletions
|
|
@ -9,9 +9,11 @@ class AccountAccount(models.Model):
|
|||
# EXTENDS account - ensure there is a tag on created MX accounts
|
||||
# The computation is a bit naive and might not be correct in all cases.
|
||||
accounts = super().create(vals_list)
|
||||
debit_tag = self.env.ref('l10n_mx.tag_debit_balance_account')
|
||||
credit_tag = self.env.ref('l10n_mx.tag_credit_balance_account')
|
||||
mx_account_no_tags = accounts.filtered(lambda a: a.company_id.country_code == 'MX' and not a.tag_ids & (credit_tag + debit_tag))
|
||||
debit_tag = self.env.ref('l10n_mx.tag_debit_balance_account', raise_if_not_found=False)
|
||||
credit_tag = self.env.ref('l10n_mx.tag_credit_balance_account', raise_if_not_found=False)
|
||||
if not debit_tag or not credit_tag:
|
||||
return accounts
|
||||
mx_account_no_tags = accounts.filtered(lambda a: 'MX' in a.company_ids.mapped('country_code') and not a.tag_ids & (credit_tag + debit_tag))
|
||||
DEBIT_CODES = ['1', '5', '6', '7'] # all other codes are considered "credit"
|
||||
for account in mx_account_no_tags:
|
||||
tag_id = debit_tag.id if account.code[0] in DEBIT_CODES else credit_tag.id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue