From 5766fec0bc5fe605aed70d1a6967354f06cd1975 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 3 Apr 2012 16:39:13 +0200 Subject: [PATCH] [FIX] sale.config.wizard: set field Project Time Unit on company when module project is installed bzr revid: rco@openerp.com-20120403143913-0kazuyvc45zyyc5v --- addons/sale/res_config.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/sale/res_config.py b/addons/sale/res_config.py index 19c829d0c39..95590f8f0c6 100644 --- a/addons/sale/res_config.py +++ b/addons/sale/res_config.py @@ -92,6 +92,7 @@ class sale_configuration(osv.osv_memory): This installs the module analytic_journal_billing_rate."""), 'module_project_timesheet': fields.boolean("Project Timesheet"), 'module_project_mrp': fields.boolean("Project MRP"), + 'module_project': fields.boolean("Project"), } def default_get(self, cr, uid, fields, context=None): @@ -99,7 +100,10 @@ class sale_configuration(osv.osv_memory): res = super(sale_configuration, self).default_get(cr, uid, fields, context) # task_work, time_unit depend on other fields res['task_work'] = res.get('module_project_mrp') and res.get('module_project_timesheet') - if res.get('module_account_analytic_analysis'): + if res.get('module_project'): + user = self.pool.get('res.users').browse(cr, uid, uid, context) + res['time_unit'] = user.company_id.project_time_mode_id.id + else: product = ir_model_data.get_object(cr, uid, 'product', 'product_consultant') res['time_unit'] = product.uom_id.id return res @@ -132,7 +136,7 @@ class sale_configuration(osv.osv_memory): product = ir_model_data.get_object(cr, uid, 'product', 'product_consultant') product.write({'uom_id': wizard.time_unit.id, 'uom_po_id': wizard.time_unit.id}) - if wizard.task_work and wizard.time_unit: + if wizard.module_project and wizard.time_unit: user = self.pool.get('res.users').browse(cr, uid, uid, context) user.company_id.write({'project_time_mode_id': wizard.time_unit.id})