[WIP] Change workflow of mrp and add field ready_production which checks if the raw material moves to consume are assigned, change prepare_order_line_procurement with correct params
bzr revid: jco@openerp.com-20130813142344-c6n7awvjj796iliu
This commit is contained in:
+21
-1
@@ -452,6 +452,25 @@ class mrp_production(osv.osv):
|
||||
result[mrp_production.id] = done / mrp_production.product_qty * 100
|
||||
return result
|
||||
|
||||
def _moves_assigned(self, cr, uid, ids, name, arg, context=None):
|
||||
""" Test whether all the consume lines are assigned """
|
||||
res = True
|
||||
for production in self.browse(cr, uid, ids, context=context):
|
||||
states = [x.state != 'assigned' for x in production.move_lines if x]
|
||||
if any(states) or len(states) == 0:
|
||||
return False
|
||||
return res
|
||||
|
||||
|
||||
def _mrp_from_move(self, cr, uid, ids, context=None):
|
||||
""" Return mrp"""
|
||||
res = []
|
||||
for move in self.browse(cr, uid, ids, context=context):
|
||||
res += self.pool.get("mrp.production").search(cr, uid, [('move_lines', 'in', move.id)], context=context)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Reference', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'origin': fields.char('Source Document', size=64, readonly=True, states={'draft': [('readonly', False)]},
|
||||
@@ -510,6 +529,8 @@ class mrp_production(osv.osv):
|
||||
'cycle_total': fields.function(_production_calc, type='float', string='Total Cycles', multi='workorder', store=True),
|
||||
'user_id':fields.many2one('res.users', 'Responsible'),
|
||||
'company_id': fields.many2one('res.company','Company',required=True),
|
||||
'ready_production': fields.function(_moves_assigned, type='boolean', store={'stock.move': (_mrp_from_move, ['state'], 10)}),
|
||||
|
||||
}
|
||||
_defaults = {
|
||||
'priority': lambda *a: '1',
|
||||
@@ -554,7 +575,6 @@ class mrp_production(osv.osv):
|
||||
'move_created_ids2' : [],
|
||||
'product_lines' : [],
|
||||
'move_prod_id' : False,
|
||||
'picking_id' : False
|
||||
})
|
||||
return super(mrp_production, self).copy(cr, uid, id, default, context)
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<field name="wkf_id" ref="wkf_prod"/>
|
||||
<field name="flow_stop">True</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">action_production_end()</field>
|
||||
<field name="action">action_production_end()</field>
|
||||
<field name="name">done</field>
|
||||
</record>
|
||||
<record id="prod_act_cancel" model="workflow.activity">
|
||||
@@ -70,7 +70,7 @@
|
||||
<field name="act_from" ref="prod_act_picking"/>
|
||||
<field name="act_to" ref="prod_act_ready"/>
|
||||
<field name="signal"></field>
|
||||
<field name="condition">picking_id and picking_id.state=='done'</field>
|
||||
<field name="condition">ready_production</field>
|
||||
</record>
|
||||
<record id="prod_trans_ready_in_production" model="workflow.transition">
|
||||
<field name="act_from" ref="prod_act_ready"/>
|
||||
|
||||
@@ -123,9 +123,9 @@ class product_product(osv.osv):
|
||||
class sale_order(osv.osv):
|
||||
_inherit = 'sale.order'
|
||||
|
||||
def _prepare_order_line_procurement(self, cr, uid, order, line, move_id, date_planned, context=None):
|
||||
def _prepare_order_line_procurement(self, cr, uid, order, line, group_id=False, context=None):
|
||||
proc_data = super(sale_order, self)._prepare_order_line_procurement(cr,
|
||||
uid, order, line, move_id, date_planned, context=context)
|
||||
uid, order, line, group_id = group_id, context=context)
|
||||
proc_data['sale_line_id'] = line.id
|
||||
return proc_data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user