[IMP] Adapt mrp workflow and moves + Differ between Bose speakers and Custom Computer
This commit is contained in:
parent
655570fe23
commit
9b34358196
|
@ -509,7 +509,7 @@ class mrp_production(osv.osv):
|
||||||
for production in self.browse(cr, uid, ids, context=context):
|
for production in self.browse(cr, uid, ids, context=context):
|
||||||
res[production.id] = True
|
res[production.id] = True
|
||||||
states = [x.state != 'assigned' for x in production.move_lines if x]
|
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
|
res[production.id] = False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -831,6 +831,8 @@ class mrp_production(osv.osv):
|
||||||
dicts = {}
|
dicts = {}
|
||||||
# Find product qty to be consumed and consume it
|
# Find product qty to be consumed and consume it
|
||||||
for scheduled in production.product_lines:
|
for scheduled in production.product_lines:
|
||||||
|
if scheduled.product_id.type == 'service':
|
||||||
|
continue
|
||||||
product_id = scheduled.product_id.id
|
product_id = scheduled.product_id.id
|
||||||
|
|
||||||
consumed_qty = consumed_data.get(product_id, 0.0)
|
consumed_qty = consumed_data.get(product_id, 0.0)
|
||||||
|
@ -1018,11 +1020,12 @@ class mrp_production(osv.osv):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def test_ready(self, cr, uid, ids):
|
def test_ready(self, cr, uid, ids):
|
||||||
res = False
|
res = True
|
||||||
for production in self.browse(cr, uid, ids):
|
for production in self.browse(cr, uid, ids):
|
||||||
if production.ready_production:
|
if production.move_lines and not production.ready_production:
|
||||||
res = True
|
res = False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _make_production_produce_line(self, cr, uid, production, context=None):
|
def _make_production_produce_line(self, cr, uid, production, context=None):
|
||||||
|
@ -1155,9 +1158,6 @@ class mrp_production(osv.osv):
|
||||||
stock_moves.append(stock_move_id)
|
stock_moves.append(stock_move_id)
|
||||||
if stock_moves:
|
if stock_moves:
|
||||||
self.pool.get('stock.move').action_confirm(cr, uid, stock_moves, context=context)
|
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)
|
production.write({'state': 'confirmed'}, context=context)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -1165,9 +1165,12 @@ class mrp_production(osv.osv):
|
||||||
"""
|
"""
|
||||||
Checks the availability on the consume lines of the production order
|
Checks the availability on the consume lines of the production order
|
||||||
"""
|
"""
|
||||||
|
from openerp import workflow
|
||||||
move_obj = self.pool.get("stock.move")
|
move_obj = self.pool.get("stock.move")
|
||||||
for production in self.browse(cr, uid, ids, context=context):
|
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)
|
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):
|
def force_production(self, cr, uid, ids, *args):
|
||||||
|
@ -1175,9 +1178,12 @@ class mrp_production(osv.osv):
|
||||||
@param *args: Arguments
|
@param *args: Arguments
|
||||||
@return: True
|
@return: True
|
||||||
"""
|
"""
|
||||||
|
from openerp import workflow
|
||||||
move_obj = self.pool.get('stock.move')
|
move_obj = self.pool.get('stock.move')
|
||||||
for order in self.browse(cr, uid, ids):
|
for order in self.browse(cr, uid, ids):
|
||||||
move_obj.force_assign(cr, uid, [x.id for x in order.move_lines])
|
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
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,9 +56,7 @@
|
||||||
<record id="prod_trans_picking_ready" model="workflow.transition">
|
<record id="prod_trans_picking_ready" model="workflow.transition">
|
||||||
<field name="act_from" ref="prod_act_confirmed"/>
|
<field name="act_from" ref="prod_act_confirmed"/>
|
||||||
<field name="act_to" ref="prod_act_ready"/>
|
<field name="act_to" ref="prod_act_ready"/>
|
||||||
<field name="trigger_model">stock.move</field>
|
<field name="signal">moves_ready</field>
|
||||||
<field name="trigger_expr_id">consume_lines_get()</field>
|
|
||||||
<field name="condition">test_ready()</field>
|
|
||||||
</record>
|
</record>
|
||||||
<record id="prod_trans_ready_in_production" model="workflow.transition">
|
<record id="prod_trans_ready_in_production" model="workflow.transition">
|
||||||
<field name="act_from" ref="prod_act_ready"/>
|
<field name="act_from" ref="prod_act_ready"/>
|
||||||
|
|
|
@ -228,9 +228,12 @@ class StockMove(osv.osv):
|
||||||
ids = [ids]
|
ids = [ids]
|
||||||
res = super(StockMove, self).write(cr, uid, ids, vals, context=context)
|
res = super(StockMove, self).write(cr, uid, ids, vals, context=context)
|
||||||
from openerp import workflow
|
from openerp import workflow
|
||||||
for move in self.browse(cr, uid, ids, context=context):
|
if vals.get('state') == 'assigned':
|
||||||
if move.raw_material_production_id and move.raw_material_production_id.state == 'confirmed':
|
moves = self.browse(cr, uid, ids, context=context)
|
||||||
workflow.trg_trigger(uid, 'stock.move', move.id, cr)
|
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
|
return res
|
||||||
|
|
||||||
class stock_warehouse(osv.osv):
|
class stock_warehouse(osv.osv):
|
||||||
|
|
|
@ -225,11 +225,11 @@ FaceTime HD Camera, 1.2 MP Photos</field>
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
|
||||||
<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="name">Bose Mini Bluetooth Speaker</field>
|
||||||
<field name="categ_id" ref="accessories"/>
|
<field name="categ_id" ref="accessories"/>
|
||||||
<field name="standard_price">600.0</field>
|
<field name="standard_price">140.0</field>
|
||||||
<field name="list_price">147.0</field>
|
<field name="list_price">247.0</field>
|
||||||
<field name="type">consu</field>
|
<field name="type">consu</field>
|
||||||
<field name="uom_id" ref="product_uom_unit"/>
|
<field name="uom_id" ref="product_uom_unit"/>
|
||||||
<field name="uom_po_id" ref="product_uom_unit"/>
|
<field name="uom_po_id" ref="product_uom_unit"/>
|
||||||
|
@ -239,6 +239,18 @@ FaceTime HD Camera, 1.2 MP Photos</field>
|
||||||
</record>
|
</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">
|
<record id="product_product_6" model="product.product">
|
||||||
<field name="name">iPad Mini</field>
|
<field name="name">iPad Mini</field>
|
||||||
<field name="categ_id" ref="ipad"/>
|
<field name="categ_id" ref="ipad"/>
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="product_product_5" model="product.product">
|
<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"/>
|
<field name="image" type="base64" file="product/static/img/product_product_5-image.png"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,16 @@
|
||||||
|
|
||||||
<record id="product.product_product_4" model="product.product">
|
<record id="product.product_product_4" model="product.product">
|
||||||
<field name="type">product</field>
|
<field name="type">product</field>
|
||||||
|
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="product.product_product_5" model="product.product">
|
<record id="product.product_product_5" model="product.product">
|
||||||
<field name="type">product</field>
|
<field name="type">product</field>
|
||||||
</record>
|
</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">
|
<record id="product.product_product_6" model="product.product">
|
||||||
<field name="type">product</field>
|
<field name="type">product</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
@ -2395,7 +2395,6 @@ class stock_move(osv.osv):
|
||||||
defaults = {
|
defaults = {
|
||||||
'product_uom_qty': uom_qty,
|
'product_uom_qty': uom_qty,
|
||||||
'product_uos_qty': uos_qty,
|
'product_uos_qty': uos_qty,
|
||||||
'state': move.state,
|
|
||||||
'procure_method': 'make_to_stock',
|
'procure_method': 'make_to_stock',
|
||||||
'restrict_lot_id': restrict_lot_id,
|
'restrict_lot_id': restrict_lot_id,
|
||||||
'restrict_partner_id': restrict_partner_id,
|
'restrict_partner_id': restrict_partner_id,
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
<field name="location_id" ref="stock_location_14"/>
|
<field name="location_id" ref="stock_location_14"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="stock_inventory_line_15" model="stock.inventory.line">
|
<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="product_uom_id" ref="product.product_uom_unit"/>
|
||||||
<field name="inventory_id" ref="stock_inventory_0"/>
|
<field name="inventory_id" ref="stock_inventory_0"/>
|
||||||
<field name="product_qty">8.0</field>
|
<field name="product_qty">8.0</field>
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</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_published" eval="True"/>
|
||||||
<field name="website_size_x">2</field>
|
<field name="website_size_x">2</field>
|
||||||
<field name="website_style_ids" eval="[(6,0,[ref('website_sale.image_promo')])]"/>
|
<field name="website_style_ids" eval="[(6,0,[ref('website_sale.image_promo')])]"/>
|
||||||
|
@ -688,7 +688,7 @@ Weight: 1.1 ounces</field>
|
||||||
<record id="product.product_product_4_product_template" model="product.template">
|
<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')])]"/>
|
<field name="public_categ_ids" eval="[(6,0,[ref('product.Computer_all_in_one')])]"/>
|
||||||
</record>
|
</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')])]"/>
|
<field name="public_categ_ids" eval="[(6,0,[ref('product.Speakers')])]"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="product.product_product_6_product_template" model="product.template">
|
<record id="product.product_product_6_product_template" model="product.template">
|
||||||
|
|
Loading…
Reference in New Issue