From 64a4f20a64d18ce1c4ff0e711960b5442be73908 Mon Sep 17 00:00:00 2001 From: David Tran Date: Wed, 11 Aug 2021 06:20:24 +0000 Subject: [PATCH] [FIX] l10n_vn: wrong account code for the revenue deduction accounts closes odoo/odoo#75042 X-original-commit: bfe7190215c3014df2fb468f1860b24759de2e38 Signed-off-by: Laurent Smet --- addons/l10n_vn/__manifest__.py | 2 +- .../l10n_vn/data/account.account.template.csv | 6 ++--- .../migrations/14.0.2.0.1/post-migration.py | 22 +++++++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 addons/l10n_vn/migrations/14.0.2.0.1/post-migration.py diff --git a/addons/l10n_vn/__manifest__.py b/addons/l10n_vn/__manifest__.py index 6004735228f..c3ddb5aa91a 100644 --- a/addons/l10n_vn/__manifest__.py +++ b/addons/l10n_vn/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Vietnam - Accounting", - "version": "2.0", + "version": "2.0.1", "author": "General Solutions", 'website': 'http://gscom.vn', 'category': 'Accounting/Localizations/Account Charts', diff --git a/addons/l10n_vn/data/account.account.template.csv b/addons/l10n_vn/data/account.account.template.csv index 34b17e12d7a..a412f97705a 100644 --- a/addons/l10n_vn/data/account.account.template.csv +++ b/addons/l10n_vn/data/account.account.template.csv @@ -147,9 +147,9 @@ "chart5117","Revenue from investment properties",5117,"account.data_account_type_revenue","vn_template","False" "chart5118","Other revenue",5118,"account.data_account_type_revenue","vn_template","False" "chart515","Financial income",515,"account.data_account_type_revenue","vn_template","False" -"chart5221","Trade discounts",5221,"account.data_account_type_revenue","vn_template","False" -"chart5222","Sales returns",5222,"account.data_account_type_revenue","vn_template","False" -"chart5223","Sales rebates",5223,"account.data_account_type_revenue","vn_template","False" +"chart5211","Trade discounts",5211,"account.data_account_type_revenue","vn_template","False" +"chart5212","Sales returns",5212,"account.data_account_type_revenue","vn_template","False" +"chart5213","Sales rebates",5213,"account.data_account_type_revenue","vn_template","False" "chart6111","Purchases of raw materials",6111,"account.data_account_type_direct_costs","vn_template","False" "chart621","Direct raw material costs",621,"account.data_account_type_direct_costs","vn_template","False" "chart622","Direct labour costs",622,"account.data_account_type_direct_costs","vn_template","False" diff --git a/addons/l10n_vn/migrations/14.0.2.0.1/post-migration.py b/addons/l10n_vn/migrations/14.0.2.0.1/post-migration.py new file mode 100644 index 00000000000..5033b0372b3 --- /dev/null +++ b/addons/l10n_vn/migrations/14.0.2.0.1/post-migration.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +from odoo import api, SUPERUSER_ID + +FIXED_ACCOUNTS_MAP = { + '5221': '5211', + '5222': '5212', + '5223': '5213' + } + + +def _fix_revenue_deduction_accounts_code(env): + vn_template = env.ref('l10n_vn.vn_template') + for company in env['res.company'].with_context(active_test=False).search([('chart_template_id', '=', vn_template.id)]): + for incorrect_code, correct_code in FIXED_ACCOUNTS_MAP.items(): + account = env['account.account'].search([('code', '=', incorrect_code), ('company_id', '=', company.id)]) + if account: + account.write({'code': correct_code}) + + +def migrate(cr, version): + env = api.Environment(cr, SUPERUSER_ID, {}) + _fix_revenue_deduction_accounts_code(env)