[IMP] Query should pass through orm and as such the refreshes can be removed in the code, which will go faster as it is done automatically by the new api
This commit is contained in:
parent
38f0508bba
commit
8c8056d95f
|
@ -111,7 +111,6 @@ class procurement_order(osv.osv):
|
|||
|
||||
res[procurement.id] = produce_id
|
||||
self.write(cr, uid, [procurement.id], {'production_id': produce_id})
|
||||
procurement.refresh()
|
||||
self.production_order_create_note(cr, uid, procurement, context=context)
|
||||
production_obj.action_compute(cr, uid, [produce_id], properties=[x.id for x in procurement.property_ids])
|
||||
production_obj.signal_workflow(cr, uid, [produce_id], 'button_confirm')
|
||||
|
|
|
@ -203,7 +203,6 @@ class procurement_order(osv.osv):
|
|||
if procurement.state not in ("running", "done"):
|
||||
try:
|
||||
if self._assign(cr, uid, procurement, context=context):
|
||||
procurement.refresh()
|
||||
res = self._run(cr, uid, procurement, context=context or {})
|
||||
if res:
|
||||
self.write(cr, uid, [procurement.id], {'state': 'running'}, context=context)
|
||||
|
|
|
@ -404,7 +404,6 @@ class stock_quant(osv.osv):
|
|||
quant = self._quant_create(cr, uid, qty, move, lot_id=lot_id, owner_id=owner_id, src_package_id=src_package_id, dest_package_id=dest_package_id, force_location_from=location_from, force_location_to=location_to, context=context)
|
||||
else:
|
||||
self._quant_split(cr, uid, quant, qty, context=context)
|
||||
quant.refresh()
|
||||
to_move_quants.append(quant)
|
||||
quants_reconcile.append(quant)
|
||||
if to_move_quants:
|
||||
|
@ -414,7 +413,6 @@ class stock_quant(osv.osv):
|
|||
if location_to.usage == 'internal':
|
||||
if self.search(cr, uid, [('product_id', '=', move.product_id.id), ('qty','<', 0)], limit=1, context=context):
|
||||
for quant in quants_reconcile:
|
||||
quant.refresh()
|
||||
self._quant_reconcile_negative(cr, uid, quant, move, context=context)
|
||||
|
||||
def move_quants_write(self, cr, uid, quants, move, location_dest_id, dest_package_id, context=None):
|
||||
|
@ -527,7 +525,6 @@ class stock_quant(osv.osv):
|
|||
new_qty_round = float_round(quant.qty - qty, precision_rounding=rounding)
|
||||
new_quant = self.copy(cr, SUPERUSER_ID, quant.id, default={'qty': new_qty_round, 'history_ids': [(4, x.id) for x in quant.history_ids]}, context=context)
|
||||
self.write(cr, SUPERUSER_ID, quant.id, {'qty': qty_round}, context=context)
|
||||
quant.refresh()
|
||||
return self.browse(cr, uid, new_quant, context=context)
|
||||
|
||||
def _get_latest_move(self, cr, uid, quant, context=None):
|
||||
|
@ -877,7 +874,6 @@ class stock_picking(osv.osv):
|
|||
for pick in self.browse(cr, uid, ids, context=context):
|
||||
if pick.state == 'draft':
|
||||
self.action_confirm(cr, uid, [pick.id], context=context)
|
||||
pick.refresh()
|
||||
#skip the moves that don't need to be checked
|
||||
move_ids = [x.id for x in pick.move_lines if x.state not in ('draft', 'cancel', 'done')]
|
||||
if not move_ids:
|
||||
|
@ -1207,6 +1203,7 @@ class stock_picking(osv.osv):
|
|||
uom_obj = self.pool.get('product.uom')
|
||||
package_obj = self.pool.get('stock.quant.package')
|
||||
quant_obj = self.pool.get('stock.quant')
|
||||
link_obj = self.pool.get('stock.move.operation.link')
|
||||
quants_in_package_done = set()
|
||||
prod2move_ids = {}
|
||||
still_to_do = []
|
||||
|
@ -1222,7 +1219,9 @@ class stock_picking(osv.osv):
|
|||
operations = picking.pack_operation_ids
|
||||
operations = sorted(operations, key=lambda x: ((x.package_id and not x.product_id) and -4 or 0) + (x.package_id and -2 or 0) + (x.lot_id and -1 or 0))
|
||||
#delete existing operations to start again from scratch
|
||||
cr.execute("DELETE FROM stock_move_operation_link WHERE operation_id in %s", (tuple([x.id for x in operations]),))
|
||||
links = link_obj.search(cr, uid, [('operation_id', 'in', [x.id for x in operations])], context=context)
|
||||
if links:
|
||||
link_obj.unlink(cr, uid, links, context=context)
|
||||
#1) first, try to create links when quants can be identified without any doubt
|
||||
for ops in operations:
|
||||
#for each operation, create the links with the stock move by seeking on the matching reserved quants,
|
||||
|
@ -1382,9 +1381,7 @@ class stock_picking(osv.osv):
|
|||
if not all_op_processed:
|
||||
todo_move_ids += self._create_extra_moves(cr, uid, picking, context=context)
|
||||
|
||||
picking.refresh()
|
||||
#split move lines eventually
|
||||
|
||||
#split move lines if needed
|
||||
toassign_move_ids = []
|
||||
for move in picking.move_lines:
|
||||
remaining_qty = move.remaining_qty
|
||||
|
@ -1410,7 +1407,6 @@ class stock_picking(osv.osv):
|
|||
self.pool.get('stock.move').action_done(cr, uid, todo_move_ids, context=context)
|
||||
elif context.get('do_only_split'):
|
||||
context = dict(context, split=todo_move_ids)
|
||||
picking.refresh()
|
||||
self._create_backorder(cr, uid, picking, context=context)
|
||||
if toassign_move_ids:
|
||||
stock_move_obj.action_assign(cr, uid, toassign_move_ids, context=context)
|
||||
|
@ -2211,7 +2207,6 @@ class stock_move(osv.osv):
|
|||
for move in todo_moves:
|
||||
if move.linked_move_operation_ids:
|
||||
continue
|
||||
move.refresh()
|
||||
#then if the move isn't totally assigned, try to find quants without any specific domain
|
||||
if move.state != 'assigned':
|
||||
qty_already_assigned = move.reserved_availability
|
||||
|
@ -2616,7 +2611,6 @@ class stock_inventory(osv.osv):
|
|||
if inventory_line.product_qty < 0 and inventory_line.product_qty != inventory_line.theoretical_qty:
|
||||
raise osv.except_osv(_('Warning'), _('You cannot set a negative product quantity in an inventory line:\n\t%s - qty: %s' % (inventory_line.product_id.name, inventory_line.product_qty)))
|
||||
self.action_check(cr, uid, [inv.id], context=context)
|
||||
inv.refresh()
|
||||
self.write(cr, uid, [inv.id], {'state': 'done'}, context=context)
|
||||
self.post_inventory(cr, uid, inv, context=context)
|
||||
return True
|
||||
|
@ -3362,7 +3356,6 @@ class stock_warehouse(osv.osv):
|
|||
new_id = super(stock_warehouse, self).create(cr, uid, vals=vals, context=context)
|
||||
warehouse = self.browse(cr, uid, new_id, context=context)
|
||||
self.create_sequences_and_picking_types(cr, uid, warehouse, context=context)
|
||||
warehouse.refresh()
|
||||
|
||||
#create routes and push/pull rules
|
||||
new_objects_dict = self.create_routes(cr, uid, new_id, warehouse, context=context)
|
||||
|
@ -3482,7 +3475,6 @@ class stock_warehouse(osv.osv):
|
|||
self.change_route(cr, uid, ids, warehouse, vals.get('reception_steps', False), vals.get('delivery_steps', False), context=context_with_inactive)
|
||||
# Check if we need to change something to resupply warehouses and associated MTO rules
|
||||
self._check_resupply(cr, uid, warehouse, vals.get('reception_steps'), vals.get('delivery_steps'), context=context)
|
||||
warehouse.refresh()
|
||||
if vals.get('code') or vals.get('name'):
|
||||
name = warehouse.name
|
||||
#rename sequence
|
||||
|
@ -3624,7 +3616,6 @@ class stock_location_path(osv.osv):
|
|||
'date_expected': newdate,
|
||||
'location_dest_id': rule.location_dest_id.id
|
||||
})
|
||||
move.refresh()
|
||||
#avoid looping if a push rule is not well configured
|
||||
if rule.location_dest_id.id != old_dest_location:
|
||||
#call again push_apply to see if a next step is defined
|
||||
|
|
|
@ -267,7 +267,6 @@ class stock_move(osv.osv):
|
|||
def _store_average_cost_price(self, cr, uid, move, context=None):
|
||||
''' move is a browe record '''
|
||||
product_obj = self.pool.get('product.product')
|
||||
move.refresh()
|
||||
if any([q.qty <= 0 for q in move.quant_ids]):
|
||||
#if there is a negative quant, the standard price shouldn't be updated
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue