[FIX] sale: in config wizard, do not assume the 'service' product hasn't been deleted...
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Fri, 11 Jan 2013 13:25:31 +0000 (14:25 +0100)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Fri, 11 Jan 2013 13:25:31 +0000 (14:25 +0100)
bzr revid: qdp-launchpad@openerp.com-20130111132531-z7rapvvuk2kaqw8a

addons/sale/res_config.py

index f87841e..44733be 100644 (file)
@@ -98,13 +98,20 @@ Example: Product: this product is deprecated, do not purchase more than 5.
         wizard = self.browse(cr, uid, ids)[0]
 
         if wizard.time_unit:
-            product = ir_model_data.get_object(cr, uid, 'product', 'product_product_consultant')
-            product.write({'uom_id': wizard.time_unit.id, 'uom_po_id': wizard.time_unit.id})
+            product = False
+            try:
+                product = ir_model_data.get_object(cr, uid, 'product', 'product_product_consultant')
+            except:
+                #product with xml_id product_product_consultant has not been found. Don't do anything except logging the exception
+                import logging
+                _logger = logging.getLogger(__name__)
+                _logger.warning("Warning, product with xml_id 'product_product_consultant' hasn't been found")
+            if product:
+                product.write({'uom_id': wizard.time_unit.id, 'uom_po_id': wizard.time_unit.id})
 
         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})
-         
         return {}
 
     def onchange_task_work(self, cr, uid, ids, task_work, context=None):