[IMP] Better demo data + property comment + recheck

[IMP] Recheck should be type object and procure_method read only when not in draft

[FIX] Inversion of moves in the correct way and assigning production_id

As the moves are split the other way, the original move needs to be done.  Also the production_id for linking the
new to be produced moves and the production order must be written on those.

[IMP] Clean
This commit is contained in:
Josse Colpaert 2014-09-29 11:13:44 +02:00
parent 68c8d90221
commit 661a204eda
4 changed files with 14 additions and 18 deletions

View File

@ -220,11 +220,13 @@ class mrp_bom(osv.osv):
domain = domain + [ '|', ('date_start', '=', False), ('date_start', '<=', time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)),
'|', ('date_stop', '=', False), ('date_stop', '>=', time.strftime(DEFAULT_SERVER_DATETIME_FORMAT))]
# order to prioritize bom with product_id over the one without
ids = self.search(cr, uid, domain, order='product_id')
ids = self.search(cr, uid, domain, order='product_id', context=context)
# Search a BoM which has all properties specified, or if you can not find one, you could
# pass a BoM without any properties
bom_empty_prop = False
for bom in self.pool.get('mrp.bom').browse(cr, uid, ids):
for bom in self.pool.get('mrp.bom').browse(cr, uid, ids, context=context):
if not set(map(int, bom.property_ids or [])) - set(properties or []):
if not bom.property_ids:
if properties and not bom.property_ids:
bom_empty_prop = bom.id
else:
return bom.id
@ -827,7 +829,6 @@ class mrp_production(osv.osv):
scheduled_qty[scheduled.product_id.id] = qty
dicts = {}
# Find product qty to be consumed and consume it
quants_taken = []
for product_id in scheduled_qty.keys():
consumed_qty = consumed_data.get(product_id, 0.0)
@ -909,9 +910,7 @@ class mrp_production(osv.osv):
produced_products[produced_product.product_id.id] += produced_product.product_qty
for produce_product in production.move_created_ids:
produced_qty = produced_products.get(produce_product.product_id.id, 0)
subproduct_factor = self._get_subproduct_factor(cr, uid, production.id, produce_product.id, context=context)
rest_qty = (subproduct_factor * production.product_qty) - produced_qty
lot_id = False
if wiz:
lot_id = wiz.lot_id.id

View File

@ -451,7 +451,7 @@
<field name="product_tmpl_id" ref="product.product_product_3_product_template"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="sequence">5</field>
<field name="type">phantom</field>
<field name="type">normal</field>
</record>
<record id="mrp_bom_line_17" model="mrp.bom.line">

View File

@ -157,13 +157,12 @@ class StockMove(osv.osv):
@param restrict_lot_id: optionnal parameter that allows to restrict the choice of quants on this specific lot
@param restrict_partner_id: optionnal parameter that allows to restrict the choice of quants to this specific partner
@param consumed_for: optionnal parameter given to this function to make the link between raw material consumed and produced product, for a better traceability
@return: Consumed lines
@return: New lines created if not everything was consumed for this line
"""
if context is None:
context = {}
res = []
production_obj = self.pool.get('mrp.production')
uom_obj = self.pool.get('product.uom')
if product_qty <= 0:
raise osv.except_osv(_('Warning!'), _('Please provide proper quantity.'))
@ -175,7 +174,6 @@ class StockMove(osv.osv):
else:
ids2.append(move.id)
toassign_move_ids = []
prod_orders = set()
for move in self.browse(cr, uid, ids2, context=context):
prod_orders.add(move.raw_material_production_id.id or move.production_id.id)
@ -185,18 +183,17 @@ class StockMove(osv.osv):
quantity_rest = move_qty - product_qty
if quantity_rest > 0:
new_mov = self.split(cr, uid, move, quantity_rest, context=context)
if move.location_id.usage == 'internal':
toassign_move_ids.append(new_mov)
res.append(move.id)
res.append(new_mov)
vals = {'restrict_lot_id': restrict_lot_id,
'restrict_partner_id': restrict_partner_id,
'consumed_for': consumed_for}
if location_id:
vals.update({'location_id': location_id})
self.write(cr, uid, [move.id], vals, context=context)
self.action_done(cr, uid, res, context=context)
if toassign_move_ids:
self.action_assign(cr, uid, toassign_move_ids, context=context)
# Original moves will be the quantities consumed, so they need to be done
self.action_done(cr, uid, ids2, context=context)
if res:
self.action_assign(cr, uid, res, context=context)
if prod_orders:
production_obj.signal_workflow(cr, uid, list(prod_orders), 'button_produce')
return res

View File

@ -646,7 +646,7 @@
<header>
<button name="action_confirm" states="draft" string="Mark as Todo" type="object" class="oe_highlight" groups="base.group_user"/>
<button name="action_assign" states="confirmed" string="Check Availability" type="object" class="oe_highlight" groups="base.group_user"/>
<button name="rereserve_pick" states="partially_available" string="Recheck Availability" class="oe_highlight" groups="base.group_user"/>
<button name="rereserve_pick" states="partially_available" string="Recheck Availability" type="object" class="oe_highlight" groups="base.group_user"/>
<button name="force_assign" states="confirmed,waiting,partially_available" string="Force Availability" type="object" groups="base.group_user"/>
<button name="do_enter_transfer_details" states="assigned,partially_available" string="Transfer" groups="stock.group_stock_user" type="object" class="oe_highlight"/>
<button name="do_print_picking" string="Print Picking List" groups="stock.group_stock_user" type="object" attrs="{'invisible': ['|', ('picking_type_code', '=', 'outgoing'), ('state', '!=', 'assigned')]}"/>
@ -1066,7 +1066,7 @@
<group>
<group>
<field name="product_id" on_change="onchange_product_id(product_id,location_id,location_dest_id, parent.partner_id)"/>
<field name="procure_method" groups="stock.group_adv_location"/>
<field name="procure_method" attrs="{'readonly': [('state', '!=', 'draft')]}" groups="stock.group_adv_location"/>
<field name="picking_type_id" invisible="1"/>
<label for="product_uom_qty"/>
<div>