for production in self.browse(cr, uid, ids, context=context):
res[production.id] = True
states = [x.state != 'assigned' for x in production.move_lines if x]
- if any(states) or len(states) == 0:
+ if any(states) or len(states) == 0: #When no moves, ready_production will be False, but test_ready will pass
res[production.id] = False
return res
dicts = {}
# Find product qty to be consumed and consume it
for scheduled in production.product_lines:
+ if scheduled.product_id.type == 'service':
+ continue
product_id = scheduled.product_id.id
consumed_qty = consumed_data.get(product_id, 0.0)
return res
def test_ready(self, cr, uid, ids):
- res = False
+ res = True
for production in self.browse(cr, uid, ids):
- if production.ready_production:
- res = True
+ if production.move_lines and not production.ready_production:
+ res = False
return res
+
def _make_production_produce_line(self, cr, uid, production, context=None):
stock_moves.append(stock_move_id)
if stock_moves:
self.pool.get('stock.move').action_confirm(cr, uid, stock_moves, context=context)
- else:
- raise osv.except_osv(_('Error!'),
- _('It does not make sense to create a production order without any physical product to consume'))
production.write({'state': 'confirmed'}, context=context)
return 0
"""
Checks the availability on the consume lines of the production order
"""
+ from openerp import workflow
move_obj = self.pool.get("stock.move")
for production in self.browse(cr, uid, ids, context=context):
move_obj.action_assign(cr, uid, [x.id for x in production.move_lines], context=context)
+ if self.pool.get('mrp.production').test_ready(cr, uid, [production.id]):
+ workflow.trg_validate(uid, 'mrp.production', production.id, 'moves_ready', cr)
def force_production(self, cr, uid, ids, *args):
@param *args: Arguments
@return: True
"""
+ from openerp import workflow
move_obj = self.pool.get('stock.move')
for order in self.browse(cr, uid, ids):
move_obj.force_assign(cr, uid, [x.id for x in order.move_lines])
+ if self.pool.get('mrp.production').test_ready(cr, uid, [order.id]):
+ workflow.trg_validate(uid, 'mrp.production', order.id, 'moves_ready', cr)
return True
<record id="prod_trans_picking_ready" model="workflow.transition">
<field name="act_from" ref="prod_act_confirmed"/>
<field name="act_to" ref="prod_act_ready"/>
- <field name="trigger_model">stock.move</field>
- <field name="trigger_expr_id">consume_lines_get()</field>
- <field name="condition">test_ready()</field>
+ <field name="signal">moves_ready</field>
</record>
<record id="prod_trans_ready_in_production" model="workflow.transition">
<field name="act_from" ref="prod_act_ready"/>
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.raw_material_production_id and move.raw_material_production_id.state == 'confirmed':
- workflow.trg_trigger(uid, 'stock.move', move.id, cr)
+ if vals.get('state') == 'assigned':
+ moves = self.browse(cr, uid, ids, context=context)
+ orders = list(set([x.raw_material_production_id.id for x in moves if x.raw_material_production_id and x.raw_material_production_id.state == 'confirmed']))
+ for order_id in orders:
+ if self.pool.get('mrp.production').test_ready(cr, uid, [order_id]):
+ workflow.trg_validate(uid, 'mrp.production', order_id, 'moves_ready', cr)
return res
class stock_warehouse(osv.osv):
<!-- -->
- <record id="product_product_5" model="product.product">
+ <record id="product_product_5b" model="product.product">
<field name="name">Bose Mini Bluetooth Speaker</field>
<field name="categ_id" ref="accessories"/>
- <field name="standard_price">600.0</field>
- <field name="list_price">147.0</field>
+ <field name="standard_price">140.0</field>
+ <field name="list_price">247.0</field>
<field name="type">consu</field>
<field name="uom_id" ref="product_uom_unit"/>
<field name="uom_po_id" ref="product_uom_unit"/>
</record>
+ <record id="product_product_5" model="product.product">
+ <field name="name">PC Assemble + Custom (PC on Demand) </field>
+ <field name="categ_id" ref="accessories"/>
+ <field name="standard_price">600.0</field>
+ <field name="list_price">147.0</field>
+ <field name="type">consu</field>
+ <field name="uom_id" ref="product_uom_unit"/>
+ <field name="uom_po_id" ref="product_uom_unit"/>
+ <field name="description">Custom computer assembled on order based on customer's requirement.</field>
+ <field name="default_code">B3423</field>
+ </record>
+
<record id="product_product_6" model="product.product">
<field name="name">iPad Mini</field>
<field name="categ_id" ref="ipad"/>
</record>
<record id="product_product_5" model="product.product">
+ <field name="image" type="base64" file="product/static/img/product_product_5-image.jpg"/>
+ </record>
+
+ <record id="product_product_5b" model="product.product">
<field name="image" type="base64" file="product/static/img/product_product_5-image.png"/>
</record>
<record id="product.product_product_4" model="product.product">
<field name="type">product</field>
-
</record>
+
<record id="product.product_product_5" model="product.product">
<field name="type">product</field>
</record>
+ <record id="product.product_product_5b" model="product.product">
+ <field name="type">product</field>
+ </record>
+
<record id="product.product_product_6" model="product.product">
<field name="type">product</field>
</record>
defaults = {
'product_uom_qty': uom_qty,
'product_uos_qty': uos_qty,
- 'state': move.state,
'procure_method': 'make_to_stock',
'restrict_lot_id': restrict_lot_id,
'restrict_partner_id': restrict_partner_id,
<field name="location_id" ref="stock_location_14"/>
</record>
<record id="stock_inventory_line_15" model="stock.inventory.line">
- <field name="product_id" ref="product.product_product_5"/>
+ <field name="product_id" ref="product.product_product_5b"/>
<field name="product_uom_id" ref="product.product_uom_unit"/>
<field name="inventory_id" ref="stock_inventory_0"/>
<field name="product_qty">8.0</field>
</field>
</record>
- <record id="product.product_product_5" model="product.product">
+ <record id="product.product_product_5b" model="product.product">
<field name="website_published" eval="True"/>
<field name="website_size_x">2</field>
<field name="website_style_ids" eval="[(6,0,[ref('website_sale.image_promo')])]"/>
<record id="product.product_product_4_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('product.Computer_all_in_one')])]"/>
</record>
- <record id="product.product_product_5_product_template" model="product.template">
+ <record id="product.product_product_5b_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('product.Speakers')])]"/>
</record>
<record id="product.product_product_6_product_template" model="product.template">