mirror of
https://github.com/bringout/oca-ocb-l10n_asia-pacific.git
synced 2026-04-27 15:22:00 +02:00
19.0 vanilla
This commit is contained in:
parent
7dc55599c6
commit
7f43bbbfcc
650 changed files with 45260 additions and 33436 deletions
|
|
@ -0,0 +1,27 @@
|
|||
from odoo import api, SUPERUSER_ID
|
||||
from odoo.fields import Domain
|
||||
from odoo.release import version
|
||||
from odoo.tools import parse_version
|
||||
|
||||
FIXED_ACCOUNTS_TYPE = {
|
||||
'asset_prepayments': ['242'],
|
||||
'expense_depreciation': ['6274', '6414', '6424'],
|
||||
}
|
||||
|
||||
def _fix_accounts_type(env):
|
||||
for correct_account_type, accounts_code in FIXED_ACCOUNTS_TYPE.items():
|
||||
domains_per_company = []
|
||||
for company in env['res.company'].with_context(active_test=False).search([('chart_template', '=', 'vn')]):
|
||||
if parse_version(version) > parse_version("saas~17.5"):
|
||||
company_domain = [('company_ids', 'in', company.ids), ('account_type', '!=', correct_account_type)]
|
||||
else:
|
||||
company_domain = [('company_id', '=', company.id), ('account_type', '!=', correct_account_type)]
|
||||
doamin = Domain.AND([company_domain, Domain.OR([[('code', 'like', f'{code}%')] for code in accounts_code])])
|
||||
domains_per_company.append(doamin)
|
||||
accounts = env['account.account'].search(Domain.OR(domains_per_company))
|
||||
accounts.account_type = correct_account_type
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
_fix_accounts_type(env)
|
||||
Loading…
Add table
Add a link
Reference in a new issue