Jigar Amin  (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-821261-jam into 
lp:openobject-addons.

Requested reviews:
  Bhumika (OpenERP) (sbh-openerp)
Related bugs:
  Bug #821261 in OpenERP Addons: "Task from sale order - can invoice both"
  https://bugs.launchpad.net/openobject-addons/+bug/821261

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-821261-jam/+merge/71321

Changes :
  - Bug #821261 : "Task from sale order - can invoice both".
     - Issue 1 : "The analytic account from SO does not link as a project in 
task." has been fixed with this branch. 
Kindly Review This,
Thank You
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-821261-jam/+merge/71321
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-821261-jam.
=== modified file 'project_mrp/project_procurement.py'
--- project_mrp/project_procurement.py	2011-02-02 13:24:37 +0000
+++ project_mrp/project_procurement.py	2011-08-12 09:34:22 +0000
@@ -33,7 +33,18 @@
         return True
 
     def action_produce_assign_service(self, cr, uid, ids, context=None):
+        line_pool=self.pool.get('sale.order.line')
+        project_pool=self.pool.get('project.project')
         for procurement in self.browse(cr, uid, ids, context=context):
+            project_id = False
+            line_ids = line_pool.search(cr, uid , [('procurement_id', '=', procurement.id)])
+            order_lines = line_pool.browse(cr, uid, line_ids)
+            for line in order_lines:
+                if line.product_id and  line.product_id.project_id:            
+                    project_id = line.product_id.project_id.id
+                if not project_id and line.order_id.project_id:
+                    project_id = project_pool.search(cr, uid , [('name', '=', line.order_id.project_id.name)])
+                    project_id = project_id and project_id[0] or False
             self.write(cr, uid, [procurement.id], {'state': 'running'})
             planned_hours = procurement.product_qty
             task_id = self.pool.get('project.task').create(cr, uid, {
@@ -46,7 +57,7 @@
                 'procurement_id': procurement.id,
                 'description': procurement.note,
                 'date_deadline': procurement.date_planned,
-                'project_id': procurement.product_id.project_id and procurement.product_id.project_id.id or False,
+                'project_id':  project_id,
                 'state': 'draft',
                 'company_id': procurement.company_id.id,
             },context=context)

_______________________________________________
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

Reply via email to