[IMP] Put cost method only once, make sure extra moves get moves in consequent pickings, default buy route on template
This commit is contained in:
parent
ea69325466
commit
9376d16938
|
@ -64,7 +64,7 @@ class procurement_group(osv.osv):
|
|||
}
|
||||
_defaults = {
|
||||
'name': lambda self, cr, uid, c: self.pool.get('ir.sequence').get(cr, uid, 'procurement.group') or '',
|
||||
'move_type': lambda self, cr, uid, c: 'one'
|
||||
'move_type': lambda self, cr, uid, c: 'direct'
|
||||
}
|
||||
|
||||
class procurement_rule(osv.osv):
|
||||
|
|
|
@ -1358,6 +1358,10 @@ class product_template(osv.Model):
|
|||
_name = 'product.template'
|
||||
_inherit = 'product.template'
|
||||
|
||||
def _get_buy_route(self, cr, uid, context=None):
|
||||
buy_route = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'purchase', 'route_warehouse0_buy')[1]
|
||||
return [buy_route]
|
||||
|
||||
def _purchase_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict.fromkeys(ids, 0)
|
||||
for template in self.browse(cr, uid, ids, context=context):
|
||||
|
@ -1369,6 +1373,7 @@ class product_template(osv.Model):
|
|||
}
|
||||
_defaults = {
|
||||
'purchase_ok': 1,
|
||||
'route_ids': _get_buy_route,
|
||||
}
|
||||
|
||||
class product_product(osv.Model):
|
||||
|
@ -1446,15 +1451,9 @@ class account_invoice_line(osv.Model):
|
|||
readonly=True),
|
||||
}
|
||||
|
||||
class product_product(osv.osv):
|
||||
_inherit = "product.product"
|
||||
class product_template(osv.osv):
|
||||
_inherit = "product.template"
|
||||
|
||||
def _get_buy_route(self, cr, uid, context=None):
|
||||
buy_route = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'purchase', 'route_warehouse0_buy')[1]
|
||||
return [buy_route]
|
||||
|
||||
_defaults = {
|
||||
'route_ids': _get_buy_route,
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -1248,6 +1248,7 @@ class stock_picking(osv.osv):
|
|||
'''
|
||||
move_obj = self.pool.get('stock.move')
|
||||
operation_obj = self.pool.get('stock.pack.operation')
|
||||
moves = []
|
||||
for op in picking.pack_operation_ids:
|
||||
for product_id, remaining_qty in operation_obj._get_remaining_prod_quantities(cr, uid, op, context=context).items():
|
||||
if remaining_qty > 0:
|
||||
|
@ -1260,9 +1261,12 @@ class stock_picking(osv.osv):
|
|||
'product_uom': product.uom_id.id,
|
||||
'product_uom_qty': remaining_qty,
|
||||
'name': _('Extra Move: ') + product.name,
|
||||
'state': 'confirmed',
|
||||
'state': 'draft',
|
||||
}
|
||||
move_obj.create(cr, uid, vals, context=context)
|
||||
moves.append(move_obj.create(cr, uid, vals, context=context))
|
||||
if moves:
|
||||
move_obj.action_confirm(cr, uid, moves, context=context)
|
||||
return moves
|
||||
|
||||
def rereserve_quants(self, cr, uid, picking, move_ids=[], context=None):
|
||||
""" Unreserve quants then try to reassign quants."""
|
||||
|
@ -1289,11 +1293,13 @@ class stock_picking(osv.osv):
|
|||
else:
|
||||
need_rereserve, all_op_processed = self.picking_recompute_remaining_quantities(cr, uid, picking, context=context)
|
||||
#create extra moves in the picking (unexpected product moves coming from pack operations)
|
||||
todo_move_ids = []
|
||||
if not all_op_processed:
|
||||
self._create_extra_moves(cr, uid, picking, context=context)
|
||||
todo_move_ids += self._create_extra_moves(cr, uid, picking, context=context)
|
||||
|
||||
picking.refresh()
|
||||
#split move lines eventually
|
||||
todo_move_ids = []
|
||||
|
||||
toassign_move_ids = []
|
||||
for move in picking.move_lines:
|
||||
remaining_qty = move.remaining_qty
|
||||
|
|
|
@ -30,11 +30,7 @@
|
|||
<field name="property_stock_account_input" domain="[('type','<>','view'),('type','<>','consolidation')]"/>
|
||||
<field name="property_stock_account_output" domain="[('type','<>','view'),('type','<>','consolidation')]"/>
|
||||
</group>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='standard_price']" position='replace'>
|
||||
<field name="standard_price" attrs="{'readonly':[('cost_method','=','average')]}"/>
|
||||
<field name="cost_method" groups="stock_account.group_inventory_valuation"/>
|
||||
</xpath>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
Loading…
Reference in New Issue