From 1f48ac7fd640bcd1bb3ae46041af9bb84a0fe9f1 Mon Sep 17 00:00:00 2001 From: Adrien Peiffer Date: Thu, 27 Nov 2014 10:18:59 +0100 Subject: [PATCH] [MIG] account_chart_update: Migration to 8.0 * Move out of unported * Set account_chart_update installable * value_reference of ir.property is a char * Use get_by_record method of ir.property * number digits is returned before assignment in case of property exist but account not * product_obj isn't used --- account_chart_update/__openerp__.py | 2 +- .../wizard/wizard_chart_update.py | 19 +-- .../wizard/wizard_chart_update_view.xml | 150 ++++++++++++++++++ 3 files changed, 159 insertions(+), 12 deletions(-) create mode 100644 account_chart_update/wizard/wizard_chart_update_view.xml diff --git a/account_chart_update/__openerp__.py b/account_chart_update/__openerp__.py index 1ebdbfc8..e1f10c21 100644 --- a/account_chart_update/__openerp__.py +++ b/account_chart_update/__openerp__.py @@ -72,5 +72,5 @@ Any problem found while updating will be shown on the last step. 'wizard/wizard_chart_update_view.xml', ], "active": False, - "installable": True + 'installable': True } diff --git a/account_chart_update/wizard/wizard_chart_update.py b/account_chart_update/wizard/wizard_chart_update.py index 1cd81750..891faf0d 100644 --- a/account_chart_update/wizard/wizard_chart_update.py +++ b/account_chart_update/wizard/wizard_chart_update.py @@ -19,10 +19,6 @@ # along with this program. If not, see . # ############################################################################## -""" -Account Chart Update Wizard -""" - from openerp.osv import fields, orm from openerp.tools.translate import _ import logging @@ -255,7 +251,6 @@ class wizard_update_charts_accounts(orm.TransientModel): if context is None: context = {} property_obj = self.pool.get('ir.property') - account_obj = self.pool.get('account.account') if not company_id: user = self.pool.get('res.users').browse(cr, uid, uid, context) company_id = user.company_id.id @@ -265,6 +260,7 @@ class wizard_update_charts_accounts(orm.TransientModel): ('res_id', '=', False), ('value_reference', '!=', False) ]) + number_digits = 6 if not property_ids: # Try to get a generic (no-company) property property_ids = property_obj.search(cr, uid, [ @@ -272,15 +268,13 @@ class wizard_update_charts_accounts(orm.TransientModel): ('res_id', '=', False), ('value_reference', '!=', False) ]) - number_digits = 6 if property_ids: prop = property_obj.browse( cr, uid, property_ids[0], context=context) - account_id = prop.value_reference.id - if account_id: - code = account_obj.read( - cr, uid, account_id, ['code'], context)['code'] - number_digits = len(code) + account = property_obj.get_by_record(cr, uid, prop, + context=context) + if account: + number_digits = len(account.code) return number_digits _defaults = { @@ -464,6 +458,7 @@ class wizard_update_charts_accounts(orm.TransientModel): 'notes': _('Name or code not found.'), }, context) elif wizard.update_tax_code: + # Check the tax code for changes. modified = False notes = "" tax_code = tax_code_obj.browse( @@ -479,6 +474,7 @@ class wizard_update_charts_accounts(orm.TransientModel): modified = True # TODO: We could check other account fields for changes... if modified: + # Tax code to update. updated_tax_codes += 1 wiz_tax_code_obj.create(cr, uid, { 'tax_code_id': tax_code_template.id, @@ -533,6 +529,7 @@ class wizard_update_charts_accounts(orm.TransientModel): else: delay_wiz_tax.append(vals_wiz) elif wizard.update_tax: + # Check the tax for changes. modified = False notes = "" tax = tax_obj.browse(cr, uid, tax_id, context=context) diff --git a/account_chart_update/wizard/wizard_chart_update_view.xml b/account_chart_update/wizard/wizard_chart_update_view.xml new file mode 100644 index 00000000..91c7927d --- /dev/null +++ b/account_chart_update/wizard/wizard_chart_update_view.xml @@ -0,0 +1,150 @@ + + + + + + + + Update Chart of Accounts from a Chart Template + + wizard.update.charts.accounts + +
+
+ +
+ +

+

This wizard will update your accounts, taxes and fiscal positions according to the selected chart template

+

+
+ + + + + + + + + + + + + + + + + + + + +
+

If you leave these options set, the wizard will not just create new records, but also update records with changes (i.e. different tax amount)

+

Note: Not all the fields are tested for changes, just the main ones

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + Update chart of accounts + ir.actions.act_window + wizard.update.charts.accounts + form + form + new + + + + +
+