mirror of
https://github.com/bringout/oca-ocb-l10n_americas.git
synced 2026-04-27 00:12:01 +02:00
Initial commit: L10N_Americas packages
This commit is contained in:
commit
12b27ce151
714 changed files with 79328 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
from odoo import api, Command, models
|
||||
|
||||
|
||||
class AccountAccount(models.Model):
|
||||
_inherit = 'account.account'
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
# 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_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
|
||||
account.tag_ids = [Command.link(tag_id)]
|
||||
return accounts
|
||||
Loading…
Add table
Add a link
Reference in a new issue