Purnendu Singh (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-bug-916347-tde into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
Related bugs:
Bug #916347 in OpenERP Addons: "Error with "Install your Chart of Accounts"
wizard"
https://bugs.launchpad.net/openobject-addons/+bug/916347
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-916347-tde/+merge/92918
Hello,
Fixes:
https://bugs.launchpad.net/openobject-addons/+bug/916347
Thanks,
Purnendu Singh
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-916347-tde/+merge/92918
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-bug-916347-tde.
=== modified file 'account/account_view.xml'
--- account/account_view.xml 2012-02-13 13:17:02 +0000
+++ account/account_view.xml 2012-02-14 06:42:23 +0000
@@ -2494,11 +2494,20 @@
<field name="model_id" ref="base.model_ir_actions_todo"/>
<field eval="5" name="sequence"/>
<field name="code">
-act_window_ids = pool.get('ir.actions.act_window').search(cr, uid,[('name', 'in', ('Accounting Chart Configuration', 'Generate Chart of Accounts from a Chart Template'))], context=context)
+# check for unconfigured companies
+account_installer_obj = self.pool.get('account.installer')
+account_installer_obj.check_unconfigured_cmp(cr, uid, context=context)
+action_ids = []
+# fetch the act_window actions related to chart of account configuration
+# we use ir.actions.todo to enable the possibility for other modules to insert their own
+# wizards during the configuration process
+ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'action_wizard_multi_chart')
+if ref:
+ action_ids += [ref[1]]
ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'action_account_configuration_installer')
if ref:
- act_window_ids += [ref[1]]
-todo_ids = pool.get('ir.actions.todo').search(cr, uid, [('action_id', 'in', act_window_ids)], context=context)
+ action_ids += [ref[1]]
+todo_ids = pool.get('ir.actions.todo').search(cr, uid, [('action_id', 'in', action_ids)], context=context)
pool.get('ir.actions.todo').write(cr, uid, todo_ids, {'state':'open'}, context=context)
action = pool.get('res.config').next(cr, uid, [], context)
</field>
=== modified file 'account/installer.py'
--- account/installer.py 2011-12-19 16:54:40 +0000
+++ account/installer.py 2012-02-14 06:42:23 +0000
@@ -78,15 +78,26 @@
'has_default_company': _default_has_default_company,
'charts': 'configurable'
}
-
- def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
- res = super(account_installer, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
+
+ def get_unconfigured_cmp(self, cr, uid, context=None):
+ """ get the list of companies that have not been configured yet
+ but don't care about the demo chart of accounts """
cmp_select = []
company_ids = self.pool.get('res.company').search(cr, uid, [], context=context)
- #display in the widget selection of companies, only the companies that haven't been configured yet (but don't care about the demo chart of accounts)
cr.execute("SELECT company_id FROM account_account WHERE active = 't' AND account_account.parent_id IS NULL AND name != %s", ("Chart For Automated Tests",))
configured_cmp = [r[0] for r in cr.fetchall()]
- unconfigured_cmp = list(set(company_ids)-set(configured_cmp))
+ return list(set(company_ids)-set(configured_cmp))
+
+ def check_unconfigured_cmp(self, cr, uid, context=None):
+ """ check if there are still unconfigured companies """
+ if not self.get_unconfigured_cmp(cr, uid, context=context):
+ raise osv.except_osv(_('No unconfigured company !'), _("There are currently no company without chart of account. The wizard will therefore not be executed."))
+
+ def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
+ res = super(account_installer, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
+ cmp_select = []
+ # display in the widget selection only the companies that haven't been configured yet
+ unconfigured_cmp = self.get_unconfigured_cmp(cr, uid, context=context)
for field in res['fields']:
if field == 'company_id':
res['fields'][field]['domain'] = [('id','in',unconfigured_cmp)]
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp