From db2c22f0d44ca9ef588b471ded909fd4e26ad32b Mon Sep 17 00:00:00 2001 From: Trinh Ngoc Hung Date: Tue, 19 Dec 2023 18:55:50 +0700 Subject: [PATCH] [FIX] l10n_vn: Account type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 242: These future expenses must be deferred on the company’s balance sheet until the moment in time they can be recognized, at once or over a defined period, on the Profit and Loss statement. 6274, 6414, 6424: Fixed asset depreciation not expense closes odoo/odoo#146802 Signed-off-by: Brice Bartoletti (bib) --- addons/l10n_vn/__manifest__.py | 2 +- .../data/template/account.account-vn.csv | 8 +++--- .../migrations/17.0.2.0.2/post-migration.py | 27 +++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 addons/l10n_vn/migrations/17.0.2.0.2/post-migration.py diff --git a/addons/l10n_vn/__manifest__.py b/addons/l10n_vn/__manifest__.py index 7edb63f664b..79342feb879 100644 --- a/addons/l10n_vn/__manifest__.py +++ b/addons/l10n_vn/__manifest__.py @@ -3,7 +3,7 @@ 'name': 'Vietnam - Accounting', 'icon': '/account/static/description/l10n.png', 'countries': ['vn'], - 'version': '2.0.1', + 'version': '2.0.2', 'author': 'General Solutions', 'website': 'https://www.odoo.com/documentation/17.0/applications/finance/fiscal_localizations/vietnam.html', 'category': 'Accounting/Localizations/Account Charts', diff --git a/addons/l10n_vn/data/template/account.account-vn.csv b/addons/l10n_vn/data/template/account.account-vn.csv index 7337cd10023..a6ce4b0bede 100644 --- a/addons/l10n_vn/data/template/account.account-vn.csv +++ b/addons/l10n_vn/data/template/account.account-vn.csv @@ -71,7 +71,7 @@ "chart2411","Fixed assets prior to commissioning","2411","asset_non_current","False","Mua sắm TSCĐ" "chart2412","Construction works","2412","asset_non_current","False","Xây dựng cơ bản" "chart2413","Major repairs of fixed assets","2413","asset_non_current","False","Sửa chữa lớn TSCĐ" -"chart242","Prepaid expenses","242","asset_non_current","False","Chi phí trả trước" +"chart242","Prepaid expenses","242","asset_prepayments","False","Chi phí trả trước" "chart243","Deferred tax assets","243","asset_non_current","False","Tài sản thuế thu nhập hoãn lại" "chart244","Mortgage, collaterals and deposits","244","asset_non_current","False","Cầm cố, thế chấp, ký quỹ, kýcược" "chart331","Trade payables","331","liability_payable","True","Phải trả cho người bán" @@ -162,7 +162,7 @@ "chart6271","Factory staff costs","6271","expense","False","Chi phí nhân viên phân xưởng" "chart6272","Material costs","6272","expense","False","Chi phí nguyên, vật liệu" "chart6273","Production tools and instruments","6273","expense","False","Chi phí dụng cụ sản xuất" -"chart6274","Fixed asset depreciation","6274","expense","False","Chi phí khấu hao TSCĐ" +"chart6274","Fixed asset depreciation","6274","expense_depreciation","False","Chi phí khấu hao TSCĐ" "chart6277","Outside services","6277","expense","False","Chi phí dịch vụ mua ngoài" "chart6278","Other expenses","6278","expense","False","Chi phí bằng tiền khác" "chart631","Production costs","631","expense_direct_cost","False","Giá thành sản xuất" @@ -171,14 +171,14 @@ "chart6411","Staff expenses","6411","expense","False","Chi phí nhân viên" "chart6412","Materials and packing materials","6412","expense","False","Chi phí nguyên vật liệu, bao bì" "chart6413","Tools and instruments","6413","expense","False","Chi phí dụng cụ, đồ dùng" -"chart6414","Fixed asset deprecation","6414","expense","False","Chi phí khấu hao TSCĐ" +"chart6414","Fixed asset deprecation","6414","expense_depreciation","False","Chi phí khấu hao TSCĐ" "chart6415","Warranty expenses","6415","expense","False","Chi phí bảo hành" "chart6417","Outside services","6417","expense","False","Chi phí dịch vụ mua ngoài" "chart6418","Other expenses","6418","expense","False","Chi phí bằng tiền khác" "chart6421","Staff expenses","6421","expense","False","Chi phí nhân viên" "chart6422","Office supply expenses","6422","expense","False","Chi phí vật liệu quản lý" "chart6423","Office equipment expenses","6423","expense","False","Chi phí đồ dùng văn phòng" -"chart6424","Fixed asset depreciation","6424","expense","False","Chi phí khấu hao TSCĐ" +"chart6424","Fixed asset depreciation","6424","expense_depreciation","False","Chi phí khấu hao TSCĐ" "chart6425","Taxes, fees and charges","6425","expense","False","Thuế, phí và lệ phí" "chart6426","Provision expenses","6426","expense","False","Chi phí dự phòng" "chart6427","Outside services","6427","expense","False","Chi phí dịch vụ mua ngoài" diff --git a/addons/l10n_vn/migrations/17.0.2.0.2/post-migration.py b/addons/l10n_vn/migrations/17.0.2.0.2/post-migration.py new file mode 100644 index 00000000000..a94c411af47 --- /dev/null +++ b/addons/l10n_vn/migrations/17.0.2.0.2/post-migration.py @@ -0,0 +1,27 @@ +from odoo import api, SUPERUSER_ID +from odoo.osv import expression + +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')]): + doamin = expression.AND([ + [('company_id', '=', company.id), ('account_type', '!=', correct_account_type)], + expression.OR([ + [('code', 'like', f'{code}%')] for code in accounts_code + ]) + ]) + domains_per_company.append(doamin) + accounts = env['account.account'].search(expression.OR(domains_per_company)) + accounts.account_type = correct_account_type + + +def migrate(cr, version): + env = api.Environment(cr, SUPERUSER_ID, {}) + _fix_accounts_type(env)