From ccfadbdd90a344d7d134a8be48ca8b8d1e13cb26 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Wed, 23 Nov 2011 15:16:16 +0100 Subject: [PATCH] [IMP] Removed the wizard to install chart of accounts -> install automatically If installation from SaaS, we know the country of the main company so that we can install the chart of account by default if it exists for this country. If not from SaaS, you get the wizard like before. bzr revid: fp@tinyerp.com-20111123141616-jrz846u7hd3rubbc --- addons/account/__openerp__.py | 1 + addons/account/account.py | 16 +-------------- addons/account/account_installer.xml | 2 +- addons/account/account_pre_install.yml | 22 ++++++++++++++++++++ addons/account/demo/account_demo.xml | 28 +++++++++++++------------- addons/account/installer.py | 5 ++++- addons/product/product_data.xml | 4 ++-- 7 files changed, 45 insertions(+), 33 deletions(-) create mode 100644 addons/account/account_pre_install.yml diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 81d09b30ae9..ec61248e147 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -125,6 +125,7 @@ module named account_voucher. "wizard/account_report_balance_sheet_view.xml", "edi/invoice_action_data.xml", "account_bank_view.xml", + "account_pre_install.yml" ], 'demo_xml': [ 'demo/account_demo.xml', diff --git a/addons/account/account.py b/addons/account/account.py index c8895fa6946..8aa1569520e 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -861,19 +861,6 @@ class account_fiscalyear(osv.osv): } _order = "date_start" - def _check_fiscal_year(self, cr, uid, ids, context=None): - current_fiscal_yr = self.browse(cr, uid, ids, context=context)[0] - obj_fiscal_ids = self.search(cr, uid, [('company_id', '=', current_fiscal_yr.company_id.id)], context=context) - obj_fiscal_ids.remove(ids[0]) - data_fiscal_yr = self.browse(cr, uid, obj_fiscal_ids, context=context) - - for old_fy in data_fiscal_yr: - if old_fy.company_id.id == current_fiscal_yr['company_id'].id: - # Condition to check if the current fiscal year falls in between any previously defined fiscal year - if old_fy.date_start <= current_fiscal_yr['date_start'] <= old_fy.date_stop or \ - old_fy.date_start <= current_fiscal_yr['date_stop'] <= old_fy.date_stop: - return False - return True def _check_duration(self, cr, uid, ids, context=None): obj_fy = self.browse(cr, uid, ids[0], context=context) @@ -882,8 +869,7 @@ class account_fiscalyear(osv.osv): return True _constraints = [ - (_check_duration, 'Error! The start date of the fiscal year must be before his end date.', ['date_start','date_stop']), - (_check_fiscal_year, 'Error! You can not define overlapping fiscal years for the same company.',['date_start', 'date_stop']) + (_check_duration, 'Error! The start date of the fiscal year must be before his end date.', ['date_start','date_stop']) ] def create_period3(self, cr, uid, ids, context=None): diff --git a/addons/account/account_installer.xml b/addons/account/account_installer.xml index 230078c4e33..e249f8fa872 100644 --- a/addons/account/account_installer.xml +++ b/addons/account/account_installer.xml @@ -57,7 +57,7 @@ Accounting 5 - + diff --git a/addons/account/account_pre_install.yml b/addons/account/account_pre_install.yml new file mode 100644 index 00000000000..13adbe8108f --- /dev/null +++ b/addons/account/account_pre_install.yml @@ -0,0 +1,22 @@ +- + I configure automatically if the country is set on the company, mainly for online offers. +- + !python {model: account.installer}: | + modules = self.pool.get('ir.module.module') + wizards = self.pool.get('ir.actions.todo') + wiz = wizards.browse(cr, uid, ref('account.account_configuration_installer_todo')) + part = self.pool.get('res.partner').browse(cr, uid, ref('base.main_partner')) + # if we know the country and the wizard has not yet been executed, we do it + if (part.country.id) and (wiz.state=='open'): + mod = 'l10n_'+part.country.code.lower() + ids = modules.search(cr, uid, [ ('name','=',mod) ], context=context) + if ids: + wizards.write(cr, uid, [ref('account.account_configuration_installer_todo')], { + 'state': 'done' + }) + wiz_id = self.create(cr, uid, { + 'charts': mod + }) + self.execute_simple(cr, uid, [wiz_id]) + modules.state_update(cr, uid, ids, + 'to install', ['uninstalled'], context=context) diff --git a/addons/account/demo/account_demo.xml b/addons/account/demo/account_demo.xml index 566185c70c3..0bbfa71af62 100644 --- a/addons/account/demo/account_demo.xml +++ b/addons/account/demo/account_demo.xml @@ -7,7 +7,7 @@ --> - + @@ -20,7 +20,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -47,7 +47,7 @@ - + @@ -56,7 +56,7 @@ - + @@ -65,7 +65,7 @@ - + @@ -74,7 +74,7 @@ - + @@ -83,7 +83,7 @@ - + @@ -92,7 +92,7 @@ - + @@ -101,7 +101,7 @@ - + @@ -110,7 +110,7 @@ - + @@ -119,7 +119,7 @@ - + @@ -129,6 +129,6 @@ - + diff --git a/addons/account/installer.py b/addons/account/installer.py index fcd29e9e323..a0157e51c8e 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -111,6 +111,10 @@ class account_installer(osv.osv_memory): return {} def execute(self, cr, uid, ids, context=None): + self.execute_simple(cr, uid, ids, context) + super(account_installer, self).execute(cr, uid, ids, context=context) + + def execute_simple(self, cr, uid, ids, context=None): if context is None: context = {} fy_obj = self.pool.get('account.fiscalyear') @@ -219,7 +223,6 @@ class account_installer(osv.osv_memory): fy_obj.create_period(cr, uid, [fiscal_id]) elif res['period'] == '3months': fy_obj.create_period3(cr, uid, [fiscal_id]) - super(account_installer, self).execute(cr, uid, ids, context=context) def modules_to_install(self, cr, uid, ids, context=None): modules = super(account_installer, self).modules_to_install( diff --git a/addons/product/product_data.xml b/addons/product/product_data.xml index fc085aab922..122c8594de4 100644 --- a/addons/product/product_data.xml +++ b/addons/product/product_data.xml @@ -23,8 +23,8 @@ + Resource: product.uom + --> PCE