[IMP] project_mrp: Add the user_id and project_id in product and add the task_id in procurement

bzr revid: sbh@tinyerp.com-20100708133342-105x6v60zwc26c98
This commit is contained in:
sbh (Open ERP) 2010-07-08 19:03:42 +05:30
parent f07518d0d3
commit dceac87f08
4 changed files with 50 additions and 4 deletions

View File

@ -51,6 +51,7 @@ automatically created via sale orders.
'init_xml': [],
'update_xml': ['project_mrp_workflow.xml',
#'process/project_mrp_process.xml',
'project_mrp_view.xml'
],
'demo_xml': [],
'test': ['test/project_task_procurement.yml'],

View File

@ -26,12 +26,16 @@ import tools
class procurement_order(osv.osv):
_name = "procurement.order"
_inherit = "procurement.order"
_columns = {
'task_id': fields.many2one('project.task', 'Task')
}
def action_produce_assign_service(self, cr, uid, ids, context=None):
if context is None:
context = {}
for procurement in self.browse(cr, uid, ids):
sline = self.pool.get('sale.order.line')
product_obj=self.pool.get('product.product')
content = ''
sale_order = self.pool.get('sale.order')
so_ref = procurement.name.split(':')[0]
@ -69,6 +73,7 @@ class procurement_order(osv.osv):
self.write(cr, uid, [procurement.id], {'state': 'running'})
name_task = ('','')
planned_hours=0.0
if procurement.product_id.type == 'service':
proc_name = procurement.name
if procurement.origin == proc_name:
@ -77,12 +82,12 @@ class procurement_order(osv.osv):
name_task = (procurement.origin, proc_name or '')
else:
name_task = (procurement.product_id.name or procurement.origin, procurement.name or '')
planned_hours= procurement.product_id.sale_delay +procurement.product_id. produce_delay
task_id = self.pool.get('project.task').create(cr, uid, {
'name': '%s:%s' % name_task,
'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': "b"+(l and l.order_id.note or ''),
'procurement_id': procurement.id,
@ -93,7 +98,8 @@ class procurement_order(osv.osv):
'company_id': procurement.company_id.id,
'project_id': project_id,
},context=context)
self.write(cr, uid, [procurement.id],{'task_id':task_id})
product_obj.write(cr,uid,[procurement.product_id.id],{'user_id':uid,'project_id':project_id})
return task_id
procurement_order()

View File

@ -48,5 +48,13 @@ class project_task(osv.osv):
return True
project_task()
class product_product(osv.osv):
_inherit = "product.product"
_columns = {
'user_id': fields.many2one('res.users', 'Responsible', ondelete='set null',help='Project Manager'),
'project_id': fields.many2one('project.project', 'Project', ondelete='set null',)
}
product_product()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_procurement_task_form" model="ir.ui.view">
<field name="name">procurement.procurement.form.view.inherit</field>
<field name="model">procurement.order</field>
<field name="type">form</field>
<field name="inherit_id" ref="procurement.procurement_form_view"/>
<field name="arch" type="xml">
<field name="close_move" position="after">
<field name="task_id"/>
</field>
</field>
</record>
<record id="view_product_task_form" model="ir.ui.view">
<field name="name">product.form.view.inherit</field>
<field name="model">product.product</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="user_id" attrs="{'readonly':[('type','!=','service')]}"/>
<field name="project_id" attrs="{'readonly':[('type','!=','service')]}" />
</field>
</field>
</record>
</data>
</openerp>