From 7f7595bba73d7face2fab81172131adfdc631753 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Tue, 24 Jul 2012 11:40:51 +0530 Subject: [PATCH] [IMP]project_mrp,analytic_contract_project :Fix the problem for creating SO with service type product bzr revid: cha@tinyerp.com-20120724061051-5ojujboykewg0wwy --- .../analytic_contract_project.py | 3 ++- addons/project_mrp/project_procurement.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/analytic_contract_project/analytic_contract_project.py b/addons/analytic_contract_project/analytic_contract_project.py index 6221617637e..1ffab1246c9 100644 --- a/addons/analytic_contract_project/analytic_contract_project.py +++ b/addons/analytic_contract_project/analytic_contract_project.py @@ -78,6 +78,7 @@ class task(osv.osv): def create(self, cr, uid, vals, context=None): task_id = super(task, self).create(cr, uid, vals, context=context) task_browse = self.browse(cr, uid, task_id, context=context) - self.pool.get('account.analytic.account').message_append_note(cr, uid, [task_browse.project_id.analytic_account_id.id], body=_("Task %s has been created.") % (task_browse.name), context=context) + if task_browse.project_id.analytic_account_id: + self.pool.get('account.analytic.account').message_append_note(cr, uid, [task_browse.project_id.analytic_account_id.id], body=_("Task %s has been created.") % (task_browse.name), context=context) return task_id task() diff --git a/addons/project_mrp/project_procurement.py b/addons/project_mrp/project_procurement.py index 9252e3bbd11..299a74f52aa 100644 --- a/addons/project_mrp/project_procurement.py +++ b/addons/project_mrp/project_procurement.py @@ -45,9 +45,9 @@ class procurement_order(osv.osv): def _convert_qty_company_hours(self, cr, uid, procurement, context=None): product_uom = self.pool.get('product.uom') - company_time_uom_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.project_time_mode_id.id - if procurement.product_uom.id != company_time_uom_id: - planned_hours = product_uom._compute_qty(cr, uid, procurement.product_uom.id, procurement.product_qty, company_time_uom_id) + company_time_uom_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.project_time_mode_id + if procurement.product_uom.id != company_time_uom_id.id and procurement.product_uom.category_id.id == company_time_uom_id.category_id.id: + planned_hours = product_uom._compute_qty(cr, uid, procurement.product_uom.id, procurement.product_qty, company_time_uom_id.id) else: planned_hours = procurement.product_qty return planned_hours @@ -71,7 +71,7 @@ class procurement_order(osv.osv): task_id = project_task.create(cr, uid, { 'name': '%s:%s' % (procurement.origin or '', procurement.product_id.name), 'date_deadline': procurement.date_planned, - 'planned_hours':planned_hours, + 'planned_hours': planned_hours, 'remaining_hours': planned_hours, 'user_id': procurement.product_id.product_manager.id, 'notes': procurement.note,