summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2017-09-15 14:22:37 +0200
committerSimon Lejeune <sle@openerp.com>2017-09-15 17:49:37 +0200
commit6aebc800538b6fabd79c6cd1e819ef6d961e7589 (patch)
tree90ed3397705860d9964cbc85a024260c75a4eba3
parentbfa85c84a661e2584600ae90771f8a900206c0a3 (diff)
[REF] stock, etc: only expose public method, remove indirection
also, remove now useless api.multi and dummy methods here and there
-rw-r--r--addons/mrp/data/mrp_demo.xml2
-rw-r--r--addons/mrp/models/mrp_production.py18
-rw-r--r--addons/mrp/models/mrp_unbuild.py6
-rw-r--r--addons/mrp/models/stock_move.py20
-rw-r--r--addons/mrp/tests/test_order.py2
-rw-r--r--addons/mrp/tests/test_stock.py2
-rw-r--r--addons/mrp/tests/test_workorder_operation.py4
-rw-r--r--addons/mrp/views/mrp_message_views.xml4
-rw-r--r--addons/mrp/views/stock_move_views.xml2
-rw-r--r--addons/mrp/wizard/change_production_qty.py2
-rw-r--r--addons/mrp_byproduct/models/mrp_production.py2
-rw-r--r--addons/mrp_repair/models/mrp_repair.py2
-rw-r--r--addons/point_of_sale/models/pos_order.py4
-rw-r--r--addons/purchase/models/purchase.py8
-rw-r--r--addons/sale_mrp/tests/test_sale_mrp_flow.py4
-rw-r--r--addons/sale_stock/models/stock.py5
-rw-r--r--addons/sale_stock/tests/test_sale_stock.py4
-rw-r--r--addons/stock/models/procurement.py7
-rw-r--r--addons/stock/models/product.py12
-rw-r--r--addons/stock/models/stock_inventory.py14
-rw-r--r--addons/stock/models/stock_location.py7
-rw-r--r--addons/stock/models/stock_move.py81
-rw-r--r--addons/stock/models/stock_move_line.py16
-rw-r--r--addons/stock/models/stock_picking.py44
-rw-r--r--addons/stock/models/stock_quant.py10
-rw-r--r--addons/stock/models/stock_scrap.py10
-rw-r--r--addons/stock/models/stock_traceability.py1
-rw-r--r--addons/stock/models/stock_warehouse.py12
-rw-r--r--addons/stock/tests/test_inventory.py10
-rw-r--r--addons/stock/tests/test_move.py368
-rw-r--r--addons/stock/tests/test_move2.py8
-rw-r--r--addons/stock/tests/test_shipment.py2
-rw-r--r--addons/stock/tests/test_stock_flow.py30
-rw-r--r--addons/stock/tests/test_warehouse.py16
-rw-r--r--addons/stock/views/stock_inventory_views.xml4
-rw-r--r--addons/stock/views/stock_picking_views.xml2
-rw-r--r--addons/stock/views/stock_scrap_views.xml2
-rw-r--r--addons/stock/wizard/stock_backorder_confirmation.py2
-rw-r--r--addons/stock/wizard/stock_change_product_qty.py6
-rw-r--r--addons/stock/wizard/stock_immediate_transfer.py3
-rw-r--r--addons/stock/wizard/stock_picking_return.py4
-rw-r--r--addons/stock/wizard/stock_scheduler_compute.py1
-rw-r--r--addons/stock_account/models/stock.py5
-rw-r--r--addons/stock_account/tests/test_stockvaluation.py266
44 files changed, 450 insertions, 584 deletions
diff --git a/addons/mrp/data/mrp_demo.xml b/addons/mrp/data/mrp_demo.xml
index f8a333a67f4..c142e372051 100644
--- a/addons/mrp/data/mrp_demo.xml
+++ b/addons/mrp/data/mrp_demo.xml
@@ -533,7 +533,7 @@
<field name="bom_id" ref="mrp_bom_laptop_cust"/>
</record>
- <function model="stock.inventory" name="prepare_inventory" eval="[[ref('mrp.stock_inventory_product_laptop_charger'), ref('mrp.stock_inventory_product_laptop_keypad')]]"/>
+ <function model="stock.inventory" name="action_start" eval="[[ref('mrp.stock_inventory_product_laptop_charger'), ref('mrp.stock_inventory_product_laptop_keypad')]]"/>
<function model="stock.inventory" name="action_done" eval="[[ref('stock_inventory_product_laptop_charger'), ref('stock_inventory_product_laptop_keypad')]]"/>
diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py
index 796a3a69387..d3167bf7a53 100644
--- a/addons/mrp/models/mrp_production.py
+++ b/addons/mrp/models/mrp_production.py
@@ -302,7 +302,7 @@ class MrpProduction(models.Model):
production._generate_raw_moves(lines)
# Check for all draft moves whether they are mto or not
production._adjust_procure_method()
- production.move_raw_ids.action_confirm()
+ production.move_raw_ids._action_confirm()
return True
def _generate_finished_moves(self):
@@ -322,7 +322,7 @@ class MrpProduction(models.Model):
'propagate': self.propagate,
'move_dest_ids': [(4, x.id) for x in self.move_dest_ids],
})
- move.action_confirm()
+ move._action_confirm()
return move
def _generate_raw_moves(self, exploded_lines):
@@ -402,7 +402,7 @@ class MrpProduction(models.Model):
else:
if move[0].quantity_done > 0:
raise UserError(_('Lines need to be deleted, but can not as you still have some quantities to consume in them. '))
- move[0].action_cancel()
+ move[0]._action_cancel()
move[0].unlink()
return move
else:
@@ -411,7 +411,7 @@ class MrpProduction(models.Model):
@api.multi
def action_assign(self):
for production in self:
- production.move_raw_ids.action_assign()
+ production.move_raw_ids._action_assign()
return True
@api.multi
@@ -496,7 +496,7 @@ class MrpProduction(models.Model):
finish_moves = production.move_finished_ids.filtered(lambda x: x.state not in ('done', 'cancel'))
raw_moves = production.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel'))
- (finish_moves | raw_moves).action_cancel()
+ (finish_moves | raw_moves)._action_cancel()
self.write({'state': 'cancel'})
return True
@@ -510,11 +510,11 @@ class MrpProduction(models.Model):
for order in self:
moves_not_to_do = order.move_raw_ids.filtered(lambda x: x.state == 'done')
moves_to_do = order.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel'))
- moves_to_do.action_done()
+ moves_to_do._action_done()
moves_to_do = order.move_raw_ids.filtered(lambda x: x.state == 'done') - moves_not_to_do
order._cal_price(moves_to_do)
moves_to_finish = order.move_finished_ids.filtered(lambda x: x.state not in ('done','cancel'))
- moves_to_finish.action_done()
+ moves_to_finish._action_done()
#order.action_assign()
consume_move_lines = moves_to_do.mapped('active_move_line_ids')
for moveline in moves_to_finish.mapped('active_move_line_ids'):
@@ -535,14 +535,14 @@ class MrpProduction(models.Model):
raise UserError(_('Work order %s is still running') % wo.name)
self.post_inventory()
moves_to_cancel = (self.move_raw_ids | self.move_finished_ids).filtered(lambda x: x.state not in ('done', 'cancel'))
- moves_to_cancel.action_cancel()
+ moves_to_cancel._action_cancel()
self.write({'state': 'done', 'date_finished': fields.Datetime.now()})
return self.write({'state': 'done'})
@api.multi
def do_unreserve(self):
for production in self:
- production.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel')).do_unreserve()
+ production.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel'))._do_unreserve()
return True
@api.multi
diff --git a/addons/mrp/models/mrp_unbuild.py b/addons/mrp/models/mrp_unbuild.py
index 142e55d7ba5..3245ff2fb78 100644
--- a/addons/mrp/models/mrp_unbuild.py
+++ b/addons/mrp/models/mrp_unbuild.py
@@ -105,7 +105,7 @@ class MrpUnbuild(models.Model):
})
else:
consume_move.quantity_done = consume_move.product_uom_qty
- consume_move.action_done()
+ consume_move._action_done()
# TODO: Will fail if user do more than one unbuild with lot on the same MO. Need to check what other unbuild has aready took
for produce_move in produce_moves:
@@ -128,7 +128,7 @@ class MrpUnbuild(models.Model):
needed_quantity -= taken_quantity
else:
produce_move.quantity_done = produce_move.product_uom_qty
- produce_moves.action_done()
+ produce_moves._action_done()
produced_move_line_ids = produce_moves.mapped('move_line_ids').filtered(lambda ml: ml.qty_done > 0)
consume_move.move_line_ids.write({'produce_line_ids': [(6, 0, produced_move_line_ids.ids)]})
@@ -148,7 +148,7 @@ class MrpUnbuild(models.Model):
'origin': unbuild.name,
'consume_unbuild_id': unbuild.id,
})
- move.action_confirm()
+ move._action_confirm()
moves += move
return moves
diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py
index a391f986a99..933307e5aed 100644
--- a/addons/mrp/models/stock_move.py
+++ b/addons/mrp/models/stock_move.py
@@ -71,27 +71,24 @@ class StockMove(models.Model):
else:
return super(StockMove, self)._get_move_lines()
- @api.multi
@api.depends('state')
def _compute_is_done(self):
for move in self:
move.is_done = (move.state in ('done', 'cancel'))
- @api.multi
- def action_assign(self):
- res = super(StockMove, self).action_assign()
+ def _action_assign(self):
+ res = super(StockMove, self)._action_assign()
for move in self.filtered(lambda x: x.production_id or x.raw_material_production_id):
if move.move_line_ids:
move.move_line_ids.write({'production_id': move.raw_material_production_id.id,
'workorder_id': move.workorder_id.id,})
return res
- @api.multi
- def action_cancel(self):
+ def _action_cancel(self):
if any(move.quantity_done for move in self): #TODO: either put in stock, or check there is a production order related to it
raise exceptions.UserError(_('You cannot cancel a manufacturing order if you have already consumed material.\
If you want to cancel this MO, please change the consumed quantities to 0.'))
- return super(StockMove, self).action_cancel()
+ return super(StockMove, self)._action_cancel()
@api.multi
# Could use split_move_operation from stock here
@@ -127,17 +124,12 @@ class StockMove(models.Model):
}
return result
- @api.multi
- def save(self):
- return True
-
- @api.multi
- def action_confirm(self):
+ def _action_confirm(self):
moves = self
for move in self.filtered(lambda m: m.production_id):
moves |= move.action_explode()
# we go further with the list of ids potentially changed by action_explode
- return super(StockMove, moves).action_confirm()
+ return super(StockMove, moves)._action_confirm()
def action_explode(self):
""" Explodes pickings """
diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py
index 35e3c2ee9c7..176b023d5d9 100644
--- a/addons/mrp/tests/test_order.py
+++ b/addons/mrp/tests/test_order.py
@@ -239,7 +239,7 @@ class TestMrpOrder(TestMrpCommon):
'location_id': self.ref('stock.stock_location_14')
})]
})
- inventory.prepare_inventory()
+ inventory.action_start()
inventory.action_done()
# re-assign consume material
diff --git a/addons/mrp/tests/test_stock.py b/addons/mrp/tests/test_stock.py
index ddd4deb4341..a58348bb1e8 100644
--- a/addons/mrp/tests/test_stock.py
+++ b/addons/mrp/tests/test_stock.py
@@ -69,7 +69,7 @@ class TestWarehouse(common.TestMrpCommon):
'line_ids': [
(0, 0, {'product_id': self.product_2.id, 'product_uom_id': self.product_2.uom_id.id, 'product_qty': 12, 'prod_lot_id': lot_product_2.id, 'location_id': self.ref('stock.stock_location_14')})
]})
- (stock_inv_product_4 | stock_inv_product_2).prepare_inventory()
+ (stock_inv_product_4 | stock_inv_product_2).action_start()
(stock_inv_product_4 | stock_inv_product_2).action_done()
#Create Manufacturing order.
diff --git a/addons/mrp/tests/test_workorder_operation.py b/addons/mrp/tests/test_workorder_operation.py
index a52332c05a0..02626887c1f 100644
--- a/addons/mrp/tests/test_workorder_operation.py
+++ b/addons/mrp/tests/test_workorder_operation.py
@@ -212,7 +212,7 @@ class TestWorkOrderProcess(common.TransactionCase):
'location_id': self.source_location_id
})]
})
- # inventory.prepare_inventory()
+ # inventory.action_start()
inventory.action_done()
# Check consumed move status
@@ -382,7 +382,7 @@ class TestWorkOrderProcess(common.TransactionCase):
'location_id': self.source_location_id
})]
})
- # inventory.prepare_inventory()
+ # inventory.action_start()
inventory.action_done()
# Start Production ...
diff --git a/addons/mrp/views/mrp_message_views.xml b/addons/mrp/views/mrp_message_views.xml
index df42e54f7a1..3697b144972 100644
--- a/addons/mrp/views/mrp_message_views.xml
+++ b/addons/mrp/views/mrp_message_views.xml
@@ -39,7 +39,7 @@
</group>
<field name="message" widget="html" editor_height="450px"/>
<footer class="oe_edit_only">
- <button name="save" type="object" string="Save" class="oe_highlight"/>
+ <button special="save" type="object" string="Save" class="oe_highlight"/>
<button string="Discard" special="cancel"/>
</footer>
</form>
@@ -63,7 +63,7 @@
</group>
<field name="message" widget="html" editor_height="450px"/>
<footer class="oe_edit_only">
- <button name="save" type="object" string="Save" class="oe_highlight"/>
+ <button special="save" type="object" string="Save" class="oe_highlight"/>
<button string="Discard" special="cancel"/>
</footer>
</form>
diff --git a/addons/mrp/views/stock_move_views.xml b/addons/mrp/views/stock_move_views.xml
index 08b66f1d9fa..db9623bc67f 100644
--- a/addons/mrp/views/stock_move_views.xml
+++ b/addons/mrp/views/stock_move_views.xml
@@ -47,7 +47,7 @@
</tree>
</field>
<footer class="oe_edit_only">
- <button name="save" type="object" string="Save" class="oe_highlight"/>
+ <button special="save" type="object" string="Save" class="oe_highlight"/>
<button string="Discard" special="cancel"/>
</footer>
</form>
diff --git a/addons/mrp/wizard/change_production_qty.py b/addons/mrp/wizard/change_production_qty.py
index cd3cf5a5864..526a12d8ffc 100644
--- a/addons/mrp/wizard/change_production_qty.py
+++ b/addons/mrp/wizard/change_production_qty.py
@@ -55,7 +55,7 @@ class ChangeProductionQty(models.TransientModel):
operation_bom_qty[operation.id] = bom_data['qty']
self._update_product_to_produce(production, production.product_qty - qty_produced)
moves = production.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel'))
- moves.action_assign()
+ moves._action_assign()
for wo in production.workorder_ids:
operation = wo.operation_id
if operation_bom_qty.get(operation.id):
diff --git a/addons/mrp_byproduct/models/mrp_production.py b/addons/mrp_byproduct/models/mrp_production.py
index c60c67ab4f0..91917da03cc 100644
--- a/addons/mrp_byproduct/models/mrp_production.py
+++ b/addons/mrp_byproduct/models/mrp_production.py
@@ -30,7 +30,7 @@ class MrpProduction(models.Model):
'subproduct_id': sub_product.id
}
move = Move.create(data)
- move.action_confirm()
+ move._action_confirm()
@api.multi
def _generate_moves(self):
diff --git a/addons/mrp_repair/models/mrp_repair.py b/addons/mrp_repair/models/mrp_repair.py
index 55199f61b40..c057c69f2f1 100644
--- a/addons/mrp_repair/models/mrp_repair.py
+++ b/addons/mrp_repair/models/mrp_repair.py
@@ -463,7 +463,7 @@ class Repair(models.Model):
consumed_lines = moves.mapped('move_line_ids')
produced_lines = move.move_line_ids
moves |= move
- moves.action_done()
+ moves._action_done()
produced_lines.write({'consume_line_ids': [(6, 0, consumed_lines.ids)]})
res[repair.id] = move.id
return res
diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py
index 92cec857a6b..7669357c342 100644
--- a/addons/point_of_sale/models/pos_order.py
+++ b/addons/point_of_sale/models/pos_order.py
@@ -673,9 +673,9 @@ class PosOrder(models.Model):
# when the pos.config has no picking_type_id set only the moves will be created
if moves and not return_picking and not order_picking:
- moves.action_assign()
+ moves._action_assign()
moves.filtered(lambda m: m.state in ['confirmed', 'waiting']).force_assign()
- moves.filtered(lambda m: m.product_id.tracking == 'none').action_done()
+ moves.filtered(lambda m: m.product_id.tracking == 'none')._action_done()
return True
diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py
index 2bc2c0b52c2..d048cfefc02 100644
--- a/addons/purchase/models/purchase.py
+++ b/addons/purchase/models/purchase.py
@@ -414,12 +414,12 @@ class PurchaseOrder(models.Model):
else:
picking = pickings[0]
moves = order.order_line._create_stock_moves(picking)
- moves = moves.filtered(lambda x: x.state not in ('done', 'cancel')).action_confirm()
+ moves = moves.filtered(lambda x: x.state not in ('done', 'cancel'))._action_confirm()
seq = 0
for move in sorted(moves, key=lambda move: move.date_expected):
seq += 5
move.sequence = seq
- moves.action_assign()
+ moves._action_assign()
picking.message_post_with_view('mail.message_origin_link',
values={'self': picking, 'origin': order},
subtype_id=self.env.ref('mail.mt_note').id)
@@ -655,8 +655,8 @@ class PurchaseOrderLine(models.Model):
for move_val in move_vals:
self.env['stock.move']\
.create(move_val)\
- .action_confirm()\
- .action_assign()
+ ._action_confirm()\
+ ._action_assign()
@api.multi
def _get_stock_move_price_unit(self):
diff --git a/addons/sale_mrp/tests/test_sale_mrp_flow.py b/addons/sale_mrp/tests/test_sale_mrp_flow.py
index 5ab02b673ce..f6a87c7a926 100644
--- a/addons/sale_mrp/tests/test_sale_mrp_flow.py
+++ b/addons/sale_mrp/tests/test_sale_mrp_flow.py
@@ -244,7 +244,7 @@ class TestSaleMrpFlow(common.TransactionCase):
'product_id': product_c.id,
'filter': 'product'})
- inventory.prepare_inventory()
+ inventory.action_start()
self.assertFalse(inventory.line_ids, "Inventory line should not created.")
self.InventoryLine.create({
'inventory_id': inventory.id,
@@ -294,7 +294,7 @@ class TestSaleMrpFlow(common.TransactionCase):
'product_id': product_c.id,
'filter': 'product'})
- inventory.prepare_inventory()
+ inventory.action_start()
self.assertFalse(inventory.line_ids, "Inventory line should not created.")
self.InventoryLine.create({
'inventory_id': inventory.id,
diff --git a/addons/sale_stock/models/stock.py b/addons/sale_stock/models/stock.py
index 98d09435fc1..aed1a510c9e 100644
--- a/addons/sale_stock/models/stock.py
+++ b/addons/sale_stock/models/stock.py
@@ -13,9 +13,8 @@ class StockMove(models.Model):
_inherit = "stock.move"
sale_line_id = fields.Many2one('sale.order.line', 'Sale Line')
- @api.multi
- def action_done(self):
- result = super(StockMove, self).action_done()
+ def _action_done(self):
+ result = super(StockMove, self)._action_done()
for line in self.mapped('sale_line_id'):
line.qty_delivered = line._get_delivered_qty()
return result
diff --git a/addons/sale_stock/tests/test_sale_stock.py b/addons/sale_stock/tests/test_sale_stock.py
index 2cc67016c8d..4880c8fdd12 100644
--- a/addons/sale_stock/tests/test_sale_stock.py
+++ b/addons/sale_stock/tests/test_sale_stock.py
@@ -141,7 +141,7 @@ class TestSaleStock(TestSale):
pick = self.so.picking_ids
pick.force_assign()
pick.move_lines.write({'quantity_done': 5})
- pick.do_new_transfer()
+ pick.button_validate()
# Check quantity delivered
del_qty = sum(sol.qty_delivered for sol in self.so.order_line)
@@ -168,7 +168,7 @@ class TestSaleStock(TestSale):
# Validate picking
return_pick.force_assign()
return_pick.move_lines.write({'quantity_done': 2})
- return_pick.do_new_transfer()
+ return_pick.button_validate()
# Check invoice
self.assertEqual(self.so.invoice_status, 'to invoice', 'Sale Stock: so invoice_status should be "to invoice" instead of "%s" after picking return' % self.so.invoice_status)
diff --git a/addons/stock/models/procurement.py b/addons/stock/models/procurement.py
index f3a43fbe083..3894ad64fcd 100644
--- a/addons/stock/models/procurement.py
+++ b/addons/stock/models/procurement.py
@@ -62,7 +62,6 @@ class ProcurementRule(models.Model):
'stock.warehouse', 'Warehouse to Propagate',
help="The warehouse to propagate on the created move/procurement, which can be different of the warehouse this rule is for (e.g for resupplying rules from another warehouse)")
- @api.multi
def _run_move(self, product_id, product_qty, product_uom, location_id, name, origin, values):
if not self.location_src_id:
msg = _('No source location defined on procurement rule: %s!') % (self.name, )
@@ -79,8 +78,8 @@ class ProcurementRule(models.Model):
data = self._get_stock_move_values(product_id, product_qty, product_uom, location_id, name, origin, values, group_id)
# Since action_confirm launch following procurement_group we should activate it.
move = self.env['stock.move'].sudo().create(data)
- move.assign_picking()
- move.action_confirm()
+ move._assign_picking()
+ move._action_confirm()
return True
def _get_stock_move_values(self, product_id, product_qty, product_uom, location_id, name, origin, values, group_id):
@@ -249,7 +248,7 @@ class ProcurementGroup(models.Model):
# Search all confirmed stock_moves and try to assign them
confirmed_moves = self.env['stock.move'].search([('state', '=', 'confirmed')], limit=None, order='priority desc, date_expected asc')
for moves_chunk in split_every(100, confirmed_moves.ids):
- self.env['stock.move'].browse(moves_chunk).action_assign()
+ self.env['stock.move'].browse(moves_chunk)._action_assign()
if use_new_cursor:
self._cr.commit()
diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py
index 63485c8e907..12c957855ad 100644
--- a/addons/stock/models/product.py
+++ b/addons/stock/models/product.py
@@ -84,12 +84,10 @@ class Product(models.Model):
product.outgoing_qty = res[product.id]['outgoing_qty']
product.virtual_available = res[product.id]['virtual_available']
- @api.multi
def _product_available(self, field_names=None, arg=False):
""" Compatibility method """
return self._compute_quantities_dict(self._context.get('lot_id'), self._context.get('owner_id'), self._context.get('package_id'), self._context.get('from_date'), self._context.get('to_date'))
- @api.multi
def _compute_quantities_dict(self, lot_id, owner_id, package_id, from_date=False, to_date=False):
domain_quant_loc, domain_move_in_loc, domain_move_out_loc = self._get_domain_locations()
domain_quant = [('product_id', 'in', self.ids)] + domain_quant_loc
@@ -348,18 +346,15 @@ class Product(models.Model):
res['fields']['qty_available']['string'] = _('Produced Qty')
return res
- @api.multi
def action_view_routes(self):
return self.mapped('product_tmpl_id').action_view_routes()
- @api.multi
def action_view_stock_move_lines(self):
self.ensure_one()
action = self.env.ref('stock.stock_move_line_action').read()[0]
action['domain'] = [('product_id', '=', self.id)]
return action
- @api.multi
def action_open_product_lot(self):
self.ensure_one()
action = self.env.ref('stock.action_production_lot_form').read()[0]
@@ -367,7 +362,6 @@ class Product(models.Model):
action['context'] = {'default_product_id': self.id}
return action
- @api.multi
def write(self, values):
res = super(Product, self).write(values)
if 'active' in values and not values['active'] and self.mapped('orderpoint_ids').filtered(lambda r: r.active):
@@ -498,7 +492,6 @@ class ProductTemplate(models.Model):
def onchange_tracking(self):
return self.mapped('product_variant_ids').onchange_tracking()
- @api.multi
def write(self, vals):
if 'uom_id' in vals:
new_uom = self.env['product.uom'].browse(vals['uom_id'])
@@ -508,14 +501,12 @@ class ProductTemplate(models.Model):
raise UserError(_("You can not change the unit of measure of a product that has already been used in a done stock move. If you need to change the unit of measure, you may deactivate this product."))
return super(ProductTemplate, self).write(vals)
- @api.multi
def action_view_routes(self):
routes = self.mapped('route_ids') | self.mapped('categ_id').mapped('total_route_ids') | self.env['stock.location.route'].search([('warehouse_selectable', '=', True)])
action = self.env.ref('stock.action_routes_form').read()[0]
action['domain'] = [('id', 'in', routes.ids)]
return action
- @api.multi
def action_open_quants(self):
products = self.mapped('product_variant_ids')
action = self.env.ref('stock.product_open_quants').read()[0]
@@ -523,7 +514,6 @@ class ProductTemplate(models.Model):
action['context'] = {'search_default_internal_loc': 1}
return action
- @api.multi
def action_view_orderpoints(self):
products = self.mapped('product_variant_ids')
action = self.env.ref('stock.product_open_orderpoint').read()[0]
@@ -534,14 +524,12 @@ class ProductTemplate(models.Model):
action['context'] = {}
return action
- @api.multi
def action_view_stock_move_lines(self):
self.ensure_one()
action = self.env.ref('stock.stock_move_line_action').read()[0]
action['domain'] = [('product_id.product_tmpl_id', 'in', self.ids)]
return action
- @api.multi
def action_open_product_lot(self):
self.ensure_one()
action = self.env.ref('stock.action_production_lot_form').read()[0]
diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py
index 7e46e17093d..156260cd6c3 100644
--- a/addons/stock/models/stock_inventory.py
+++ b/addons/stock/models/stock_inventory.py
@@ -149,13 +149,10 @@ class Inventory(models.Model):
if self.filter != 'pack' and self.package_id:
raise UserError(_('The selected inventory options are not coherent.'))
- @api.multi
def action_reset_product_qty(self):
self.mapped('line_ids').write({'product_qty': 0})
return True
- reset_real_qty = action_reset_product_qty
- @api.multi
def action_done(self):
negative = next((line for line in self.mapped('line_ids') if line.product_qty < 0 and line.product_qty != line.theoretical_qty), False)
if negative:
@@ -165,14 +162,12 @@ class Inventory(models.Model):
self.post_inventory()
return True
- @api.multi
def post_inventory(self):
# The inventory is posted as a single step which means quants cannot be moved from an internal location to another using an inventory
# as they will be moved to inventory loss, and other quants will be created to the encoded quant location. This is a normal behavior
# as quants cannot be reuse from inventory location (users can still manually move the products before/after the inventory if they want).
- self.mapped('move_ids').filtered(lambda move: move.state != 'done').action_done()
+ self.mapped('move_ids').filtered(lambda move: move.state != 'done')._action_done()
- @api.multi
def action_check(self):
""" Checks the inventory and computes the stock move to do """
# tde todo: clean after _generate_moves
@@ -181,15 +176,13 @@ class Inventory(models.Model):
inventory.mapped('move_ids').unlink()
inventory.line_ids._generate_moves()
- @api.multi
def action_cancel_draft(self):
- self.mapped('move_ids').action_cancel()
+ self.mapped('move_ids')._action_cancel()
self.write({
'line_ids': [(5,)],
'state': 'draft'
})
- @api.multi
def action_start(self):
for inventory in self:
vals = {'state': 'confirm', 'date': fields.Datetime.now()}
@@ -197,9 +190,7 @@ class Inventory(models.Model):
vals.update({'line_ids': [(0, 0, line_values) for line_values in inventory._get_inventory_lines_values()]})
inventory.write(vals)
return True
- prepare_inventory = action_start
- @api.multi
def action_inventory_line_tree(self):
action = self.env.ref('stock.action_inventory_line_tree').read()[0]
action['context'] = {
@@ -212,7 +203,6 @@ class Inventory(models.Model):
}
return action
- @api.multi
def _get_inventory_lines_values(self):
# TDE CLEANME: is sql really necessary ? I don't think so
locations = self.env['stock.location'].search([('id', 'child_of', [self.location_id.id])])
diff --git a/addons/stock/models/stock_location.py b/addons/stock/models/stock_location.py
index 020384b5992..76bc2aec172 100644
--- a/addons/stock/models/stock_location.py
+++ b/addons/stock/models/stock_location.py
@@ -79,7 +79,6 @@ class Location(models.Model):
name = '%s/%s' % (current.name, name)
self.complete_name = name
- @api.multi
def name_get(self):
ret_list = []
for location in self:
@@ -109,7 +108,6 @@ class Location(models.Model):
current_location = current_location.location_id
return putaway_location
- @api.multi
@api.returns('stock.warehouse', lambda value: value.id)
def get_warehouse(self):
""" Returns warehouse id of warehouse that contains location """
@@ -149,7 +147,6 @@ class Route(models.Model):
categ_ids = fields.Many2many('product.category', 'stock_location_route_categ', 'route_id', 'categ_id', 'Product Categories')
warehouse_ids = fields.Many2many('stock.warehouse', 'stock_route_warehouse', 'route_id', 'warehouse_id', 'Warehouses')
- @api.multi
def write(self, values):
'''when a route is deactivated, deactivate also its pull and push rules'''
res = super(Route, self).write(values)
@@ -158,7 +155,6 @@ class Route(models.Model):
self.mapped('pull_ids').filtered(lambda rule: rule.active != values['active']).write({'active': values['active']})
return res
- @api.multi
def view_product_ids(self):
return {
'name': _('Products'),
@@ -169,7 +165,6 @@ class Route(models.Model):
'domain': [('route_ids', 'in', self.ids)],
}
- @api.multi
def view_categ_ids(self):
return {
'name': _('Product Categories'),
@@ -228,7 +223,7 @@ class PushedFlow(models.Model):
new_move_vals = self._prepare_move_copy_values(move, new_date)
new_move = move.copy(new_move_vals)
move.write({'move_dest_ids': [(4, new_move.id)]})
- new_move.action_confirm()
+ new_move._action_confirm()
def _prepare_move_copy_values(self, move_to_copy, new_date):
new_move_vals = {
diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py
index 9b490ab1cb8..874a819acae 100644
--- a/addons/stock/models/stock_move.py
+++ b/addons/stock/models/stock_move.py
@@ -14,6 +14,7 @@ from odoo.tools.float_utils import float_compare, float_round, float_is_zero
PROCUREMENT_PRIORITIES = [('0', 'Not urgent'), ('1', 'Normal'), ('2', 'Urgent'), ('3', 'Very Urgent')]
+
class StockMove(models.Model):
_name = "stock.move"
_description = "Stock Move"
@@ -92,7 +93,6 @@ class StockMove(models.Model):
picking_id = fields.Many2one('stock.picking', 'Transfer Reference', index=True, states={'done': [('readonly', True)]})
picking_partner_id = fields.Many2one('res.partner', 'Transfer Destination Address', related='picking_id.partner_id')
note = fields.Text('Notes')
- # TODO: state should be computed according to the move lines
state = fields.Selection([
('draft', 'New'), ('cancel', 'Cancelled'),
('waiting', 'Waiting Another Move'),
@@ -157,7 +157,6 @@ class StockMove(models.Model):
is_locked = fields.Boolean(related='picking_id.is_locked', readonly=True)
is_initial_demand_editable = fields.Boolean('Is initial demand editable', compute='_compute_is_initial_demand_editable')
- @api.multi
@api.depends('product_id', 'has_tracking', 'move_line_ids', 'location_id', 'location_dest_id')
def _compute_show_details_visible(self):
""" According to this field, the button that calls `action_show_details` will be displayed
@@ -180,7 +179,6 @@ class StockMove(models.Model):
else:
move.show_details_visible = False
- @api.multi
def _compute_show_reserved_availability(self):
""" This field is only of use in an attrs in the picking view, in order to hide the
"available" column if the move is coming from a supplier.
@@ -188,7 +186,6 @@ class StockMove(models.Model):
for move in self:
move.show_reserved_availability = not move.location_id.usage == 'supplier'
- @api.multi
@api.depends('state', 'picking_id')
def _compute_is_initial_demand_editable(self):
for move in self:
@@ -211,7 +208,6 @@ class StockMove(models.Model):
self.ensure_one()
return self.move_line_ids
- @api.multi
@api.depends('move_line_ids.qty_done', 'move_line_ids.product_uom_id')
def _quantity_done_compute(self):
for move in self:
@@ -219,7 +215,6 @@ class StockMove(models.Model):
# Transform the move_line quantity_done into the move uom.
move.quantity_done += move_line.product_uom_id._compute_quantity(move_line.qty_done, move.product_uom)
- @api.multi
def _quantity_done_set(self):
quantity_done = self[0].quantity_done # any call to create will invalidate `move.quantity_done`
for move in self:
@@ -241,7 +236,6 @@ class StockMove(models.Model):
detect errors. """
raise UserError(_('The requested operation cannot be processed because of a programming error setting the `product_qty` field instead of the `product_uom_qty`.'))
-
@api.one
@api.depends('move_line_ids.product_qty')
def _compute_reserved_availability(self):
@@ -264,7 +258,6 @@ class StockMove(models.Model):
total_availability = self.env['stock.quant']._get_available_quantity(self.product_id, self.location_id)
self.availability = min(self.product_qty, total_availability)
- @api.multi
def _compute_string_qty_information(self):
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
void_moves = self.filtered(lambda move: move.state in ('draft', 'done', 'cancel') or move.location_id.usage != 'internal')
@@ -321,7 +314,6 @@ class StockMove(models.Model):
defaults['additional'] = True
return defaults
- @api.multi
def name_get(self):
res = []
for move in self:
@@ -344,13 +336,12 @@ class StockMove(models.Model):
picking.message_track(picking.fields_get(['state']), initial_values)
return res
- @api.multi
def write(self, vals):
# FIXME: pim fix your crap
if vals.get('product_uom_qty'):
if self.env.context.get('do_not_unreserve') is None:
move_to_unreserve = self.filtered(lambda m: m.state not in ['draft', 'done', 'cancel'] and m.reserved_availability > vals.get('product_uom_qty'))
- move_to_unreserve.do_unreserve()
+ move_to_unreserve._do_unreserve()
(self - move_to_unreserve).filtered(lambda m: m.state == 'assigned').write({'state': 'partially_available'})
# TDE CLEANME: it is a gros bordel + tracking
@@ -397,7 +388,6 @@ class StockMove(models.Model):
pickings.message_track(pickings.fields_get(['state']), initial_values)
return res
- @api.multi
def action_show_details(self):
""" Returns an action that will open a form view (in a popup) allowing to work on all the
move lines of a particular move. This form view is used when "show operations" is not
@@ -435,18 +425,14 @@ class StockMove(models.Model):
),
}
- # Misc tools
- # ------------------------------------------------------------
-
- @api.multi
- def do_unreserve(self):
+ def _do_unreserve(self):
if any(move.state in ('done', 'cancel') for move in self):
raise UserError(_('Cannot unreserve a done move'))
for move in self:
move.move_line_ids.unlink()
- if(move.procure_method == 'make_to_order' and not move.move_orig_ids):
+ if move.procure_method == 'make_to_order' and not move.move_orig_ids:
move.state = 'waiting'
- elif(move.move_orig_ids and not all(orig.state in ('done', 'cancel') for orig in move.move_orig_ids)):
+ elif move.move_orig_ids and not all(orig.state in ('done', 'cancel') for orig in move.move_orig_ids):
move.state = 'waiting'
else:
move.state = 'confirmed'
@@ -510,9 +496,7 @@ class StockMove(models.Model):
}
}
- # TDE DECORATOR: remove that api.multi when action_confirm is migrated
- @api.multi
- def assign_picking(self):
+ def _assign_picking(self):
""" Try to assign the moves to an existing picking that has not been
reserved yet and has the same procurement group, locations and picking
type (moves should already have them identical). Otherwise, create a new
@@ -540,7 +524,6 @@ class StockMove(models.Model):
if recompute:
move.recompute()
return True
- _picking_assign = assign_picking
def _get_new_picking_values(self):
""" Prepares a new picking for this move as it could not be assigned to
@@ -554,10 +537,8 @@ class StockMove(models.Model):
'location_id': self.location_id.id,
'location_dest_id': self.location_dest_id.id,
}
- _prepare_picking_assign = _get_new_picking_values
- @api.multi
- def action_confirm(self):
+ def _action_confirm(self):
""" Confirms stock move or put it in waiting if it's linked to another move. """
move_create_proc = self.env['stock.move']
move_to_confirm = self.env['stock.move']
@@ -591,7 +572,7 @@ class StockMove(models.Model):
# assign picking in batch for all confirmed move that share the same details
for moves in to_assign.values():
- moves.assign_picking()
+ moves._assign_picking()
self._push_apply()
return self
@@ -617,25 +598,13 @@ class StockMove(models.Model):
'priority': self.priority,
}
- @api.multi
- def force_assign(self):
+ def _force_assign(self):
""" Allow to work on stock move lines even if the reservationis not possible. We just mark
the move as assigned, so the view does not block the user.
"""
for move in self.filtered(lambda m: m.state in ['confirmed', 'waiting', 'partially_available', 'assigned']):
move.write({'state': 'assigned'})
- @api.multi
- def check_tracking(self, move_line):
- """ Checks if serial number is assigned to stock move or not and raise an error if it had to. """
- # TDE FIXME: I cannot able to understand
- for move in self:
- if move.picking_id and \
- (move.picking_id.picking_type_id.use_existing_lots or move.picking_id.picking_type_id.use_create_lots) and \
- move.product_id.tracking != 'none' and \
- not (move_line and (move_line.product_id and move_line.pack_lot_ids)) or (move_line and not move_line.product_id):
- raise UserError(_('You need to provide a Lot/Serial Number for product %s') % ("%s (%s)" % (move.product_id.name, move.picking_id.name)))
-
def _prepare_move_line_vals(self, quantity=None, reserved_quant=None):
self.ensure_one()
# apply putaway
@@ -692,8 +661,7 @@ class StockMove(models.Model):
self.env['stock.move.line'].create(self._prepare_move_line_vals(quantity=quantity, reserved_quant=reserved_quant))
return taken_quantity
- @api.multi
- def action_assign(self):
+ def _action_assign(self):
""" Reserve stock moves by creating their stock move lines. A stock move is
considered reserved once the sum of `product_qty` for all its move lines is
equal to its `product_qty`. If it is less, the stock move is considered
@@ -795,17 +763,16 @@ class StockMove(models.Model):
assigned_moves.write({'state': 'assigned'})
self.mapped('picking_id')._check_entire_pack()
- @api.multi
- def action_cancel(self):
+ def _action_cancel(self):
if any(move.state == 'done' for move in self):
raise UserError(_('You cannot cancel a stock move that has been set to \'Done\'.'))
for move in self:
- move.do_unreserve()
+ move._do_unreserve()
siblings_states = (move.move_dest_ids.mapped('move_orig_ids') - move).mapped('state')
if move.propagate:
# only cancel the next move if all my siblings are also cancelled
if all(state == 'cancel' for state in siblings_states):
- move.move_dest_ids.action_cancel()
+ move.move_dest_ids._action_cancel()
else:
if all(state in ('done', 'cancel') for state in siblings_states):
move.move_dest_ids.write({'procure_method': 'make_to_stock'})
@@ -820,7 +787,6 @@ class StockMove(models.Model):
}
return vals
- @api.multi
def _create_extra_move(self):
""" If the quantity done on a move exceeds its quantity todo, this method will create an
extra move attached to a (potentially split) move line. If the previous condition is not
@@ -839,7 +805,7 @@ class StockMove(models.Model):
precision_rounding=self.product_uom.rounding,
rounding_method ='UP')
extra_move_vals = self._prepare_extra_move_vals(extra_move_quantity)
- extra_move = self.copy(default=extra_move_vals).action_confirm()
+ extra_move = self.copy(default=extra_move_vals)._action_confirm()
# link it to some move lines
for move_line in self.move_line_ids.filtered(lambda ml: ml.qty_done):
@@ -860,9 +826,8 @@ class StockMove(models.Model):
break
return extra_move
- @api.multi
- def action_done(self):
- self.filtered(lambda move: move.state == 'draft').action_confirm() # MRP allows scrapping draft moves
+ def _action_done(self):
+ self.filtered(lambda move: move.state == 'draft')._action_confirm() # MRP allows scrapping draft moves
moves = self.filtered(lambda x: x.state not in ('done', 'cancel'))
moves_todo = self.env['stock.move']
@@ -886,7 +851,7 @@ class StockMove(models.Model):
if float_compare(move.quantity_done, move.product_uom_qty, precision_rounding=rounding) < 0:
# Need to do some kind of conversion here
qty_split = move.product_uom._compute_quantity(move.product_uom_qty - move.quantity_done, move.product_id.uom_id)
- new_move = move.split(qty_split)
+ new_move = move._split(qty_split)
for move_line in move.move_line_ids:
if move_line.product_qty and move_line.qty_done:
# FIXME: there will be an issue if the move was partially available
@@ -900,10 +865,10 @@ class StockMove(models.Model):
# If you were already putting stock.move.lots on the next one in the work order, transfer those to the new move
move.move_line_ids.filtered(lambda x: x.qty_done == 0.0).write({'move_id': new_move})
self.browse(new_move).quantity_done = 0.0
- move.move_line_ids.action_done()
+ move.move_line_ids._action_done()
picking = self and self[0].picking_id or False
moves_todo.write({'state': 'done', 'date': fields.Datetime.now()})
- moves_todo.mapped('move_dest_ids').action_assign()
+ moves_todo.mapped('move_dest_ids')._action_assign()
if picking:
moves_to_backorder = picking.move_lines.filtered(lambda x: x.state not in ('done', 'cancel'))
if moves_to_backorder:
@@ -916,10 +881,9 @@ class StockMove(models.Model):
picking.message_post('Backorder Created') #message needs to be improved
moves_to_backorder.write({'picking_id': backorder_picking.id})
moves_to_backorder.mapped('move_line_ids').write({'picking_id': backorder_picking.id})
- moves_to_backorder.action_assign()
+ moves_to_backorder._action_assign()
return moves_todo
- @api.multi
def unlink(self):
if any(move.state not in ('draft', 'cancel') for move in self):
raise UserError(_('You can only delete draft moves.'))
@@ -935,8 +899,7 @@ class StockMove(models.Model):
}
return vals
- @api.multi
- def split(self, qty, restrict_partner_id=False):
+ def _split(self, qty, restrict_partner_id=False):
""" Splits qty from move move into a new move
:param qty: float. quantity to split (given in product UoM)
@@ -975,7 +938,7 @@ class StockMove(models.Model):
# new_move.write({'move_dest_id': new_move_prop})
# returning the first element of list returned by action_confirm is ok because we checked it wouldn't be exploded (and
# thus the result of action_confirm should always be a list of 1 element length)
- new_move.action_confirm()
+ new_move._action_confirm()
# TDE FIXME: due to action confirm change
return new_move.id
diff --git a/addons/stock/models/stock_move_line.py b/addons/stock/models/stock_move_line.py
index 1b3a68ec083..32a2732eede 100644
--- a/addons/stock/models/stock_move_line.py
+++ b/addons/stock/models/stock_move_line.py
@@ -76,14 +76,12 @@ class StockMoveLine(models.Model):
detect errors. """
raise UserError(_('The requested operation cannot be processed because of a programming error setting the `product_qty` field instead of the `product_uom_qty`.'))
- @api.multi
@api.constrains('product_uom_qty')
def check_reserved_done_quantity(self):
for move_line in self:
if move_line.state == 'done' and not float_is_zero(move_line.product_uom_qty, precision_rounding=self.env['decimal.precision'].precision_get('Product Unit of Measure')):
raise ValidationError(_('A done move line should never have a reserved quantity.'))
- @api.multi
@api.onchange('product_id', 'product_uom_id')
def onchange_product_id(self):
if self.product_id:
@@ -122,11 +120,10 @@ class StockMoveLine(models.Model):
Quant._update_available_quantity(ml.product_id, ml.location_id, taken_from_untracked_qty, lot_id=ml.lot_id, package_id=ml.package_id, owner_id=ml.owner_id)
Quant._update_available_quantity(ml.product_id, ml.location_dest_id, quantity, lot_id=ml.lot_id, package_id=ml.result_package_id, owner_id=ml.owner_id, in_date=in_date)
next_moves = ml.move_id.move_dest_ids.filtered(lambda move: move.state not in ('done', 'cancel'))
- next_moves.do_unreserve()
- next_moves.action_assign()
+ next_moves._do_unreserve()
+ next_moves._action_assign()
return ml
- @api.multi
def write(self, vals):
""" Through the interface, we allow users to change the charateristics of a move line. If a
quantity has been reserved for this move line, we impact the reservation directly to free
@@ -195,7 +192,7 @@ class StockMoveLine(models.Model):
new_product_uom_qty = self.product_id.uom_id._compute_quantity(new_product_qty, self.product_uom_id, rounding_method='HALF-UP')
ml.with_context(bypass_reservation_update=True).product_uom_qty = new_product_uom_qty
- # When editing a done move line, the reserved availability of a potential chained move is impacted. Take care of running again `action_assign` on the concerned moves.
+ # When editing a done move line, the reserved availability of a potential chained move is impacted. Take care of running again `_action_assign` on the concerned moves.
next_moves = self.env['stock.move']
if updates or 'qty_done' in vals:
for ml in self.filtered(lambda ml: ml.move_id.state == 'done' and ml.product_id.type == 'product'):
@@ -240,11 +237,10 @@ class StockMoveLine(models.Model):
moves = self.filtered(lambda ml: ml.move_id.state == 'done').mapped('move_id')
for move in moves:
move.product_uom_qty = move.quantity_done
- next_moves.do_unreserve()
- next_moves.action_assign()
+ next_moves._do_unreserve()
+ next_moves._action_assign()
return res
- @api.multi
def unlink(self):
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
for ml in self:
@@ -256,7 +252,7 @@ class StockMoveLine(models.Model):
package_id=ml.package_id, owner_id=ml.owner_id, strict=True)
return super(StockMoveLine, self).unlink()
- def action_done(self):
+ def _action_done(self):
""" This method is called during a move's `action_done`. It'll actually move a quant from
the source location to the destination location, and unreserve if needed in the source
location.
diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py
index 41bc40df76b..40cd8c8700f 100644
--- a/addons/stock/models/stock_picking.py
+++ b/addons/stock/models/stock_picking.py
@@ -75,7 +75,6 @@ class PickingType(models.Model):
tristates.insert(0, {'tooltip': picking.name or '' + ": " + _('OK'), 'value': 1})
self.last_done_picking = json.dumps(tristates)
- @api.multi
def _compute_picking_count(self):
# TDE TODO count picking can be done using previous two
domains = {
@@ -100,7 +99,6 @@ class PickingType(models.Model):
record.rate_picking_late = record.count_picking and record.count_picking_late * 100 / record.count_picking or 0
record.rate_picking_backorders = record.count_picking and record.count_picking_backorders * 100 / record.count_picking or 0
- @api.multi
def name_get(self):
""" Display 'Warehouse_name: PickingType_name' """
# TDE TODO remove context key support + update purchase
@@ -136,7 +134,6 @@ class PickingType(models.Model):
self.default_location_src_id = self.env.ref('stock.stock_location_stock').id
self.default_location_dest_id = self.env.ref('stock.stock_location_customers').id
- @api.multi
def _get_action(self, action_xmlid):
# TDE TODO check to have one view + custo in methods
action = self.env.ref(action_xmlid).read()[0]
@@ -144,23 +141,18 @@ class PickingType(models.Model):
action['display_name'] = self.display_name
return action
- @api.multi
def get_action_picking_tree_late(self):
return self._get_action('stock.action_picking_tree_late')
- @api.multi
def get_action_picking_tree_backorder(self):
return self._get_action('stock.action_picking_tree_backorder')
- @api.multi
def get_action_picking_tree_waiting(self):
return self._get_action('stock.action_picking_tree_waiting')
- @api.multi
def get_action_picking_tree_ready(self):
return self._get_action('stock.action_picking_tree_ready')
- @api.multi
def get_stock_picking_action_picking_type(self):
return self._get_action('stock.stock_picking_action_picking_type')
@@ -449,7 +441,7 @@ class Picking(models.Model):
@api.multi
def unlink(self):
- self.mapped('move_lines').action_cancel()
+ self.mapped('move_lines')._action_cancel()
self.mapped('move_lines').unlink() # Checks if moves are not done
return super(Picking, self).unlink()
@@ -467,14 +459,14 @@ class Picking(models.Model):
@api.multi
def action_confirm(self):
- # call `action_confirm` on every draft move
+ # call `_action_confirm` on every draft move
self.mapped('move_lines')\
.filtered(lambda move: move.state == 'draft')\
- .action_confirm()
- # call `action_assign` on every confirmed move which location_id bypasses the reservation
+ ._action_confirm()
+ # call `_action_assign` on every confirmed move which location_id bypasses the reservation
self.filtered(lambda picking: picking.location_id.usage in ('supplier', 'inventory', 'production'))\
.filtered(lambda move: move.state == 'confirmed')\
- .mapped('move_lines').action_assign()
+ .mapped('move_lines')._action_assign()
return True
@api.multi
@@ -488,7 +480,7 @@ class Picking(models.Model):
moves = self.mapped('move_lines').filtered(lambda move: move.state not in ('draft', 'cancel', 'done'))
if not moves:
raise UserError(_('Nothing to check the availability for.'))
- moves.action_assign()
+ moves._action_assign()
return True
@api.multi
@@ -496,12 +488,12 @@ class Picking(models.Model):
""" Changes state of picking to available if moves are confirmed or waiting.
@return: True
"""
- self.mapped('move_lines').filtered(lambda move: move.state in ['confirmed', 'waiting', 'partially_available']).force_assign()
+ self.mapped('move_lines').filtered(lambda move: move.state in ['confirmed', 'waiting', 'partially_available'])._force_assign()
return True
@api.multi
def action_cancel(self):
- self.mapped('move_lines').action_cancel()
+ self.mapped('move_lines')._action_cancel()
return True
@api.multi
@@ -548,10 +540,10 @@ class Picking(models.Model):
'picking_id': pick.id,
})
ops.move_id = new_move.id
- new_move.action_confirm()
+ new_move._action_confirm()
todo_moves |= new_move
#'qty_done': ops.qty_done})
- todo_moves.action_done()
+ todo_moves._action_done()
self.write({'date_done': fields.Datetime.now()})
return True
@@ -584,7 +576,7 @@ class Picking(models.Model):
def do_unreserve(self):
for move in self:
for move_line in move.move_lines:
- move_line.do_unreserve()
+ move_line._do_unreserve()
self.write({'state': 'confirmed'})
@api.multi
@@ -627,13 +619,11 @@ class Picking(models.Model):
}
# Check backorder should check for other barcodes
- if self.check_backorder():
+ if self._check_backorder():
return self.action_generate_backorder_wizard()
self.action_done()
return
- do_new_transfer = button_validate #TODO: replace later
-
def action_generate_backorder_wizard(self):
view = self.env.ref('stock.view_backorder_confirmation')
wiz = self.env['stock.backorder.confirmation'].create({'pick_id': self.id})
@@ -654,7 +644,7 @@ class Picking(models.Model):
self.is_locked = not self.is_locked
return True
- def check_backorder(self):
+ def _check_backorder(self):
self.ensure_one()
quantity_todo = {}
quantity_done = {}
@@ -685,7 +675,7 @@ class Picking(models.Model):
vals = self._prepare_values_extra_move(move_line, product, remaining_qty)
moves |= moves.create(vals)
if moves:
- moves.with_context(skip_check=True).action_confirm()
+ moves.with_context(skip_check=True)._action_confirm()
return moves
@api.model
@@ -722,7 +712,6 @@ class Picking(models.Model):
'group_id': picking.group_id.id,
}
- @api.multi
def _create_backorder(self, backorder_moves=[]):
""" Move all non-done lines into a new backorder picking. If the key 'do_only_split' is given in the context, then move all lines not in context.get('split', []) instead of all non-done lines.
"""
@@ -751,7 +740,6 @@ class Picking(models.Model):
backorders |= backorder_picking
return backorders
- @api.multi
def _put_in_pack(self):
package = False
for pick in self:
@@ -777,11 +765,9 @@ class Picking(models.Model):
raise UserError(_('Please process some quantities to put in the pack first!'))
return package
- @api.multi
def put_in_pack(self):
return self._put_in_pack()
- @api.multi
def button_scrap(self):
self.ensure_one()
return {
@@ -795,7 +781,6 @@ class Picking(models.Model):
'target': 'new',
}
- @api.multi
def action_see_move_scrap(self):
self.ensure_one()
action = self.env.ref('stock.action_stock_scrap').read()[0]
@@ -803,7 +788,6 @@ class Picking(models.Model):
action['domain'] = [('id', 'in', scraps.ids)]
return action
- @api.multi
def action_see_packages(self):
self.ensure_one()
action = self.env.ref('stock.action_package_view').read()[0]
diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py
index 26eddffce30..0e2c6d549c5 100644
--- a/addons/stock/models/stock_quant.py
+++ b/addons/stock/models/stock_quant.py
@@ -48,7 +48,6 @@ class StockQuant(models.Model):
readonly=True, required=True)
in_date = fields.Datetime('Incoming Date', readonly=True)
- @api.multi
def action_view_stock_moves(self):
self.ensure_one()
action = self.env.ref('stock.stock_move_line_action').read()[0]
@@ -60,20 +59,17 @@ class StockQuant(models.Model):
('package_id', '=', self.package_id.id)]
return action
- @api.multi
@api.constrains('product_id')
def check_product_id(self):
if any(elem.product_id.type != 'product' for elem in self):
raise ValidationError(_('Quants cannot be created for consumables or services.'))
- @api.multi
@api.constrains('quantity')
def check_quantity(self):
for quant in self:
if quant.quantity > 1 and quant.lot_id and quant.product_id.tracking == 'serial':
raise ValidationError(_('A serial number should only be linked to a single product.'))
- @api.multi
@api.constrains('in_date', 'lot_id')
def check_in_date(self):
for quant in self:
@@ -304,7 +300,6 @@ class QuantPackage(models.Model):
package.company_id = values['company_id']
package.owner_id = values['owner_id']
- @api.multi
def name_get(self):
return list(self._compute_complete_name().items())
@@ -325,7 +320,6 @@ class QuantPackage(models.Model):
self.current_picking_move_line_ids = False
self.current_picking_id = False
-
def _search_location(self, operator, value):
if value:
packs = self.search([('quant_ids.location_id', operator, value)])
@@ -367,7 +361,6 @@ class QuantPackage(models.Model):
raise UserError(_('Everything inside a package should be in the same location'))
return True
- @api.multi
def unpack(self):
for package in self:
move_lines_to_remove = self.move_line_ids.filtered(lambda move_line: move_line.state != 'done')
@@ -382,16 +375,13 @@ class QuantPackage(models.Model):
action['domain'] = [('id', 'in', pickings.ids)]
return action
- @api.multi
def view_content_package(self):
action = self.env['ir.actions.act_window'].for_xml_id('stock', 'quantsact')
action['domain'] = [('id', 'in', self._get_contained_quants().ids)]
return action
- get_content_package = view_content_package
def _get_contained_quants(self):
return self.env['stock.quant'].search([('package_id', 'child_of', self.ids)])
- get_content = _get_contained_quants
def _get_all_products_quantities(self):
'''This function computes the different product quantities for the given package
diff --git a/addons/stock/models/stock_scrap.py b/addons/stock/models/stock_scrap.py
index 4eba509a8de..ff60d32361f 100644
--- a/addons/stock/models/stock_scrap.py
+++ b/addons/stock/models/stock_scrap.py
@@ -66,7 +66,6 @@ class StockScrap(models.Model):
scrap.do_scrap()
return scrap
- @api.multi
def unlink(self):
if 'done' in self.mapped('state'):
raise UserError(_('You cannot delete a scrap which is done.'))
@@ -75,7 +74,6 @@ class StockScrap(models.Model):
def _get_origin_moves(self):
return self.picking_id and self.picking_id.move_lines.filtered(lambda x: x.product_id == self.product_id)
- @api.multi
def do_scrap(self):
for scrap in self:
move = self.env['stock.move'].create(scrap._prepare_move_values())
@@ -89,7 +87,7 @@ class StockScrap(models.Model):
]).mapped('quantity'))
if quantity_in_stock < move.product_qty: # FIXME: float compare
raise UserError(_('You cannot scrap a move without having available stock for %s. You can correct it with an inventory adjustment.') % move.product_id.name)
- move.action_done()
+ move._action_done()
scrap.write({'move_id': move.id, 'state': 'done'})
return True
@@ -116,18 +114,12 @@ class StockScrap(models.Model):
'picking_id': self.picking_id.id
}
- @api.multi
def action_get_stock_picking(self):
action = self.env.ref('stock.action_picking_tree_all').read([])[0]
action['domain'] = [('id', '=', self.picking_id.id)]
return action
- @api.multi
def action_get_stock_move(self):
action = self.env.ref('stock.stock_move_action').read([])[0]
action['domain'] = [('id', '=', self.move_id.id)]
return action
-
- @api.multi
- def action_done(self):
- return {'type': 'ir.actions.act_window_close'}
diff --git a/addons/stock/models/stock_traceability.py b/addons/stock/models/stock_traceability.py
index a03ae146990..b6213ce76ac 100644
--- a/addons/stock/models/stock_traceability.py
+++ b/addons/stock/models/stock_traceability.py
@@ -292,7 +292,6 @@ class MrpStockReport(models.TransientModel):
final_vals += self.make_dict_head(level, model=model, stream=stream, parent_id=parent_id, move_line=line)
return final_vals
- @api.multi
def get_pdf_lines(self, line_data=[]):
final_vals = []
lines = []
diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py
index b0e407f3e23..38025779ea0 100644
--- a/addons/stock/models/stock_warehouse.py
+++ b/addons/stock/models/stock_warehouse.py
@@ -118,7 +118,6 @@ class Warehouse(models.Model):
self._update_partner_data(vals['partner_id'], vals.get('company_id'))
return warehouse
- @api.multi
def write(self, vals):
Route = self.env['stock.location.route']
warehouses = self.with_context(active_test=False) # TDE FIXME: check this
@@ -251,7 +250,6 @@ class Warehouse(models.Model):
PickingType.browse(warehouse_data['in_type_id']).write({'return_picking_type_id': warehouse_data['out_type_id']})
return warehouse_data
- @api.multi
def create_routes(self):
self.ensure_one()
routes_data = self.get_routes_dict()
@@ -459,7 +457,6 @@ class Warehouse(models.Model):
self.Routing(warehouse.wh_output_stock_loc_id, customer_loc, warehouse.out_type_id)],
}) for warehouse in self)
- @api.multi
def _get_reception_delivery_route_values(self, route_type):
return {
'name': self._format_routename(route_type=route_type),
@@ -499,7 +496,6 @@ class Warehouse(models.Model):
# Pull / Push tools
# ------------------------------------------------------------
- @api.multi
def _get_push_pull_rules_values(self, route_values, values=None, push_values=None, pull_values=None, name_suffix=''):
first_rule = True
push_rules_list, pull_rules_list = [], []
@@ -584,7 +580,6 @@ class Warehouse(models.Model):
'&', ('route_id', 'in', routes.ids),
('location_src_id.usage', '=', 'transit')]).write({'location_id': new_location.id})
- @api.multi
def _update_routes(self):
routes_data = self.get_routes_dict()
# change the default source and destination location and (de)activate operation types
@@ -601,7 +596,6 @@ class Warehouse(models.Model):
for field_name, values in picking_type_values.items():
self[field_name].write(values)
- @api.multi
def _update_name_and_code(self, new_name=False, new_code=False):
if new_code:
self.mapped('lot_stock_id').mapped('location_id').write({'name': new_code})
@@ -688,18 +682,15 @@ class Warehouse(models.Model):
'int_type_id': {'name': self.name + _('Sequence internal'), 'prefix': self.code + '/INT/', 'padding': 5},
}
- @api.multi
def _format_rulename(self, from_loc, dest_loc, suffix):
return '%s: %s -> %s%s' % (self.code, from_loc.name, dest_loc.name, suffix)
- @api.multi
def _format_routename(self, name=None, route_type=None):
if route_type:
name = self._get_route_name(route_type)
return '%s: %s' % (self.name, name)
@api.returns('self')
- @api.multi
def _get_all_routes(self):
# TDE FIXME: check overrides
routes = self.mapped('route_ids') | self.mapped('mto_pull_id').mapped('route_id')
@@ -707,7 +698,6 @@ class Warehouse(models.Model):
return routes
get_all_routes_for_wh = _get_all_routes
- @api.multi
def action_view_all_routes(self):
routes = self._get_all_routes()
return {
@@ -786,7 +776,6 @@ class Orderpoint(models.Model):
('qty_multiple_check', 'CHECK( qty_multiple >= 0 )', 'Qty Multiple must be greater than or equal to zero.'),
]
- @api.multi
def _quantity_in_progress(self):
"""Return Quantities that are not yet in virtual stock but should be deduced from orderpoint rule
(example: purchases created from orderpoints)"""
@@ -822,7 +811,6 @@ class Orderpoint(models.Model):
date_planned = start_date + relativedelta.relativedelta(days=days)
return date_planned.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
- @api.multi
def _prepare_procurement_values(self, product_qty, date=False, group=False):
""" Prepare specific key for moves or other components that will be created from a procurement rule
comming from an orderpoint. This method could be override in order to add other custom key that could
diff --git a/addons/stock/tests/test_inventory.py b/addons/stock/tests/test_inventory.py
index 2cbd909e064..f0a2901860a 100644
--- a/addons/stock/tests/test_inventory.py
+++ b/addons/stock/tests/test_inventory.py
@@ -37,7 +37,7 @@ class TestInventory(TransactionCase):
'location_id': self.stock_location.id,
'product_id': self.product1.id,
})
- inventory.prepare_inventory()
+ inventory.action_start()
self.assertEqual(len(inventory.line_ids), 1)
self.assertEqual(inventory.line_ids.theoretical_qty, 100)
inventory.line_ids.product_qty = 0 # Put the quantity back to 0
@@ -57,7 +57,7 @@ class TestInventory(TransactionCase):
'product_id': self.product2.id,
'exhausted': True, # should be set by an onchange
})
- inventory.prepare_inventory()
+ inventory.action_start()
self.assertEqual(len(inventory.line_ids), 1)
self.assertEqual(inventory.line_ids.theoretical_qty, 0)
@@ -87,7 +87,7 @@ class TestInventory(TransactionCase):
'product_id': self.product2.id,
'exhausted': True, # should be set by an onchange
})
- inventory.prepare_inventory()
+ inventory.action_start()
self.assertEqual(len(inventory.line_ids), 1)
self.assertEqual(inventory.line_ids.theoretical_qty, 0)
@@ -113,7 +113,7 @@ class TestInventory(TransactionCase):
'product_id': self.product2.id,
'exhausted': True, # should be set by an onchange
})
- inventory.prepare_inventory()
+ inventory.action_start()
self.assertEqual(len(inventory.line_ids), 1)
self.assertEqual(inventory.line_ids.theoretical_qty, 0)
@@ -154,7 +154,7 @@ class TestInventory(TransactionCase):
'product_id': self.product1.id,
'exhausted': True,
})
- inventory.prepare_inventory()
+ inventory.action_start()
self.assertEqual(len(inventory.line_ids), 1)
self.assertEqual(inventory.line_ids.theoretical_qty, 0)
inventory.line_ids.partner_id = owner1
diff --git a/addons/stock/tests/test_move.py b/addons/stock/tests/test_move.py
index 07bb1261d13..a55321448a1 100644
--- a/addons/stock/tests/test_move.py
+++ b/addons/stock/tests/test_move.py
@@ -56,11 +56,11 @@ class StockMove(TransactionCase):
self.assertEqual(move1.state, 'draft')
# confirmation
- move1.action_confirm()
+ move1._action_confirm()
self.assertEqual(move1.state, 'confirmed')
# assignment
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(len(move1.move_line_ids), 1)
@@ -71,7 +71,7 @@ class StockMove(TransactionCase):
move_line.qty_done = 100.0
# validation
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.state, 'done')
# no quants are created in the supplier location
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.supplier_location), 0.0)
@@ -98,11 +98,11 @@ class StockMove(TransactionCase):
self.assertEqual(move1.state, 'draft')
# confirmation
- move1.action_confirm()
+ move1._action_confirm()
self.assertEqual(move1.state, 'confirmed')
# assignment
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(len(move1.move_line_ids), 1)
move_line = move1.move_line_ids[0]
@@ -111,7 +111,7 @@ class StockMove(TransactionCase):
move_line.qty_done = 5.0
self.assertEqual(move_line.product_qty, 5) # don't change reservation
- move1.action_done()
+ move1._action_done()
self.assertEqual(move_line.product_qty, 0) # change reservation to 0 for done move
self.assertEqual(move1.state, 'done')
@@ -143,11 +143,11 @@ class StockMove(TransactionCase):
self.assertEqual(move1.state, 'draft')
# confirmation
- move1.action_confirm()
+ move1._action_confirm()
self.assertEqual(move1.state, 'confirmed')
# assignment
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(len(move1.move_line_ids), 5)
move_line = move1.move_line_ids[0]
@@ -161,7 +161,7 @@ class StockMove(TransactionCase):
self.assertEqual(move1.quantity_done, 5.0)
self.assertEqual(move1.product_qty, 5) # don't change reservation
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.quantity_done, 5.0)
self.assertEqual(move1.product_qty, 5) # don't change reservation
@@ -200,11 +200,11 @@ class StockMove(TransactionCase):
self.assertEqual(move1.state, 'draft')
# confirmation
- move1.action_confirm()
+ move1._action_confirm()
self.assertEqual(move1.state, 'confirmed')
# assignment
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(len(move1.move_line_ids), 1)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0)
@@ -218,7 +218,7 @@ class StockMove(TransactionCase):
move_line.qty_done = 100.0
# validation
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.state, 'done')
# Check there is one quant in customer location
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.customer_location), 100.0)
@@ -249,11 +249,11 @@ class StockMove(TransactionCase):
self.assertEqual(move1.state, 'draft')
# confirmation
- move1.action_confirm()
+ move1._action_confirm()
self.assertEqual(move1.state, 'confirmed')
# assignment
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(len(move1.move_line_ids), 1)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0)
@@ -267,7 +267,7 @@ class StockMove(TransactionCase):
move_line.qty_done = 100.0
# validation
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.state, 'done')
# no quants are created in the customer location since it's a consumable
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.customer_location), 0.0)
@@ -298,8 +298,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 5.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(len(move1.move_line_ids), 2)
@@ -330,8 +330,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 4.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(len(move1.move_line_ids), 4)
for ml in move1.move_line_ids:
self.assertEqual(ml.product_qty, 1.0)
@@ -360,7 +360,7 @@ class StockMove(TransactionCase):
move1.move_line_ids.write({'qty_done': 1.0})
- move1.action_done()
+ move1._action_done()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location), 0.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location, lot_id=lot1, strict=True), 0.0)
@@ -395,10 +395,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 2.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.write({'qty_done': 1.0})
- move1.action_done()
+ move1._action_done()
self.env['stock.quant']._update_available_quantity(self.product2, self.stock_location, 2)
lot3 = self.env['stock.production.lot'].create({
@@ -462,10 +462,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 2.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.write({'qty_done': 1.0})
- move1.action_done()
+ move1._action_done()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location), 0.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location, lot_id=lot1, strict=True), 0.0)
@@ -493,8 +493,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(move1.state, 'confirmed')
# create an untracked quant
@@ -518,7 +518,7 @@ class StockMove(TransactionCase):
self.assertEqual(move1.reserved_availability, 0)
# validating the move line should move the lot, not create a negative quant in stock
- move1.action_done()
+ move1._action_done()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location), 0.0)
self.assertEqual(len(self.env['stock.quant']._gather(self.product2, self.stock_location)), 0.0)
@@ -533,8 +533,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
lot1 = self.env['stock.production.lot'].create({
@@ -554,7 +554,7 @@ class StockMove(TransactionCase):
move_line.qty_done = 1
# validating the move line should move the lot, not create a negative quant in stock
- move1.action_done()
+ move1._action_done()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location), 0.0)
self.assertEqual(len(self.env['stock.quant']._gather(self.product2, self.stock_location)), 0.0)
@@ -585,8 +585,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 2.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(len(move1.move_line_ids), 2)
for ml in move1.move_line_ids:
self.assertEqual(ml.product_qty, 1.0)
@@ -597,7 +597,7 @@ class StockMove(TransactionCase):
move1.move_line_ids.write({'qty_done': 1.0})
- move1.action_done()
+ move1._action_done()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location), 0.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location, lot_id=lot1, strict=True), 0.0)
@@ -636,11 +636,11 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 100.0,
})
- move1.action_confirm()
+ move1._action_confirm()
self.assertEqual(move1.state, 'confirmed')
# assignment
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(len(move1.move_line_ids), 1)
@@ -708,8 +708,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(move1.reserved_availability, 1.0)
@@ -734,17 +734,17 @@ class StockMove(TransactionCase):
self.assertEqual(move1.availability, 100.0)
# confirmation
- move1.action_confirm()
+ move1._action_confirm()
self.assertEqual(move1.state, 'confirmed')
# assignment
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(len(move1.move_line_ids), 1)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 50.0)
# unreserve
- move1.do_unreserve()
+ move1._do_unreserve()
self.assertEqual(len(move1.move_line_ids), 0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 150.0)
self.assertEqual(move1.state, 'confirmed')
@@ -772,17 +772,17 @@ class StockMove(TransactionCase):
self.assertEqual(move1.availability, 100.0)
# confirmation
- move1.action_confirm()
+ move1._action_confirm()
self.assertEqual(move1.state, 'confirmed')
# assignment
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(len(move1.move_line_ids), 1)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, package_id=package1), 50.0)
# unreserve
- move1.do_unreserve()
+ move1._do_unreserve()
self.assertEqual(len(move1.move_line_ids), 0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, package_id=package1), 150.0)
self.assertEqual(move1.state, 'confirmed')
@@ -807,11 +807,11 @@ class StockMove(TransactionCase):
self.assertEqual(move1.state, 'draft')
# confirmation
- move1.action_confirm()
+ move1._action_confirm()
self.assertEqual(move1.state, 'confirmed')
# assignment
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(len(move1.move_line_ids), 1)
@@ -821,7 +821,7 @@ class StockMove(TransactionCase):
self.assertEqual(quants.quantity, 2.0)
self.assertEqual(quants.reserved_quantity, 2.0)
- move1.do_unreserve()
+ move1._do_unreserve()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 2.0)
self.assertEqual(len(quants), 1.0)
self.assertEqual(quants.quantity, 2.0)
@@ -848,11 +848,11 @@ class StockMove(TransactionCase):
self.assertEqual(move1.state, 'draft')
# confirmation
- move1.action_confirm()
+ move1._action_confirm()
self.assertEqual(move1.state, 'confirmed')
# assignment
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'partially_available')
self.assertEqual(len(move1.move_line_ids), 1)
@@ -862,7 +862,7 @@ class StockMove(TransactionCase):
self.assertEqual(quants.quantity, 2.0)
self.assertEqual(quants.reserved_quantity, 2.0)
- move1.do_unreserve()
+ move1._do_unreserve()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 2.0)
self.assertEqual(len(quants), 1.0)
self.assertEqual(quants.quantity, 2.0)
@@ -894,14 +894,14 @@ class StockMove(TransactionCase):
self.assertEqual(move1.state, 'draft')
# confirmation
- move1.action_confirm()
+ move1._action_confirm()
self.assertEqual(move1.state, 'confirmed')
# assignment
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(len(move1.move_line_ids), 1)
- move1.do_unreserve()
+ move1._do_unreserve()
quants = self.env['stock.quant']._gather(self.product1, self.stock_location)
self.assertEqual(len(quants), 2.0)
@@ -935,10 +935,10 @@ class StockMove(TransactionCase):
move_stock_pack.write({'move_dest_ids': [(4, move_pack_cust.id, 0)]})
move_pack_cust.write({'move_orig_ids': [(4, move_stock_pack.id, 0)]})
- (move_stock_pack + move_pack_cust).action_confirm()
- move_stock_pack.action_assign()
+ (move_stock_pack + move_pack_cust)._action_confirm()
+ move_stock_pack._action_assign()
move_stock_pack.move_line_ids[0].qty_done = 1.0
- move_stock_pack.action_done()
+ move_stock_pack._action_done()
self.assertEqual(len(move_pack_cust.move_line_ids), 1)
move_line = move_pack_cust.move_line_ids[0]
self.assertEqual(move_line.location_id.id, self.pack_location.id)
@@ -977,8 +977,8 @@ class StockMove(TransactionCase):
move_stock_pack.write({'move_dest_ids': [(4, move_pack_cust.id, 0)]})
move_pack_cust.write({'move_orig_ids': [(4, move_stock_pack.id, 0)]})
- (move_stock_pack + move_pack_cust).action_confirm()
- move_stock_pack.action_assign()
+ (move_stock_pack + move_pack_cust)._action_confirm()
+ move_stock_pack._action_assign()
move_line_stock_pack = move_stock_pack.move_line_ids[0]
self.assertEqual(move_line_stock_pack.lot_id.id, lot1.id)
@@ -987,7 +987,7 @@ class StockMove(TransactionCase):
self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.pack_location, lot1)), 0.0)
move_line_stock_pack.qty_done = 1.0
- move_stock_pack.action_done()
+ move_stock_pack._action_done()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, lot_id=lot1), 0.0)
self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.stock_location, lot1)), 0.0)
@@ -1032,14 +1032,14 @@ class StockMove(TransactionCase):
move_stock_pack_2.write({'move_dest_ids': [(4, move_pack_cust.id, 0)]})
move_pack_cust.write({'move_orig_ids': [(4, [move_stock_pack_1.id, move_stock_pack_2.id], 0)]})
- (move_stock_pack_1 + move_stock_pack_2 + move_pack_cust).action_confirm()
+ (move_stock_pack_1 + move_stock_pack_2 + move_pack_cust)._action_confirm()
# assign and fulfill the first move
- move_stock_pack_1.action_assign()
+ move_stock_pack_1._action_assign()
self.assertEqual(move_stock_pack_1.state, 'assigned')
self.assertEqual(len(move_stock_pack_1.move_line_ids), 1)
move_stock_pack_1.move_line_ids[0].qty_done = 1.0
- move_stock_pack_1.action_done()
+ move_stock_pack_1._action_done()
self.assertEqual(move_stock_pack_1.state, 'done')
# the destination move should be partially available and have one move line
@@ -1049,11 +1049,11 @@ class StockMove(TransactionCase):
self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.stock_location)), 1.0)
self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.pack_location)), 1.0)
- move_stock_pack_2.action_assign()
+ move_stock_pack_2._action_assign()
self.assertEqual(move_stock_pack_2.state, 'assigned')
self.assertEqual(len(move_stock_pack_2.move_line_ids), 1)
move_stock_pack_2.move_line_ids[0].qty_done = 1.0
- move_stock_pack_2.action_done()
+ move_stock_pack_2._action_done()
self.assertEqual(move_stock_pack_2.state, 'done')
self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.stock_location)), 0.0)
@@ -1108,23 +1108,23 @@ class StockMove(TransactionCase):
move_stock_pack_2.write({'move_dest_ids': [(4, move_pack_cust.id, 0)]})
move_pack_cust.write({'move_orig_ids': [(4, [move_stock_pack_1.id, move_stock_pack_2.id], 0)]})
- (move_stock_pack_1 + move_stock_pack_2 + move_pack_cust).action_confirm()
+ (move_stock_pack_1 + move_stock_pack_2 + move_pack_cust)._action_confirm()
# assign and fulfill the first move
- move_stock_pack_1.action_assign()
+ move_stock_pack_1._action_assign()
self.assertEqual(len(move_stock_pack_1.move_line_ids), 1)
self.assertEqual(move_stock_pack_1.move_line_ids[0].lot_id.id, lot1.id)
move_stock_pack_1.move_line_ids[0].qty_done = 1.0
- move_stock_pack_1.action_done()
+ move_stock_pack_1._action_done()
# the destination move should be partially available and have one move line
self.assertEqual(len(move_pack_cust.move_line_ids), 1)
- move_stock_pack_2.action_assign()
+ move_stock_pack_2._action_assign()
self.assertEqual(len(move_stock_pack_2.move_line_ids), 1)
self.assertEqual(move_stock_pack_2.move_line_ids[0].lot_id.id, lot1.id)
move_stock_pack_2.move_line_ids[0].qty_done = 1.0
- move_stock_pack_2.action_done()
+ move_stock_pack_2._action_done()
self.assertEqual(len(move_pack_cust.move_line_ids), 1)
move_line_1 = move_pack_cust.move_line_ids[0]
@@ -1169,13 +1169,13 @@ class StockMove(TransactionCase):
move_pack_cust_1.write({'move_orig_ids': [(4, move_stock_pack.id, 0)]})
move_pack_cust_2.write({'move_orig_ids': [(4, move_stock_pack.id, 0)]})
- (move_stock_pack + move_pack_cust_1 + move_pack_cust_2).action_confirm()
+ (move_stock_pack + move_pack_cust_1 + move_pack_cust_2)._action_confirm()
# assign and fulfill the first move
- move_stock_pack.action_assign()
+ move_stock_pack._action_assign()
self.assertEqual(len(move_stock_pack.move_line_ids), 1)
move_stock_pack.move_line_ids[0].qty_done = 2.0
- move_stock_pack.action_done()
+ move_stock_pack._action_done()
# the destination moves should be available and have one move line
self.assertEqual(len(move_pack_cust_1.move_line_ids), 1)
@@ -1183,7 +1183,7 @@ class StockMove(TransactionCase):
move_pack_cust_1.move_line_ids[0].qty_done = 1.0
move_pack_cust_2.move_line_ids[0].qty_done = 1.0
- (move_pack_cust_1 + move_pack_cust_2).action_done()
+ (move_pack_cust_1 + move_pack_cust_2)._action_done()
def test_link_assign_6(self):
""" Test the assignment mechanism when four chained stock moves (2 sources, 2 dest) try to
@@ -1225,8 +1225,8 @@ class StockMove(TransactionCase):
})
move_stock_stock_2.write({'move_orig_ids': [(4, [move_supp_stock_1.id, move_supp_stock_2.id], 0)]})
- (move_supp_stock_1 + move_supp_stock_2 + move_stock_stock_1 + move_stock_stock_2).action_confirm()
- move_supp_stock_1.action_assign()
+ (move_supp_stock_1 + move_supp_stock_2 + move_stock_stock_1 + move_stock_stock_2)._action_confirm()
+ move_supp_stock_1._action_assign()
self.assertEqual(move_supp_stock_1.state, 'assigned')
self.assertEqual(move_supp_stock_2.state, 'confirmed')
self.assertEqual(move_stock_stock_1.state, 'waiting')
@@ -1236,7 +1236,7 @@ class StockMove(TransactionCase):
# do the fist move, it'll bring 3 units in stock location so only `move_stock_stock_1`
# should be assigned
move_supp_stock_1.move_line_ids.qty_done = 3.0
- move_supp_stock_1.action_done()
+ move_supp_stock_1._action_done()
self.assertEqual(move_supp_stock_1.state, 'done')
self.assertEqual(move_supp_stock_2.state, 'confirmed')
self.assertEqual(move_stock_stock_1.state, 'assigned')
@@ -1269,15 +1269,15 @@ class StockMove(TransactionCase):
# reserve those move
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0)
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
self.assertEqual(move2.state, 'confirmed')
# force assign the second one
- move2.force_assign()
+ move2._force_assign()
self.assertEqual(move2.state, 'assigned')
# use the product from the first one
@@ -1292,7 +1292,7 @@ class StockMove(TransactionCase):
'location_id': move2.location_id.id,
'location_dest_id': move2.location_dest_id.id,
})]})
- move2.action_done()
+ move2._action_done()
# the first move should go back to confirmed
self.assertEqual(move1.state, 'confirmed')
@@ -1330,15 +1330,15 @@ class StockMove(TransactionCase):
# reserve those move
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, lot_id=lot1), 1.0)
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
self.assertEqual(move2.state, 'confirmed')
# force assign the second one
- move2.force_assign()
+ move2._force_assign()
self.assertEqual(move2.state, 'assigned')
# use the product from the first one
@@ -1353,7 +1353,7 @@ class StockMove(TransactionCase):
'location_id': move2.location_id.id,
'location_dest_id': move2.location_dest_id.id,
})]})
- move2.action_done()
+ move2._action_done()
# the first move should go back to confirmed
self.assertEqual(move1.state, 'confirmed')
@@ -1388,8 +1388,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf1_location), 0.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf2_location), 1.0)
@@ -1428,8 +1428,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(move1.reserved_availability, 1.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0)
@@ -1464,8 +1464,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, package_id=package1), 0.0)
@@ -1499,8 +1499,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, owner_id=owner1), 0.0)
@@ -1542,8 +1542,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, lot_id=lot1, package_id=package1), 0.0)
@@ -1584,8 +1584,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf1_location), 0.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf2_location), 0.0)
@@ -1624,11 +1624,11 @@ class StockMove(TransactionCase):
self.assertEqual(move1.state, 'draft')
# confirmation
- move1.action_confirm()
+ move1._action_confirm()
self.assertEqual(move1.state, 'confirmed')
# assignment
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(len(move1.move_line_ids), 1)
move_line = move1.move_line_ids[0]
@@ -1638,7 +1638,7 @@ class StockMove(TransactionCase):
move_line.with_context(debug=True).lot_id = lot1
self.assertEqual(move_line.product_qty, 5) # don't change reservation when assgning a lot now
- move1.action_done()
+ move1._action_done()
self.assertEqual(move_line.product_qty, 0) # change reservation to 0 for done move
self.assertEqual(move1.state, 'done')
@@ -1677,11 +1677,11 @@ class StockMove(TransactionCase):
self.assertEqual(move1.state, 'draft')
# confirmation
- move1.action_confirm()
+ move1._action_confirm()
self.assertEqual(move1.state, 'confirmed')
# assignment
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(len(move1.move_line_ids), 2)
@@ -1702,7 +1702,7 @@ class StockMove(TransactionCase):
untracked_move_line.qty_done = 3
self.assertEqual(untracked_move_line.product_qty, 3) # don't change reservation
- move1.action_done()
+ move1._action_done()
self.assertEqual(untracked_move_line.product_qty, 0) # change reservation to 0 for done move
self.assertEqual(tracked_move_line.product_qty, 0) # change reservation to 0 for done move
self.assertEqual(move1.state, 'done')
@@ -1744,10 +1744,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 1
- move1.action_done()
+ move1._action_done()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf1_location), 0.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf2_location), 1.0)
@@ -1786,10 +1786,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 1
- move1.action_done()
+ move1._action_done()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, lot_id=lot1), 0.0)
@@ -1824,10 +1824,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 1
- move1.action_done()
+ move1._action_done()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, package_id=package1), 0.0)
@@ -1860,10 +1860,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 1
- move1.action_done()
+ move1._action_done()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, owner_id=owner1), 0.0)
@@ -1904,10 +1904,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 1
- move1.action_done()
+ move1._action_done()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, lot_id=lot1, package_id=package1), 0.0)
@@ -1947,10 +1947,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 1
- move1.action_done()
+ move1._action_done()
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf1_location), 0.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf2_location), 0.0)
@@ -1993,10 +1993,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 1
- move1.action_done()
+ move1._action_done()
move2 = self.env['stock.move'].create({
'name': 'test_edit_moveline_1',
@@ -2006,8 +2006,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
self.assertEqual(move2.state, 'assigned')
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf1_location), 0.0)
@@ -2044,10 +2044,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 1
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.product_uom_qty, 1.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf1_location), 0.0)
@@ -2084,10 +2084,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 1
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.product_uom_qty, 1.0)
self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf1_location), 0.0)
@@ -2113,10 +2113,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 10.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 10
- move1.action_done()
+ move1._action_done()
quant = self.env['stock.quant']._gather(self.product1, self.stock_location)
self.assertEqual(len(quant), 1.0)
@@ -2359,12 +2359,12 @@ class StockMove(TransactionCase):
picking = self._create_picking_test_immediate_validate_5(picking_type_id, product_id)
# should raise because no serial numbers were specified
- self.assertRaises(UserError, picking.do_new_transfer)
+ self.assertRaises(UserError, picking.button_validate)
picking_type_id.use_create_lots = False
picking_type_id.use_existing_lots = False
picking = self._create_picking_test_immediate_validate_5(picking_type_id, product_id)
- picking.do_new_transfer()
+ picking.button_validate()
self.assertEqual(picking.state, 'done')
def test_immediate_validate_5(self):
@@ -2439,8 +2439,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 2.0,
})
- (move1 + move2).action_confirm()
- (move1 + move2).force_assign()
+ (move1 + move2)._action_confirm()
+ (move1 + move2)._force_assign()
(move1 + move2).write({'quantity_done': 1})
self.assertEqual(move1.quantity_done, 1)
self.assertEqual(move2.quantity_done, 1)
@@ -2509,8 +2509,8 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(len(move1.move_line_ids), 1)
@@ -2535,11 +2535,11 @@ class StockMove(TransactionCase):
'product_uom_qty': 1.0,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.lot_name = 'lot1'
move1.move_line_ids.qty_done = 1
- move1.action_done()
+ move1._action_done()
quant = self.env['stock.quant']._gather(self.product3, self.stock_location)
self.assertEqual(len(quant), 1.0)
@@ -2556,10 +2556,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
move2.move_line_ids.qty_done = 1
- move2.action_done()
+ move2._action_done()
quant = self.env['stock.quant']._gather(self.product3, self.pack_location)
self.assertEqual(len(quant), 1.0)
@@ -2588,11 +2588,11 @@ class StockMove(TransactionCase):
'product_uom_qty': 1.0,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.lot_id = lot1
move1.move_line_ids.qty_done = 1
- move1.action_done()
+ move1._action_done()
# receive lot2
move2 = self.env['stock.move'].create({
@@ -2604,11 +2604,11 @@ class StockMove(TransactionCase):
'product_uom_qty': 1.0,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
})
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
move2.move_line_ids.lot_id = lot2
move2.move_line_ids.qty_done = 1
- move2.action_done()
+ move2._action_done()
initial_in_date_lot2 = self.env['stock.quant'].search([
('location_id', '=', self.stock_location.id),
@@ -2635,10 +2635,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move3.action_confirm()
- move3.action_assign()
+ move3._action_confirm()
+ move3._action_assign()
move3.move_line_ids.qty_done = 1
- move3.action_done()
+ move3._action_done()
quant_in_pack = self.env['stock.quant'].search([
('product_id', '=', self.product3.id),
('location_id', '=', self.pack_location.id),
@@ -2693,11 +2693,11 @@ class StockMove(TransactionCase):
'product_uom_qty': 1.0,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.lot_id = lot1
move1.move_line_ids.qty_done = 1
- move1.action_done()
+ move1._action_done()
# receive lot2
move2 = self.env['stock.move'].create({
@@ -2709,11 +2709,11 @@ class StockMove(TransactionCase):
'product_uom_qty': 1.0,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
})
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
move2.move_line_ids.lot_id = lot2
move2.move_line_ids.qty_done = 1
- move2.action_done()
+ move2._action_done()
initial_in_date_lot2 = self.env['stock.quant'].search([
('location_id', '=', self.stock_location.id),
@@ -2740,10 +2740,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
})
- move3.action_confirm()
- move3.action_assign()
+ move3._action_confirm()
+ move3._action_assign()
move3.move_line_ids.qty_done = 1
- move3.action_done()
+ move3._action_done()
# Now, also move lot2
self.env['stock.move.line'].create({
@@ -2781,10 +2781,10 @@ class StockMove(TransactionCase):
'product_uom_qty': 10.0,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 10
- move1.action_done()
+ move1._action_done()
self.assertEqual(self.product1.qty_available, 10.0)
@@ -2796,10 +2796,10 @@ class StockMove(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 5.0,
})
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
move2.move_line_ids.qty_done = 5
- move2.action_done()
+ move2._action_done()
self.assertEqual(self.product1.qty_available, 5.0)
self.assertEqual(self.product1.with_context(company_owned=True).qty_available, 10.0)
@@ -2820,15 +2820,15 @@ class StockMove(TransactionCase):
self.env['stock.quant']._update_available_quantity(self.product1, self.stock_location, 10)
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move_line = move1.move_line_ids
default = {'product_uom_qty': 3,
'qty_done': 3}
move_line.copy(default=default)
move_line.with_context(bypass_reservation_update=True).write({'product_uom_qty': 7, 'qty_done': 0})
- move1.action_done()
+ move1._action_done()
new_move = self.env['stock.move'].search([('name', '=', 'test_split_1'), ('state', '=', 'confirmed')])
@@ -2850,12 +2850,12 @@ class StockMove(TransactionCase):
'product_uom_qty': 10.0,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.product_uom_qty = 15
self.assertEqual(move1.state, 'partially_available')
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(move1.product_uom_qty, 15)
self.assertEqual(len(move1.move_line_ids), 1)
@@ -2874,13 +2874,13 @@ class StockMove(TransactionCase):
'product_uom_qty': 10.0,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.product_uom_qty = 5
self.assertEqual(move1.state, 'confirmed')
self.assertEqual(len(move1.move_line_ids), 0)
- move1.action_assign()
+ move1._action_assign()
self.assertEqual(move1.state, 'assigned')
self.assertEqual(move1.product_uom_qty, 5)
self.assertEqual(len(move1.move_line_ids), 1)
diff --git a/addons/stock/tests/test_move2.py b/addons/stock/tests/test_move2.py
index f0fbd786d53..62c76166c52 100644
--- a/addons/stock/tests/test_move2.py
+++ b/addons/stock/tests/test_move2.py
@@ -785,7 +785,7 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.stock_location,
'product_id': self.productA.id,
})
- inventory.prepare_inventory()
+ inventory.action_start()
inventory.line_ids.product_qty = 2
inventory.action_done()
delivery_order.action_assign()
@@ -842,7 +842,7 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.stock_location,
'product_id': self.productA.id,
})
- inventory.prepare_inventory()
+ inventory.action_start()
inventory.line_ids.prod_lot_id = lot1
inventory.line_ids.product_qty = 2
inventory.action_done()
@@ -902,7 +902,7 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.stock_location,
'product_id': self.productA.id,
})
- inventory.prepare_inventory()
+ inventory.action_start()
self.env['stock.inventory.line'].create({
'inventory_id': inventory.id,
'location_id': inventory.location_id.id,
@@ -969,7 +969,7 @@ class TestSinglePicking(TestStockCommon):
'location_id': self.stock_location,
'product_id': self.productA.id,
})
- inventory.prepare_inventory()
+ inventory.action_start()
self.env['stock.inventory.line'].create({
'inventory_id': inventory.id,
'location_id': inventory.location_id.id,
diff --git a/addons/stock/tests/test_shipment.py b/addons/stock/tests/test_shipment.py
index 98eb9f66d02..4af36692260 100644
--- a/addons/stock/tests/test_shipment.py
+++ b/addons/stock/tests/test_shipment.py
@@ -13,7 +13,7 @@ class TestInventory(TestStockCommon):
# create and confirm an incoming move of product 3
incoming_move = self._create_move_in(self.product_3, self.warehouse_1, create_picking=True, product_uom_qty=50)
- incoming_move.action_confirm()
+ incoming_move._action_confirm()
# receive only 40 units of products; this will create a backorder of incoming shipment for the remaining 10
pack_operation = self._create_pack_operation(
diff --git a/addons/stock/tests/test_stock_flow.py b/addons/stock/tests/test_stock_flow.py
index fb01d9edec9..83e8391f954 100644
--- a/addons/stock/tests/test_stock_flow.py
+++ b/addons/stock/tests/test_stock_flow.py
@@ -1075,7 +1075,7 @@ class TestStockFlow(TestStockCommon):
inventory = self.InvObj.create({'name': 'Test',
'product_id': self.UnitA.id,
'filter': 'product'})
- inventory.prepare_inventory()
+ inventory.action_start()
self.assertFalse(inventory.line_ids, "Inventory line should not created.")
inventory_line = self.InvLineObj.create({
'inventory_id': inventory.id,
@@ -1093,7 +1093,7 @@ class TestStockFlow(TestStockCommon):
inventory = self.InvObj.create({'name': 'Test',
'product_id': self.UnitA.id,
'filter': 'product'})
- inventory.prepare_inventory()
+ inventory.action_start()
self.assertEqual(len(inventory.line_ids), 1, "One inventory line should be created.")
inventory_line = self.InvLineObj.search([('product_id', '=', self.UnitA.id), ('inventory_id', '=', inventory.id)], limit=1)
self.assertEqual(inventory_line.product_qty, 120, "Wrong product quantity in inventory line.")
@@ -1117,7 +1117,7 @@ class TestStockFlow(TestStockCommon):
inventory = self.InvObj.create({'name': 'Inventory Product KG',
'product_id': productKG.id,
'filter': 'product'})
- inventory.prepare_inventory()
+ inventory.action_start()
self.assertFalse(inventory.line_ids, "Inventory line should not created.")
inventory_line = self.InvLineObj.create({
'inventory_id': inventory.id,
@@ -1134,7 +1134,7 @@ class TestStockFlow(TestStockCommon):
inventory = self.InvObj.create({'name': 'Test',
'product_id': productKG.id,
'filter': 'product'})
- inventory.prepare_inventory()
+ inventory.action_start()
self.assertEqual(len(inventory.line_ids), 1, "One inventory line should be created.")
inventory_line = self.InvLineObj.search([('product_id', '=', productKG.id), ('inventory_id', '=', inventory.id)], limit=1)
self.assertEqual(inventory_line.product_qty, 5000, "Wrong product quantity in inventory line.")
@@ -1160,7 +1160,7 @@ class TestStockFlow(TestStockCommon):
inventory = self.InvObj.create({'name': 'Test Partial and Pack',
'filter': 'partial',
'location_id': self.stock_location})
- inventory.prepare_inventory()
+ inventory.action_start()
pack_obj = self.env['stock.quant.package']
lot_obj = self.env['stock.production.lot']
pack1 = pack_obj.create({'name': 'PACK00TEST1'})
@@ -1186,7 +1186,7 @@ class TestStockFlow(TestStockCommon):
inventory2 = self.InvObj.create({'name': 'Test Partial Lot and Pack2',
'filter': 'partial',
'location_id': self.stock_location})
- inventory2.prepare_inventory()
+ inventory2.action_start()
line_vals = []
line_vals += [{'location_id': self.stock_location, 'product_id': packproduct.id, 'product_qty': 20, 'product_uom_id': packproduct.uom_id.id}]
line_vals += [{'location_id': self.stock_location, 'product_id': lotproduct.id, 'product_qty': 0, 'product_uom_id': lotproduct.uom_id.id, 'prod_lot_id': False}]
@@ -1211,7 +1211,7 @@ class TestStockFlow(TestStockCommon):
'category_id': category_id
})
# Start Inventory
- inventory3.prepare_inventory()
+ inventory3.action_start()
# check all products have given category id
products_category = inventory3.line_ids.mapped('product_id.categ_id')
self.assertEqual(len(products_category), 1, "Inventory line should have only one category")
@@ -1224,7 +1224,7 @@ class TestStockFlow(TestStockCommon):
'category_id': category_id,
'exhausted': True,
})
- inventory4.prepare_inventory()
+ inventory4.action_start()
inventory4._get_inventory_lines_values()
inventory4_lines_count = len(inventory4.line_ids)
inventory4.action_done()
@@ -1238,7 +1238,7 @@ class TestStockFlow(TestStockCommon):
'category_id': category_id,
'exhausted': True,
})
- inventory5.prepare_inventory()
+ inventory5.action_start()
inventory5._get_inventory_lines_values()
inventory5_lines_count = len(inventory5.line_ids)
inventory5.action_done()
@@ -1795,13 +1795,13 @@ class TestStockFlow(TestStockCommon):
'location_dest_id': self.customer_location})
with self.assertRaises(UserError):
- move_mto_alone.action_confirm()
- move_with_ancestors.action_confirm()
- other_move.action_confirm()
+ move_mto_alone._action_confirm()
+ move_with_ancestors._action_confirm()
+ other_move._action_confirm()
- move_mto_alone.do_unreserve()
- move_with_ancestors.do_unreserve()
- other_move.do_unreserve()
+ move_mto_alone._do_unreserve()
+ move_with_ancestors._do_unreserve()
+ other_move._do_unreserve()
self.assertEquals(move_mto_alone.state, "waiting")
self.assertEquals(move_with_ancestors.state, "waiting")
diff --git a/addons/stock/tests/test_warehouse.py b/addons/stock/tests/test_warehouse.py
index 749cd5cbc28..bcffba2509d 100644
--- a/addons/stock/tests/test_warehouse.py
+++ b/addons/stock/tests/test_warehouse.py
@@ -19,7 +19,7 @@ class TestWarehouse(TestStockCommon):
'location_id': self.warehouse_1.lot_stock_id.id,
'product_id': self.product_1.id,
})
- inventory.prepare_inventory()
+ inventory.action_start()
# As done in common.py, there is already an inventory line existing
self.assertEqual(len(inventory.line_ids), 1)
self.assertEqual(inventory.line_ids.theoretical_qty, 50.0)
@@ -99,20 +99,20 @@ class TestWarehouse(TestStockCommon):
self.assertEqual(customer_move.location_dest_id, self.env.ref('stock.stock_location_customers'))
# confirm move, check quantity on hand and virtually available, without location context
- customer_move.action_confirm()
+ customer_move._action_confirm()
self.assertEqual(product.qty_available, 0.0)
self.assertEqual(product.virtual_available, -5.0)
customer_move.quantity_done = 5
- customer_move.action_done()
+ customer_move._action_done()
self.assertEqual(product.qty_available, -5.0)
# compensate negative quants by receiving products from supplier
receive_move = self._create_move(product, self.env.ref('stock.stock_location_suppliers'), self.warehouse_1.lot_stock_id, product_uom_qty=15)
- receive_move.action_confirm()
+ receive_move._action_confirm()
receive_move.quantity_done = 15
- receive_move.action_done()
+ receive_move._action_done()
product._compute_quantities()
self.assertEqual(product.qty_available, 10.0)
@@ -121,13 +121,13 @@ class TestWarehouse(TestStockCommon):
# new move towards customer
customer_move_2 = self._create_move(product, self.warehouse_1.lot_stock_id, self.env.ref('stock.stock_location_customers'), product_uom_qty=2)
- customer_move_2.action_confirm()
+ customer_move_2._action_confirm()
product._compute_quantities()
self.assertEqual(product.qty_available, 10.0)
self.assertEqual(product.virtual_available, 8.0)
customer_move_2.quantity_done = 2.0
- customer_move_2.action_done()
+ customer_move_2._action_done()
product._compute_quantities()
self.assertEqual(product.qty_available, 8.0)
@@ -208,7 +208,7 @@ class TestWarehouse(TestStockCommon):
'location_id': stock_location.id,
'product_id': productA.id,
})
- inventory.prepare_inventory()
+ inventory.action_start()
self.assertEqual(len(inventory.line_ids), 1, "Wrong inventory lines generated.")
self.assertEqual(inventory.line_ids.theoretical_qty, -1, "Theoretical quantity should be -1.")
inventory.line_ids.product_qty = 0 # Put the quantity back to 0
diff --git a/addons/stock/views/stock_inventory_views.xml b/addons/stock/views/stock_inventory_views.xml
index af9af7be00a..d3394da3c13 100644
--- a/addons/stock/views/stock_inventory_views.xml
+++ b/addons/stock/views/stock_inventory_views.xml
@@ -113,7 +113,7 @@
<field name="arch" type="xml">
<form string="Inventory Adjustment">
<header>
- <button name="prepare_inventory" states="draft" string="Start Inventory" type="object" class="oe_highlight" groups="stock.group_stock_user"/>
+ <button name="action_start" states="draft" string="Start Inventory" type="object" class="oe_highlight" groups="stock.group_stock_user"/>
<button name="action_done" states="confirm" string="Validate Inventory" type="object" class="oe_highlight" groups="stock.group_stock_manager"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
<button name="action_cancel_draft" states="confirm" string="Cancel Inventory" type="object"/>
@@ -155,7 +155,7 @@
</group>
<notebook attrs="{'invisible':[('state','=','draft')]}">
<page string="Inventory Details" >
- <button name="reset_real_qty" states="confirm" string="⇒ Set quantities to 0" type="object" class="oe_link oe_right" groups="stock.group_stock_user"/>
+ <button name="action_reset_product_qty" states="confirm" string="⇒ Set quantities to 0" type="object" class="oe_link oe_right" groups="stock.group_stock_user"/>
<field name="line_ids" string="Inventory Details" context="{'default_location_id': location_id, 'default_product_id': product_id, 'default_prod_lot_id': lot_id, 'default_package_id': package_id, 'default_partner_id': partner_id}" mode="tree,kanban">
<tree string="Inventory Details" editable="bottom" decoration-info="product_qty != theoretical_qty" decoration-danger="theoretical_qty &lt; 0">
<field name="product_id" domain="[('type','=','product')]"/>
diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml
index 2444cc1e714..4b06be5582f 100644
--- a/addons/stock/views/stock_picking_views.xml
+++ b/addons/stock/views/stock_picking_views.xml
@@ -205,7 +205,7 @@
<button name="action_assign" attrs="{'invisible': ['|', ('state', 'not in', ('confirmed', 'waiting')), ('is_locked', '=', False)]}" string="Check Availability" type="object" class="oe_highlight" groups="base.group_user"/>
<button name="action_assign" attrs="{'invisible': ['|', ('state', '!=', 'partially_available'), ('is_locked', '=', False)]}" string="Recheck Availability" type="object" groups="base.group_user"/>
<button name="force_assign" attrs="{'invisible': ['|', ('state', 'not in', ('confirmed', 'waiting', 'partially_available')), ('is_locked', '=', False)]}" string="Force Availability" type="object" groups="stock.group_stock_manager"/>
- <button name="do_new_transfer" attrs="{'invisible': ['|', ('state', 'not in', ('draft', 'partially_available', 'assigned')), ('is_locked', '=', False)]}" string="Validate" groups="stock.group_stock_user" type="object" class="oe_highlight"/>
+ <button name="button_validate" attrs="{'invisible': ['|', ('state', 'not in', ('draft', 'partially_available', 'assigned')), ('is_locked', '=', False)]}" string="Validate" groups="stock.group_stock_user" type="object" class="oe_highlight"/>
<button name="do_print_picking" string="Print" groups="stock.group_stock_user" type="object" attrs="{'invisible': ['|', ('state', 'not in', ('assigned', 'partially_available')), ('is_locked', '=', False)]}"/>
<button name="%(action_report_delivery)d" string="Print" attrs="{'invisible': ['|', ('state', '!=', 'done'), ('is_locked', '=', False)]}" type="action" groups="base.group_user"/>
<button name="%(act_stock_return_picking)d" string="Return" attrs="{'invisible': ['|', ('state', '!=', 'done'), ('is_locked', '=', False)]}" type="action" groups="base.group_user"/>
diff --git a/addons/stock/views/stock_scrap_views.xml b/addons/stock/views/stock_scrap_views.xml
index 4a3459a405b..95575bd082f 100644
--- a/addons/stock/views/stock_scrap_views.xml
+++ b/addons/stock/views/stock_scrap_views.xml
@@ -126,7 +126,7 @@
</group>
</group>
<footer>
- <button name="action_done" string="Done" type="object" class="btn-primary"/>
+ <button name="action_done" special="save" string="Done" class="btn-primary"/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer>
</form>
diff --git a/addons/stock/wizard/stock_backorder_confirmation.py b/addons/stock/wizard/stock_backorder_confirmation.py
index 8d0ef8e32be..2ddbbe30ba5 100644
--- a/addons/stock/wizard/stock_backorder_confirmation.py
+++ b/addons/stock/wizard/stock_backorder_confirmation.py
@@ -25,10 +25,8 @@ class StockBackorderConfirmation(models.TransientModel):
backorder_pick.action_cancel()
self.pick_id.message_post(body=_("Back order <em>%s</em> <b>cancelled</b>.") % (backorder_pick.name))
- @api.multi
def process(self):
self._process()
- @api.multi
def process_cancel_backorder(self):
self._process(cancel_backorder=True)
diff --git a/addons/stock/wizard/stock_change_product_qty.py b/addons/stock/wizard/stock_change_product_qty.py
index 39caa0ff069..52345f6ef67 100644
--- a/addons/stock/wizard/stock_change_product_qty.py
+++ b/addons/stock/wizard/stock_change_product_qty.py
@@ -44,8 +44,7 @@ class ProductChangeQuantity(models.TransientModel):
if self.product_id:
self.product_tmpl_id = self.onchange_product_id_dict(self.product_id.id)['product_tmpl_id']
- @api.multi
- def _prepare_inventory_line(self):
+ def _action_start_line(self):
product = self.product_id.with_context(location=self.location_id.id, lot_id=self.lot_id.id)
th_qty = product.qty_available
@@ -77,13 +76,12 @@ class ProductChangeQuantity(models.TransientModel):
if any(wizard.new_quantity < 0 for wizard in self):
raise UserError(_('Quantity cannot be negative.'))
- @api.multi
def change_product_qty(self):
""" Changes the Product Quantity by making a Physical Inventory. """
Inventory = self.env['stock.inventory']
for wizard in self:
product = wizard.product_id.with_context(location=wizard.location_id.id, lot_id=wizard.lot_id.id)
- line_data = wizard._prepare_inventory_line()
+ line_data = wizard._action_start_line()
if wizard.product_id.id and wizard.lot_id.id:
diff --git a/addons/stock/wizard/stock_immediate_transfer.py b/addons/stock/wizard/stock_immediate_transfer.py
index 05d7b38ab32..b66ce187222 100644
--- a/addons/stock/wizard/stock_immediate_transfer.py
+++ b/addons/stock/wizard/stock_immediate_transfer.py
@@ -18,7 +18,6 @@ class StockImmediateTransfer(models.TransientModel):
res['pick_id'] = self._context['active_id']
return res
- @api.multi
def process(self):
self.ensure_one()
# If still in draft => confirm and assign
@@ -34,6 +33,6 @@ class StockImmediateTransfer(models.TransientModel):
move_line.qty_done = move_line.product_uom_qty
else:
move.quantity_done = move.product_uom_qty
- if self.pick_id.check_backorder():
+ if self.pick_id._check_backorder():
return self.pick_id.action_generate_backorder_wizard()
self.pick_id.do_transfer()
diff --git a/addons/stock/wizard/stock_picking_return.py b/addons/stock/wizard/stock_picking_return.py
index 15551867774..eb2c5328352 100644
--- a/addons/stock/wizard/stock_picking_return.py
+++ b/addons/stock/wizard/stock_picking_return.py
@@ -83,11 +83,10 @@ class ReturnPicking(models.TransientModel):
}
return vals
- @api.multi
def _create_returns(self):
# TODO sle: the unreserve of the next moves could be less brutal
for return_move in self.product_return_moves.mapped('move_id'):
- return_move.move_dest_ids.filtered(lambda m: m.state not in ('done', 'cancel')).do_unreserve()
+ return_move.move_dest_ids.filtered(lambda m: m.state not in ('done', 'cancel'))._do_unreserve()
# create new picking for returned products
picking_type_id = self.picking_id.picking_type_id.return_picking_type_id.id or self.picking_id.picking_type_id.id
@@ -130,7 +129,6 @@ class ReturnPicking(models.TransientModel):
new_picking.action_assign()
return new_picking.id, picking_type_id
- @api.multi
def create_returns(self):
for wizard in self:
new_picking_id, pick_type_id = wizard._create_returns()
diff --git a/addons/stock/wizard/stock_scheduler_compute.py b/addons/stock/wizard/stock_scheduler_compute.py
index 3b501a19d73..6629c5996b7 100644
--- a/addons/stock/wizard/stock_scheduler_compute.py
+++ b/addons/stock/wizard/stock_scheduler_compute.py
@@ -41,7 +41,6 @@ class StockSchedulerCompute(models.TransientModel):
new_cr.close()
return {}
- @api.multi
def procure_calculation(self):
threaded_calculation = threading.Thread(target=self._procure_calculation_orderpoint, args=())
threaded_calculation.start()
diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py
index f8a1f8b9dd0..01a59166a6c 100644
--- a/addons/stock_account/models/stock.py
+++ b/addons/stock_account/models/stock.py
@@ -148,10 +148,9 @@ class StockMove(models.Model):
"""
return self.location_id.company_id.id == self.company_id.id and not self.location_dest_id.company_id
- @api.multi
- def action_done(self):
+ def _action_done(self):
self.product_price_update_before_done()
- res = super(StockMove, self).action_done()
+ res = super(StockMove, self)._action_done()
for move in res:
if move._is_in():
if move.product_id.cost_method in ['fifo', 'average']:
diff --git a/addons/stock_account/tests/test_stockvaluation.py b/addons/stock_account/tests/test_stockvaluation.py
index fd50a6aef98..9b2e45ef687 100644
--- a/addons/stock_account/tests/test_stockvaluation.py
+++ b/addons/stock_account/tests/test_stockvaluation.py
@@ -85,10 +85,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 10.0,
'price_unit': 10.0,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 10.0
- move1.action_done()
+ move1._action_done()
# stock_account values for move1
self.assertEqual(move1.product_uom_qty, 10.0)
@@ -129,10 +129,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 10.0,
'price_unit': 8.0,
})
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
move2.move_line_ids.qty_done = 10.0
- move2.action_done()
+ move2._action_done()
# stock_account values for move2
self.assertEqual(move2.product_uom_qty, 10.0)
@@ -181,10 +181,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 3.0,
})
- move3.action_confirm()
- move3.action_assign()
+ move3._action_confirm()
+ move3._action_assign()
move3.move_line_ids.qty_done = 3.0
- move3.action_done()
+ move3._action_done()
# stock_account values for move3
self.assertEqual(move3.product_uom_qty, 3.0)
@@ -285,10 +285,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 9.0,
})
- move4.action_confirm()
- move4.action_assign()
+ move4._action_confirm()
+ move4._action_assign()
move4.move_line_ids.qty_done = 9.0
- move4.action_done()
+ move4._action_done()
# stock_account values for move4
self.assertEqual(move4.product_uom_qty, 9.0)
@@ -347,10 +347,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 20.0,
})
- move5.action_confirm()
- move5.action_assign()
+ move5._action_confirm()
+ move5._action_assign()
move5.move_line_ids.qty_done = 20.0
- move5.action_done()
+ move5._action_done()
# stock_account values for move5
self.assertEqual(move5.product_uom_qty, 20.0)
@@ -415,10 +415,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 10.0,
'price_unit': 12.0,
})
- move6.action_confirm()
- move6.action_assign()
+ move6._action_confirm()
+ move6._action_assign()
move6.move_line_ids.qty_done = 10.0
- move6.action_done()
+ move6._action_done()
# stock_account values for move6
self.assertEqual(move6.product_uom_qty, 10)
@@ -577,10 +577,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 4.0,
'price_unit': 15.0,
})
- move7.action_confirm()
- move7.action_assign()
+ move7._action_confirm()
+ move7._action_assign()
move7.move_line_ids.qty_done = 4.0
- move7.action_done()
+ move7._action_done()
# stock_account values for move1
self.assertEqual(move7.product_uom_qty, 4.0)
@@ -681,10 +681,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 68.0,
'price_unit': 15,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 68.0
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.value, 1020.0)
@@ -700,10 +700,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 140.0,
'price_unit': 15.50,
})
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
move2.move_line_ids.qty_done = 140.0
- move2.action_done()
+ move2._action_done()
self.assertEqual(move2.value, 2170.0)
@@ -719,10 +719,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 94.0,
})
- move3.action_confirm()
- move3.action_assign()
+ move3._action_confirm()
+ move3._action_assign()
move3.move_line_ids.qty_done = 94.0
- move3.action_done()
+ move3._action_done()
# note: it' ll have to get 68 units from the first batch and 26 from the second one
@@ -743,10 +743,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 40.0,
'price_unit': 16,
})
- move4.action_confirm()
- move4.action_assign()
+ move4._action_confirm()
+ move4._action_assign()
move4.move_line_ids.qty_done = 40.0
- move4.action_done()
+ move4._action_done()
self.assertEqual(move4.value, 640.0)
@@ -765,10 +765,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 78.0,
'price_unit': 16.5,
})
- move5.action_confirm()
- move5.action_assign()
+ move5._action_confirm()
+ move5._action_assign()
move5.move_line_ids.qty_done = 78.0
- move5.action_done()
+ move5._action_done()
self.assertEqual(move5.value, 1287.0)
@@ -787,10 +787,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 116.0,
})
- move6.action_confirm()
- move6.action_assign()
+ move6._action_confirm()
+ move6._action_assign()
move6.move_line_ids.qty_done = 116.0
- move6.action_done()
+ move6._action_done()
# note: it' ll have to get 114 units from the move2 and 2 from move4
# so its value should be -((114*15.5) + (2*16)) = 1735
@@ -812,10 +812,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 62.0,
})
- move7.action_confirm()
- move7.action_assign()
+ move7._action_confirm()
+ move7._action_assign()
move7.move_line_ids.qty_done = 62.0
- move7.action_done()
+ move7._action_done()
# note: it' ll have to get 38 units from the move4 and 24 from move5
# so its value should be -((38*16) + (24*16.5)) = 608 + 396
@@ -842,10 +842,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 10.0,
})
- move8.action_confirm()
- move8.action_assign()
+ move8._action_confirm()
+ move8._action_assign()
move8.move_line_ids.qty_done = 10.0
- move8.action_done()
+ move8._action_done()
self.assertEqual(move8.value, 0.0)
@@ -867,10 +867,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 10.0,
})
- move9.action_confirm()
- move9.action_assign()
+ move9._action_confirm()
+ move9._action_assign()
move9.move_line_ids.qty_done = 10.0
- move9.action_done()
+ move9._action_done()
# note: it' ll have to get 10 units from move5 so its value should
# be -(10*16.50) = -165
@@ -899,10 +899,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 10.0,
'price_unit': 100,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 10.0
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.value, 1000.0)
@@ -918,10 +918,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 10.0,
'price_unit': 80,
})
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
move2.move_line_ids.qty_done = 10.0
- move2.action_done()
+ move2._action_done()
self.assertEqual(move2.value, 800.0)
@@ -937,10 +937,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 15.0,
})
- move3.action_confirm()
- move3.action_assign()
+ move3._action_confirm()
+ move3._action_assign()
move3.move_line_ids.qty_done = 15.0
- move3.action_done()
+ move3._action_done()
# note: it' ll have to get 10 units from move1 and 5 from move2
@@ -961,10 +961,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 5.0,
'price_unit': 60,
})
- move4.action_confirm()
- move4.action_assign()
+ move4._action_confirm()
+ move4._action_assign()
move4.move_line_ids.qty_done = 5.0
- move4.action_done()
+ move4._action_done()
self.assertEqual(move4.value, 300.0)
@@ -982,10 +982,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 7.0,
})
- move5.action_confirm()
- move5.action_assign()
+ move5._action_confirm()
+ move5._action_assign()
move5.move_line_ids.qty_done = 7.0
- move5.action_done()
+ move5._action_done()
# note: it' ll have to get 5 units from the move2 and 2 from move4
# so its value should be -((5*80) + (2*60)) = 520
@@ -1015,8 +1015,8 @@ class TestStockValuation(TransactionCase):
'qty_done': 50.0,
})]
})
- move1.action_confirm()
- move1.action_done()
+ move1._action_confirm()
+ move1._action_done()
self.assertEqual(move1.value, 0.0)
# normally unused in out moves, but as it moved negative stock we mark it
@@ -1038,8 +1038,8 @@ class TestStockValuation(TransactionCase):
'qty_done': 40.0,
})]
})
- move2.action_confirm()
- move2.action_done()
+ move2._action_confirm()
+ move2._action_done()
move1._fifo_vacuum()
@@ -1064,8 +1064,8 @@ class TestStockValuation(TransactionCase):
'qty_done': 20.0
})]
})
- move3.action_confirm()
- move3.action_done()
+ move3._action_confirm()
+ move3._action_done()
move1._fifo_vacuum()
@@ -1098,8 +1098,8 @@ class TestStockValuation(TransactionCase):
'qty_done': 10.0,
})]
})
- move1.action_confirm()
- move1.action_done()
+ move1._action_confirm()
+ move1._action_done()
move2 = self.env['stock.move'].create({
'name': '10 in',
@@ -1117,8 +1117,8 @@ class TestStockValuation(TransactionCase):
'qty_done': 12.0,
})]
})
- move2.action_confirm()
- move2.action_done()
+ move2._action_confirm()
+ move2._action_done()
move2._fifo_vacuum()
self.assertEqual(len(move2.account_move_ids), 1)
@@ -1137,10 +1137,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 60.0,
'price_unit': 15,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 60.0
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.value, 900.0)
self.assertEqual(move1.remaining_qty, 0.0) # unusedin average move
@@ -1155,10 +1155,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 140.0,
'price_unit': 15.50,
})
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
move2.move_line_ids.qty_done = 140.0
- move2.action_done()
+ move2._action_done()
self.assertEqual(move2.value, 2170.0)
@@ -1171,10 +1171,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 190.0,
})
- move3.action_confirm()
- move3.action_assign()
+ move3._action_confirm()
+ move3._action_assign()
move3.move_line_ids.qty_done = 190.0
- move3.action_done()
+ move3._action_done()
self.assertEqual(move3.value, -2916.5)
@@ -1189,10 +1189,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 70.0,
'price_unit': 16.00,
})
- move4.action_confirm()
- move4.action_assign()
+ move4._action_confirm()
+ move4._action_assign()
move4.move_line_ids.qty_done = 70.0
- move4.action_done()
+ move4._action_done()
self.assertEqual(move4.value, 1120.0)
@@ -1205,10 +1205,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 30.0,
})
- move5.action_confirm()
- move5.action_assign()
+ move5._action_confirm()
+ move5._action_assign()
move5.move_line_ids.qty_done = 30.0
- move5.action_done()
+ move5._action_done()
self.assertEqual(move5.value, -477.6)
@@ -1230,10 +1230,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 10.0,
})
- move1.action_confirm()
- move1.force_assign()
+ move1._action_confirm()
+ move1._force_assign()
move1.quantity_done = 10.0
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.value, -990.0) # as no move out were done for this product, fallback on the standard price
self.assertEqual(move1.remaining_qty, 0.0) # unused in average move
@@ -1255,10 +1255,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 10.0,
'price_unit': 10,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 10.0
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.value, 100.0)
self.assertEqual(move1.remaining_qty, 0.0) # unused in average move
@@ -1272,10 +1272,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 10.0,
})
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
move2.move_line_ids.qty_done = 10.0
- move2.action_done()
+ move2._action_done()
self.assertEqual(move2.value, -100.0)
self.assertEqual(move2.remaining_qty, 0.0) # unused in average move
@@ -1289,10 +1289,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 10.0,
})
- move3.action_confirm()
- move3.force_assign()
+ move3._action_confirm()
+ move3._force_assign()
move3.quantity_done = 10.0
- move3.action_done()
+ move3._action_done()
self.assertEqual(move3.value, -100.0) # as no move out were done for this product, fallback on latest cost
self.assertEqual(move3.remaining_qty, 0.0) # unused in average move
@@ -1315,10 +1315,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 10.0,
'price_unit': 10,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 10.0
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.value, 100.0)
self.assertEqual(move1.remaining_qty, 0.0) # unused in average move
@@ -1332,10 +1332,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 10.0,
})
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
move2.move_line_ids.qty_done = 10.0
- move2.action_done()
+ move2._action_done()
self.assertEqual(move2.value, -100.0)
self.assertEqual(move2.remaining_qty, 0.0) # unused in average move
@@ -1349,10 +1349,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 10.0,
})
- move3.action_confirm()
- move3.force_assign()
+ move3._action_confirm()
+ move3._force_assign()
move3.quantity_done = 10.0
- move3.action_done()
+ move3._action_done()
self.assertEqual(move3.value, -100.0) # as no move out were done for this product, fallback on latest cost
self.assertEqual(move3.remaining_qty, 0.0) # unused in average move
@@ -1373,10 +1373,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 10.0,
'price_unit': 10,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 10.0
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.value, 100.0)
self.assertEqual(move1.remaining_qty, 0.0) # unused in average move
@@ -1394,10 +1394,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 10.0,
'price_unit': 10,
})
- move1.action_confirm()
- move1.action_assign()
+ move1._action_confirm()
+ move1._action_assign()
move1.move_line_ids.qty_done = 10.0
- move1.action_done()
+ move1._action_done()
self.assertEqual(move1.value, 100.0)
self.assertEqual(self.product1.standard_price, 10)
@@ -1412,10 +1412,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 10.0,
'price_unit': 20,
})
- move2.action_confirm()
- move2.action_assign()
+ move2._action_confirm()
+ move2._action_assign()
move2.move_line_ids.qty_done = 10.0
- move2.action_done()
+ move2._action_done()
self.assertEqual(move2.value, 200.0)
self.assertEqual(self.product1.standard_price, 15)
@@ -1429,10 +1429,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 5.0,
})
- move3.action_confirm()
- move3.force_assign()
+ move3._action_confirm()
+ move3._force_assign()
move3.quantity_done = 5.0
- move3.action_done()
+ move3._action_done()
self.assertEqual(move3.value, -75.0)
self.assertEqual(self.product1.standard_price, 15)
@@ -1446,10 +1446,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 30.0,
})
- move4.action_confirm()
- move4.force_assign()
+ move4._action_confirm()
+ move4._force_assign()
move4.quantity_done = 30.0
- move4.action_done()
+ move4._action_done()
self.assertEqual(move4.value, -450.0)
self.assertEqual(self.product1.standard_price, 15)
@@ -1464,10 +1464,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 20.0,
'price_unit': 20,
})
- move5.action_confirm()
- move5.action_assign()
+ move5._action_confirm()
+ move5._action_assign()
move5.move_line_ids.qty_done = 20.0
- move5.action_done()
+ move5._action_done()
self.assertEqual(move5.value, 400.0)
self.assertEqual(self.product1.standard_price, 35)
@@ -1483,10 +1483,10 @@ class TestStockValuation(TransactionCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 5.0,
})
- move6.action_confirm()
- move6.force_assign()
+ move6._action_confirm()
+ move6._force_assign()
move6.quantity_done = 5.0
- move6.action_done()
+ move6._action_done()
self.assertEqual(move6.value, -175.0)
self.assertEqual(self.product1.standard_price, 35)
@@ -1501,10 +1501,10 @@ class TestStockValuation(TransactionCase):
'product_uom_qty': 10.0,
'price_unit': 10,
})
- move7.action_confirm()
- move7.action_assign()
+ move7._action_confirm()
+ move7._action_assign()
move7.move_line_ids.qty_done = 10.0
- move7.action_done()
+ move7._action_done()
self.assertEqual(move7.value, 100.0)
self.assertEqual(self.product1.standard_price, 10)