[FIX] mrp: workflow

bzr revid: qdp-launchpad@openerp.com-20130925083749-iafe0qoq2jqmvgk5
This commit is contained in:
Quentin (OpenERP) 2013-09-25 10:37:49 +02:00
parent a0941178b2
commit e503beb955
3 changed files with 10 additions and 29 deletions

View File

@ -502,9 +502,9 @@ class mrp_production(osv.osv):
'picking_id': fields.many2one('stock.picking', 'Picking List', readonly=True, ondelete="restrict",
help="This is the Internal Picking List that brings the finished product to the production plan"),
'move_prod_id': fields.many2one('stock.move', 'Product Move', readonly=True),
'move_lines': fields.many2many('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Products to Consume',
'move_lines': fields.one2many('stock.move', 'raw_material_production_id', 'Products to Consume',
domain=[('state','not in', ('done', 'cancel'))], readonly=True, states={'draft':[('readonly',False)]}),
'move_lines2': fields.many2many('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Consumed Products',
'move_lines2': fields.one2many('stock.move', 'raw_material_production_id', 'Consumed Products',
domain=[('state','in', ('done', 'cancel'))], readonly=True, states={'draft':[('readonly',False)]}),
'move_created_ids': fields.one2many('stock.move', 'production_id', 'Products to Produce',
domain=[('state','not in', ('done', 'cancel'))], readonly=True, states={'draft':[('readonly',False)]}),
@ -886,37 +886,17 @@ class mrp_production(osv.osv):
"""
return self.write(cr, uid, ids, {'state': 'in_production', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S')})
def test_if_product(self, cr, uid, ids):
"""
@return: True or False
"""
res = True
for production in self.browse(cr, uid, ids):
if not production.product_lines:
if not self.action_compute(cr, uid, [production.id]):
res = False
return res
def consume_lines_get(self, cr, uid, ids, *args):
res = []
for order in self.browse(cr, uid, ids, context={}):
res += [x.id for x in order.move_lines]
return res
def test_ready2(self, cr, uid, ids):
res = True
assign = self._moves_assigned(cr, uid, ids, False, False)
for production in ids:
if not assign[production]:
res = False
return res
def test_ready(self, cr, uid, ids):
res = True
res = False
for production in self.browse(cr, uid, ids):
if not production.ready_production:
res = False
if production.ready_production:
res = True
return res
def _make_production_produce_line(self, cr, uid, production, context=None):

View File

@ -17,6 +17,7 @@
<record id="prod_act_confirmed" model="workflow.activity">
<field name="wkf_id" ref="wkf_prod"/>
<field name="name">confirmed</field>
<field name="kind">function</field>
<field name="action">action_confirm()</field>
</record>
<record id="prod_act_ready" model="workflow.activity">

View File

@ -27,7 +27,8 @@ class StockMove(osv.osv):
_inherit = 'stock.move'
_columns = {
'production_id': fields.many2one('mrp.production', 'Production', select=True),
'production_id': fields.many2one('mrp.production', 'Production Order for Produced Products', select=True),
'raw_material_production_id': fields.many2one('mrp.production', 'Production Order for Raw Materials', select=True),
}
@ -137,15 +138,14 @@ class StockMove(osv.osv):
res.append(new_move)
return res
def write(self, cr, uid, ids, vals, context=None):
if isinstance(ids, (int, long)):
ids = [ids]
res = super(StockMove, self).write(cr, uid, ids, vals, context=context)
from openerp import workflow
for move in self.browse(cr, uid, ids, context=context):
if move.production_id and move.production_id.state == 'confirmed':
workflow.trg_trigger(uid, 'stock.move', move.production_id.id, cr)
if move.raw_material_production_id and move.raw_material_production_id.state == 'confirmed':
workflow.trg_trigger(uid, 'stock.move', move.id, cr)
return res
class StockPicking(osv.osv):