From 58ffb0e3f8a2e1594e9e02bff4142c49fad8084e Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Mon, 16 Jul 2012 12:16:57 +0530 Subject: [PATCH 1/3] [IMP]project_mrp: removed the issue of specific UOM from sale order to task flow bzr revid: mma@tinyerp.com-20120716064657-7jvtzranbb677bnh --- addons/project_mrp/project_procurement.py | 14 ++------------ .../project_mrp/test/project_task_procurement.yml | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/addons/project_mrp/project_procurement.py b/addons/project_mrp/project_procurement.py index 9252e3bbd11..7f90c3fdab9 100644 --- a/addons/project_mrp/project_procurement.py +++ b/addons/project_mrp/project_procurement.py @@ -43,15 +43,6 @@ class procurement_order(osv.osv): def check_produce_service(self, cr, uid, procurement, context=None): return True - 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) - else: - planned_hours = procurement.product_qty - return planned_hours - def _get_project(self, cr, uid, procurement, context=None): project_project = self.pool.get('project.project') project = procurement.product_id.project_id @@ -67,12 +58,11 @@ class procurement_order(osv.osv): project_task = self.pool.get('project.task') for procurement in self.browse(cr, uid, ids, context=context): project = self._get_project(cr, uid, procurement, context=context) - planned_hours = self._convert_qty_company_hours(cr, uid, procurement, context=context) 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, - 'remaining_hours': planned_hours, + 'planned_hours': procurement.product_qty, + 'remaining_hours': procurement.product_qty, 'user_id': procurement.product_id.product_manager.id, 'notes': procurement.note, 'procurement_id': procurement.id, diff --git a/addons/project_mrp/test/project_task_procurement.yml b/addons/project_mrp/test/project_task_procurement.yml index b72527e61a5..1b593fe97e1 100644 --- a/addons/project_mrp/test/project_task_procurement.yml +++ b/addons/project_mrp/test/project_task_procurement.yml @@ -25,7 +25,7 @@ elif procurement.sale_line_id: account = procurement.sale_line_id.order_id.project_id assert (not project and not account) or project.analytic_account_id == account, "Project does not correspond." - planned_hours = self._convert_qty_company_hours(cr, uid, procurement, context=context) + planned_hours = procurement.product_qty assert task.planned_hours == planned_hours, 'Planned Hours do not correspond.' assert datetime.strptime(task.date_deadline, '%Y-%m-%d') == datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S'), 'Deadline does not correspond.' if procurement.product_id.product_manager: From 976593a4007ae12789b5fa5734b747a88f067115 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Mon, 16 Jul 2012 14:49:03 +0530 Subject: [PATCH 2/3] [IMP]analytic_contract_project: improve create method in analytic to fix the issue of making a sale order to task of service product bzr revid: mma@tinyerp.com-20120716091903-rwhx3w7te9rdvrfv --- addons/analytic_contract_project/analytic_contract_project.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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() From 6be29d4ec29d00aebd0d58d015f0cb360a22bd3a Mon Sep 17 00:00:00 2001 From: "Purnendu Singh (OpenERP)" Date: Thu, 19 Jul 2012 18:38:29 +0530 Subject: [PATCH 3/3] [IMP] project_mrp: Revert my changes and add the _convert_qty_company_hours method again and improve that bzr revid: psi@tinyerp.com-20120719130829-ev8rppz2qz0k6tf0 --- addons/project_mrp/project_procurement.py | 14 ++++++++++++-- .../project_mrp/test/project_task_procurement.yml | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/addons/project_mrp/project_procurement.py b/addons/project_mrp/project_procurement.py index 7f90c3fdab9..299a74f52aa 100644 --- a/addons/project_mrp/project_procurement.py +++ b/addons/project_mrp/project_procurement.py @@ -43,6 +43,15 @@ class procurement_order(osv.osv): def check_produce_service(self, cr, uid, procurement, context=None): return True + 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 + 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 + def _get_project(self, cr, uid, procurement, context=None): project_project = self.pool.get('project.project') project = procurement.product_id.project_id @@ -58,11 +67,12 @@ class procurement_order(osv.osv): project_task = self.pool.get('project.task') for procurement in self.browse(cr, uid, ids, context=context): project = self._get_project(cr, uid, procurement, context=context) + planned_hours = self._convert_qty_company_hours(cr, uid, procurement, context=context) task_id = project_task.create(cr, uid, { 'name': '%s:%s' % (procurement.origin or '', procurement.product_id.name), 'date_deadline': procurement.date_planned, - 'planned_hours': procurement.product_qty, - 'remaining_hours': procurement.product_qty, + 'planned_hours': planned_hours, + 'remaining_hours': planned_hours, 'user_id': procurement.product_id.product_manager.id, 'notes': procurement.note, 'procurement_id': procurement.id, diff --git a/addons/project_mrp/test/project_task_procurement.yml b/addons/project_mrp/test/project_task_procurement.yml index 1b593fe97e1..b72527e61a5 100644 --- a/addons/project_mrp/test/project_task_procurement.yml +++ b/addons/project_mrp/test/project_task_procurement.yml @@ -25,7 +25,7 @@ elif procurement.sale_line_id: account = procurement.sale_line_id.order_id.project_id assert (not project and not account) or project.analytic_account_id == account, "Project does not correspond." - planned_hours = procurement.product_qty + planned_hours = self._convert_qty_company_hours(cr, uid, procurement, context=context) assert task.planned_hours == planned_hours, 'Planned Hours do not correspond.' assert datetime.strptime(task.date_deadline, '%Y-%m-%d') == datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S'), 'Deadline does not correspond.' if procurement.product_id.product_manager: