diff options
| author | Simon Lejeune <sle@openerp.com> | 2017-07-13 14:19:44 +0200 |
|---|---|---|
| committer | Simon Lejeune <sle@openerp.com> | 2017-07-14 17:08:22 +0200 |
| commit | ddf2b21bdf38492ce075d4ae96bb9323c6ef59dd (patch) | |
| tree | 7a5b94d9491bbdec29308b318324cea6e8f173de | |
| parent | 27ab5153d97c16139a5b1e2410bb78780c03f076 (diff) | |
[REF] stock: adapt to rename of stock.pack.operation into stock.mode.line
44 files changed, 396 insertions, 396 deletions
diff --git a/addons/delivery/models/stock_picking.py b/addons/delivery/models/stock_picking.py index a919ec8e2c5..37a845d937e 100644 --- a/addons/delivery/models/stock_picking.py +++ b/addons/delivery/models/stock_picking.py @@ -22,8 +22,8 @@ class StockQuantPackage(models.Model): shipping_weight = fields.Float(string='Shipping Weight', help="Can be changed during the 'put in pack' to adjust the weight of the shipping.") -class StockPackOperation(models.Model): - _inherit = 'stock.pack.operation' +class StockMoveLine(models.Model): + _inherit = 'stock.move.line' @api.multi def manage_package_type(self): @@ -55,22 +55,22 @@ class StockPicking(models.Model): return weight_uom_id @api.one - @api.depends('pack_operation_ids') + @api.depends('move_line_ids') def _compute_packages(self): self.ensure_one() packs = set() - for packop in self.pack_operation_ids: - if packop.result_package_id and packop.result_package_id.packaging_id: - packs.add(packop.result_package_id.id) + for move_line in self.move_line_ids: + if move_line.result_package_id and move_line.result_package_id.packaging_id: + packs.add(move_line.result_package_id.id) self.package_ids = list(packs) @api.one - @api.depends('pack_operation_ids') + @api.depends('move_line_ids') def _compute_bulk_weight(self): weight = 0.0 - for packop in self.pack_operation_ids: - if packop.product_id and not packop.result_package_id: - weight += packop.product_uom_id._compute_quantity(packop.product_qty, packop.product_id.uom_id) * packop.product_id.weight + for move_line in self.move_line_ids: + if move_line.product_id and not move_line.result_package_id: + weight += move_line.product_uom_id._compute_quantity(move_line.product_qty, move_line.product_id.uom_id) * move_line.product_id.weight self.weight_bulk = weight @api.one diff --git a/addons/delivery/wizard/choose_delivery_package.py b/addons/delivery/wizard/choose_delivery_package.py index 28cae85a8aa..acc4ff0539f 100644 --- a/addons/delivery/wizard/choose_delivery_package.py +++ b/addons/delivery/wizard/choose_delivery_package.py @@ -40,8 +40,8 @@ class ChooseDeliveryPackage(models.TransientModel): return stock_quant_package.shipping_weight else: picking_id = self.env['stock.picking'].browse(self.env.context['active_id']) - pack_operation_ids = [po for po in picking_id.pack_operation_ids if po.qty_done > 0 and not po.result_package_id] - total_weight = sum([po.qty_done * po.product_id.weight for po in pack_operation_ids]) + move_line_ids = [po for po in picking_id.move_line_ids if po.qty_done > 0 and not po.result_package_id] + total_weight = sum([po.qty_done * po.product_id.weight for po in move_line_ids]) return total_weight def put_in_pack(self): diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 74aeb63051d..69ad489da17 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -466,7 +466,7 @@ class MrpProduction(models.Model): if len(workorders) == len(bom.routing_id.operation_ids): moves_raw |= self.move_raw_ids.filtered(lambda move: not move.operation_id) moves_finished = self.move_finished_ids.filtered(lambda move: move.operation_id == operation) #TODO: code does nothing, unless maybe by_products? - moves_raw.mapped('pack_operation_ids').write({'workorder_id': workorder.id}) + moves_raw.mapped('move_line_ids').write({'workorder_id': workorder.id}) (moves_finished + moves_raw).write({'workorder_id': workorder.id}) workorder._generate_lot_ids() diff --git a/addons/mrp/models/mrp_unbuild.py b/addons/mrp/models/mrp_unbuild.py index ee841a7259c..09841db809c 100644 --- a/addons/mrp/models/mrp_unbuild.py +++ b/addons/mrp/models/mrp_unbuild.py @@ -90,7 +90,7 @@ class MrpUnbuild(models.Model): consume_move = self._generate_consume_moves()[0] produce_moves = self._generate_produce_moves() if consume_move.has_tracking != 'none': - self.env['stock.pack.operation'].create({ + self.env['stock.move.line'].create({ 'move_id': consume_move.id, 'lot_id': self.lot_id.id, 'qty_done': consume_move.product_uom_qty, @@ -106,7 +106,7 @@ class MrpUnbuild(models.Model): for produce_move in produce_moves: if produce_move.has_tracking != 'none': original = original_quants.filtered(lambda quant: quant.product_id == produce_move.product_id) - self.env['stock.pack.operation'].create({ + self.env['stock.move.line'].create({ 'move_id': produce_move.id, 'lot_id': original.lot_id.id, 'qty_done': produce_move.product_uom_qty, diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 75da7786016..f9b420578b7 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -102,11 +102,11 @@ class MrpWorkorder(models.Model): move_raw_ids = fields.One2many( 'stock.move', 'workorder_id', 'Moves') move_line_ids = fields.One2many( - 'stock.pack.operation', 'workorder_id', 'Moves to Track', + 'stock.move.line', 'workorder_id', 'Moves to Track', domain=[('done_wo', '=', True)], help="Inventory moves for which you must scan a lot number at this work order") active_move_line_ids = fields.One2many( - 'stock.pack.operation', 'workorder_id', + 'stock.move.line', 'workorder_id', domain=[('done_wo', '=', False)]) final_lot_id = fields.Many2one( 'stock.production.lot', 'Current Lot', domain="[('product_id', '=', product_id)]", @@ -199,7 +199,7 @@ class MrpWorkorder(models.Model): qty_todo = new_qty - sum(move_lots.mapped('quantity')) if float_compare(qty_todo, 0.0, precision_rounding=move.product_uom.rounding) > 0: while float_compare(qty_todo, 0.0, precision_rounding=move.product_uom.rounding) > 0: - self.active_move_line_ids += self.env['stock.pack.operation'].new({ + self.active_move_line_ids += self.env['stock.move.line'].new({ 'move_id': move.id, 'product_id': move.product_id.id, 'lot_id': False, @@ -236,7 +236,7 @@ class MrpWorkorder(models.Model): def _generate_lot_ids(self): """ Generate stock move lines """ self.ensure_one() - MoveLine = self.env['stock.pack.operation'] + MoveLine = self.env['stock.move.line'] tracked_moves = self.move_raw_ids.filtered( lambda move: move.state not in ('done', 'cancel') and move.product_id.tracking != 'none' and move.product_id != self.production_id.product_id) for move in tracked_moves: @@ -322,7 +322,7 @@ class MrpWorkorder(models.Model): if not self.next_work_order_id: production_move = self.production_id.move_finished_ids.filtered(lambda x: (x.product_id.id == self.production_id.product_id.id) and (x.state not in ('done', 'cancel'))) if production_move.has_tracking != 'none': - move_line = production_move.pack_operation_ids.filtered(lambda x: x.lot_id.id == self.final_lot_id.id) + move_line = production_move.move_line_ids.filtered(lambda x: x.lot_id.id == self.final_lot_id.id) if move_line: move_line.product_qty += self.qty_producing else: diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index 0e28d1dd3ec..0cb7f568368 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -7,8 +7,8 @@ from odoo.tools import float_compare, float_round from odoo.addons import decimal_precision as dp -class StockPackOperation(models.Model): - _inherit = 'stock.pack.operation' +class StockMoveLine(models.Model): + _inherit = 'stock.move.line' workorder_id = fields.Many2one('mrp.workorder', 'Work Order') production_id = fields.Many2one('mrp.production', 'Production Order') @@ -33,10 +33,10 @@ class StockPackOperation(models.Model): def write(self, vals): if 'lot_id' in vals: for movelot in self: - movelot.move_id.production_id.move_raw_ids.mapped('pack_operation_ids')\ + movelot.move_id.production_id.move_raw_ids.mapped('move_line_ids')\ .filtered(lambda r: r.done_wo and not r.done_move and r.lot_produced_id == movelot.lot_id)\ .write({'lot_produced_id': vals['lot_id']}) - return super(StockPackOperation, self).write(vals) + return super(StockMoveLine, self).write(vals) class StockMove(models.Model): @@ -55,7 +55,7 @@ class StockMove(models.Model): workorder_id = fields.Many2one( 'mrp.workorder', 'Work Order To Consume') # Quantities to process, in normalized UoMs - active_move_line_ids = fields.One2many('stock.pack.operation', 'move_id', domain=[('done_wo', '=', True)], string='Lots') + active_move_line_ids = fields.One2many('stock.move.line', 'move_id', domain=[('done_wo', '=', True)], string='Lots') bom_line_id = fields.Many2one('mrp.bom.line', 'BoM Line') unit_factor = fields.Float('Unit Factor') is_done = fields.Boolean( @@ -80,8 +80,8 @@ class StockMove(models.Model): 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.pack_operation_ids: - move.pack_operation_ids.write({'production_id': move.raw_material_production_id.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 @@ -99,7 +99,7 @@ class StockMove(models.Model): view = self.env.ref('mrp.view_stock_move_lots') serial = (self.has_tracking == 'serial') only_create = False # Check operation type in theory - show_reserved = any([x for x in self.pack_operation_ids if x.product_qty > 0.0]) + show_reserved = any([x for x in self.move_line_ids if x.product_qty > 0.0]) ctx.update({ 'serial': serial, 'only_create': only_create, diff --git a/addons/mrp/wizard/change_production_qty.py b/addons/mrp/wizard/change_production_qty.py index 4ad746ef8be..b408bef5f8b 100644 --- a/addons/mrp/wizard/change_production_qty.py +++ b/addons/mrp/wizard/change_production_qty.py @@ -79,7 +79,7 @@ class ChangeProductionQty(models.TransientModel): if wo == production.workorder_ids[-1]: moves_raw |= production.move_raw_ids.filtered(lambda move: not move.operation_id) moves_finished = production.move_finished_ids.filtered(lambda move: move.operation_id == operation) #TODO: code does nothing, unless maybe by_products? - moves_raw.mapped('pack_operation_ids').write({'workorder_id': wo.id}) + moves_raw.mapped('move_line_ids').write({'workorder_id': wo.id}) (moves_finished + moves_raw).write({'workorder_id': wo.id}) if wo.move_raw_ids.filtered(lambda x: x.product_id.tracking != 'none') and not wo.active_move_line_ids: wo._generate_lot_ids() diff --git a/addons/mrp/wizard/mrp_product_produce.py b/addons/mrp/wizard/mrp_product_produce.py index 92fbfef526a..d0e4837c1d5 100644 --- a/addons/mrp/wizard/mrp_product_produce.py +++ b/addons/mrp/wizard/mrp_product_produce.py @@ -29,7 +29,7 @@ class MrpProductProduce(models.TransientModel): lines = [] existing_lines = [] for move in production.move_raw_ids.filtered(lambda x: (x.product_id.tracking != 'none') and x.state not in ('done', 'cancel')): - if not move.pack_operation_ids.filtered(lambda x: not x.lot_produced_id): + if not move.move_line_ids.filtered(lambda x: not x.lot_produced_id): qty = quantity / move.bom_line_id.bom_id.product_qty * move.bom_line_id.product_qty if move.product_id.tracking == 'serial': while float_compare(qty, 0.0, precision_rounding=move.product_uom.rounding) > 0: @@ -56,7 +56,7 @@ class MrpProductProduce(models.TransientModel): 'location_dest_id': move.location_dest_id.id, }) else: - existing_lines += move.pack_operation_ids.filtered(lambda x: not x.lot_produced_id).ids + existing_lines += move.move_line_ids.filtered(lambda x: not x.lot_produced_id).ids res['serial'] = serial res['production_id'] = production.id @@ -72,7 +72,7 @@ class MrpProductProduce(models.TransientModel): product_qty = fields.Float(string='Quantity', digits=dp.get_precision('Product Unit of Measure'), required=True) product_uom_id = fields.Many2one('product.uom', 'Unit of Measure') lot_id = fields.Many2one('stock.production.lot', string='Lot') - consume_line_ids = fields.Many2many('stock.pack.operation', 'mrp_produce_stock_pack_operation', string='Product to Track') + consume_line_ids = fields.Many2many('stock.move.line', 'mrp_produce_stock_move_line', string='Product to Track') product_tracking = fields.Selection(related="product_id.tracking") @api.multi @@ -104,12 +104,12 @@ class MrpProductProduce(models.TransientModel): @api.multi def check_finished_move_lots(self): - packs = self.env['stock.pack.operation'] + packs = self.env['stock.move.line'] produce_move = self.production_id.move_finished_ids.filtered(lambda x: x.product_id == self.product_id and x.state not in ('done', 'cancel')) if produce_move and produce_move.product_id.tracking != 'none': if not self.lot_id: raise UserError(_('You need to provide a lot for the finished product')) - existing_move_line = produce_move.pack_operation_ids.filtered(lambda x: x.lot_id == self.lot_id) + existing_move_line = produce_move.move_line_ids.filtered(lambda x: x.lot_id == self.lot_id) if existing_move_line: existing_move_line.product_qty += self.product_qty existing_move_line.qty_done += self.product_qty @@ -127,7 +127,7 @@ class MrpProductProduce(models.TransientModel): } packs.create(vals) for move in self.production_id.move_raw_ids: - for moveline in move.pack_operation_ids.filtered(lambda x: not x.lot_produced_id): + for moveline in move.move_line_ids.filtered(lambda x: not x.lot_produced_id): if moveline.qty_done and self.lot_id: #Possibly the entire move is selected remaining_qty = moveline.product_uom_qty - moveline.qty_done diff --git a/addons/mrp_repair/models/mrp_repair.py b/addons/mrp_repair/models/mrp_repair.py index f92cb1cf975..a098d0b08fa 100644 --- a/addons/mrp_repair/models/mrp_repair.py +++ b/addons/mrp_repair/models/mrp_repair.py @@ -432,8 +432,8 @@ class Repair(models.Model): 'partner_id': repair.address_id.id, 'location_id': operation.location_id.id, 'location_dest_id': operation.location_dest_id.id, - 'pack_operation_ids': [(0, 0, {'product_id': operation.product_id.id, - 'lot_id': operation.lot_id.id, + 'move_line_ids': [(0, 0, {'product_id': operation.product_id.id, + 'lot_id': operation.lot_id.id, 'product_uom_qty': 0, # bypass reservation here 'product_uom_id': operation.product_uom.id, 'qty_done': operation.product_uom_qty, @@ -453,8 +453,8 @@ class Repair(models.Model): 'partner_id': repair.address_id.id, 'location_id': repair.location_id.id, 'location_dest_id': repair.location_dest_id.id, - 'pack_operation_ids': [(0, 0, {'product_id': repair.product_id.id, - 'lot_id': repair.lot_id.id, + 'move_line_ids': [(0, 0, {'product_id': repair.product_id.id, + 'lot_id': repair.lot_id.id, 'product_uom_qty': 0, # bypass reservation here 'product_uom_id': repair.product_uom.id or repair.product_id.uom_id.id, 'qty_done': repair.product_qty, diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 67a639fd659..482ca1d809a 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -724,7 +724,7 @@ class PosOrder(models.Model): has_wrong_lots = True for pack_lot in pack_lots: lot_id, qty = pack_lot['lot_id'], pack_lot['qty'] - self.env['stock.pack.operation'].create({ + self.env['stock.move.line'].create({ 'move_id': move.id, 'product_id': move.product_id.id, 'product_uom_id': move.product_uom.id, diff --git a/addons/product_expiry/views/report_deliveryslip.xml b/addons/product_expiry/views/report_deliveryslip.xml index 97e77a58175..f91af855a81 100644 --- a/addons/product_expiry/views/report_deliveryslip.xml +++ b/addons/product_expiry/views/report_deliveryslip.xml @@ -1,7 +1,7 @@ <odoo> <template id="report_delivery_document_inherit_product_expiry" inherit_id="stock.report_delivery_document"> <xpath expr="//th[@name='lot_serial']" position="inside"> - <t t-if="any([lot.lot_id.use_date for operation in o.pack_operation_ids for lot in operation.pack_lot_ids])"> + <t t-if="any([lot.lot_id.use_date for operation in o.move_line_ids for lot in operation.pack_lot_ids])"> <span class="pull-right">Expiry Date</span> </t> </xpath> diff --git a/addons/purchase/tests/test_create_picking.py b/addons/purchase/tests/test_create_picking.py index 0d8de789006..ce66f74ea0c 100644 --- a/addons/purchase/tests/test_create_picking.py +++ b/addons/purchase/tests/test_create_picking.py @@ -54,7 +54,7 @@ class TestCreatePicking(common.TestProductCommon): # Validate first shipment self.picking = self.po.picking_ids[0] self.picking.force_assign() - for ml in self.picking.pack_operation_ids: + for ml in self.picking.move_line_ids: ml.qty_done = ml.product_uom_qty self.picking.action_done() self.assertEqual(self.po.order_line.mapped('qty_received'), [7.0], 'Purchase: all products should be received') diff --git a/addons/purchase/tests/test_purchase_order.py b/addons/purchase/tests/test_purchase_order.py index 6d63545b138..e0fe29b585f 100644 --- a/addons/purchase/tests/test_purchase_order.py +++ b/addons/purchase/tests/test_purchase_order.py @@ -75,7 +75,7 @@ class TestPurchaseOrder(AccountingTestCase): self.assertEqual(self.po.picking_count, 1, 'Purchase: one picking should be created"') self.picking = self.po.picking_ids[0] self.picking.force_assign() - self.picking.pack_operation_ids.write({'qty_done': 5.0}) + self.picking.move_line_ids.write({'qty_done': 5.0}) self.picking.button_validate() self.assertEqual(self.po.order_line.mapped('qty_received'), [5.0, 5.0], 'Purchase: all products should be received"') @@ -109,7 +109,7 @@ class TestPurchaseOrder(AccountingTestCase): self.assertEqual(self.po.picking_count, 1, 'Purchase: one picking should be created"') self.picking = self.po.picking_ids[0] self.picking.force_assign() - self.picking.pack_operation_ids.write({'qty_done': 5.0}) + self.picking.move_line_ids.write({'qty_done': 5.0}) self.picking.button_validate() self.assertEqual(self.po.order_line.mapped('qty_received'), [5.0, 5.0], 'Purchase: all products should be received"') @@ -139,7 +139,7 @@ class TestPurchaseOrder(AccountingTestCase): # Validate picking return_pick.force_assign() - return_pick.pack_operation_ids.write({'qty_done': 2}) + return_pick.move_line_ids.write({'qty_done': 2}) return_pick.button_validate() diff --git a/addons/stock/data/stock_demo.yml b/addons/stock/data/stock_demo.yml index 0263730991a..ac8ac582632 100644 --- a/addons/stock/data/stock_demo.yml +++ b/addons/stock/data/stock_demo.yml @@ -91,7 +91,7 @@ picking_type_id: stock.picking_type_out location_id: stock.stock_location_stock location_dest_id: stock.stock_location_customers - pack_operation_ids: + move_line_ids: - product_id: product.product_product_6 qty_done: 100 product_uom_id: product.product_uom_unit @@ -231,7 +231,7 @@ location_id: stock.stock_location_suppliers location_dest_id: stock.stock_location_shop0 state: done - pack_operation_ids: + move_line_ids: - product_id: product.product_delivery_01 qty_done: 100 product_uom_id: product.product_uom_unit @@ -296,7 +296,7 @@ picking_type_id: chi_picking_type_out location_id: stock.stock_location_shop0 location_dest_id: stock.stock_location_customers - pack_operation_ids: + move_line_ids: - product_id: product.product_product_6 qty_done: 100 product_uom_id: product.product_uom_unit diff --git a/addons/stock/models/__init__.py b/addons/stock/models/__init__.py index c31511010c0..16f84e77ab4 100644 --- a/addons/stock/models/__init__.py +++ b/addons/stock/models/__init__.py @@ -12,7 +12,7 @@ from . import stock_incoterms from . import stock_inventory from . import stock_location from . import stock_move -from . import stock_pack_operation +from . import stock_move_line from . import stock_production_lot from . import stock_picking from . import stock_quant diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py index 6b1770b0f42..6cd3821fb90 100644 --- a/addons/stock/models/stock_inventory.py +++ b/addons/stock/models/stock_inventory.py @@ -412,7 +412,7 @@ class InventoryLine(models.Model): 'restrict_partner_id': self.partner_id.id, 'location_id': location_id, 'location_dest_id': location_dest_id, - 'pack_operation_ids': [(0, 0, {'product_id': self.product_id.id, + 'move_line_ids': [(0, 0, {'product_id': self.product_id.id, 'lot_id': self.prod_lot_id.id, 'product_uom_qty': 0, # bypass reservation here 'product_uom_id': self.product_uom_id.id, diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index ffddf59b7c4..68ef37c5e8c 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -130,8 +130,8 @@ class StockMove(models.Model): help='If checked, when this move is cancelled, cancel the linked move too') picking_type_id = fields.Many2one('stock.picking.type', 'Operation Type') inventory_id = fields.Many2one('stock.inventory', 'Inventory') - pack_operation_ids = fields.One2many('stock.pack.operation', 'move_id') - pack_operation_nosuggest_ids = fields.One2many('stock.pack.operation', 'move_id', domain=[('product_qty', '=', 0.0)]) + move_line_ids = fields.One2many('stock.move.line', 'move_id') + move_line_nosuggest_ids = fields.One2many('stock.move.line', 'move_id', domain=[('product_qty', '=', 0.0)]) origin_returned_move_id = fields.Many2one('stock.move', 'Origin return move', copy=False, help='Move that created the return move') returned_move_ids = fields.One2many('stock.move', 'origin_returned_move_id', 'All returned moves', help='Optional: all returned moves created from this move') reserved_availability = fields.Float( @@ -161,7 +161,7 @@ class StockMove(models.Model): is_initial_demand_editable = fields.Boolean('Is initial demand editable', compute='_compute_is_initial_demand_editable') @api.multi - @api.depends('has_tracking', 'pack_operation_ids', 'location_id', 'location_dest_id', 'is_editable') + @api.depends('has_tracking', 'move_line_ids', 'location_id', 'location_dest_id', 'is_editable') def _compute_show_details_visible(self): """ According to this field, the button that calls `action_show_details` will be displayed to work on a move from its picking form view, or not. @@ -178,10 +178,10 @@ class StockMove(models.Model): multi_locations_enabled = False if self.user_has_groups('stock.group_stock_multi_locations'): multi_locations_enabled = move.location_id.child_ids or move.location_dest_id.child_ids - has_package = move.pack_operation_ids.mapped('package_id') | move.pack_operation_ids.mapped('result_package_id') + has_package = move.move_line_ids.mapped('package_id') | move.move_line_ids.mapped('result_package_id') if move.picking_id.picking_type_id.show_operations is False\ and move.state not in ['cancel', 'draft', 'confirmed']\ - and (multi_locations_enabled or move.has_tracking != 'none' or len(move.pack_operation_ids) > 1 or has_package): + and (multi_locations_enabled or move.has_tracking != 'none' or len(move.move_line_ids) > 1 or has_package): move.show_details_visible = True else: move.show_details_visible = False @@ -216,10 +216,10 @@ class StockMove(models.Model): """ This will return the move lines to consider when applying _quantity_done_compute on a stock.move. In some context, such as MRP, it is necessary to compute quantity_done on filtered sock.move.line.""" self.ensure_one() - return self.pack_operation_ids + return self.move_line_ids @api.multi - @api.depends('pack_operation_ids.qty_done', 'pack_operation_ids.product_uom_id') + @api.depends('move_line_ids.qty_done', 'move_line_ids.product_uom_id') def _quantity_done_compute(self): for move in self: for move_line in move._get_move_lines(): @@ -234,8 +234,8 @@ class StockMove(models.Model): if not move_lines: if quantity_done: # do not impact reservation here - move_line = self.env['stock.pack.operation'].create(dict(move._prepare_move_line_vals(), qty_done=quantity_done)) - move.write({'pack_operation_ids': [(4, move_line.id)]}) + move_line = self.env['stock.move.line'].create(dict(move._prepare_move_line_vals(), qty_done=quantity_done)) + move.write({'move_line_ids': [(4, move_line.id)]}) elif len(move_lines) == 1: move_lines[0].qty_done = quantity_done else: @@ -250,13 +250,13 @@ class StockMove(models.Model): @api.one - @api.depends('pack_operation_ids.product_qty') + @api.depends('move_line_ids.product_qty') def _compute_reserved_availability(self): """ Fill the `availability` field on a stock move, which is the actual reserved quantity and is represented by the aggregated `product_qty` on the linked move lines. If the move is force assigned, the value will be 0. """ - self.reserved_availability = self.product_id.uom_id._compute_quantity(sum(self.pack_operation_ids.mapped('product_qty')), self.product_uom, rounding_method='HALF-UP') + self.reserved_availability = self.product_id.uom_id._compute_quantity(sum(self.move_line_ids.mapped('product_qty')), self.product_uom, rounding_method='HALF-UP') @api.one @api.depends('state', 'product_id', 'product_qty', 'location_id') @@ -407,7 +407,7 @@ class StockMove(models.Model): self.ensure_one() # If "show suggestions" is not checked on the picking type, we have to filter out the - # reserved move lines. We do this by displaying `pack_operation_nosuggest_ids`. We use + # reserved move lines. We do this by displaying `move_line_nosuggest_ids`. We use # different views to display one field or another so that the webclient doesn't have to # fetch both. if self.picking_id.picking_type_id.show_reserved: @@ -639,14 +639,14 @@ class StockMove(models.Model): move.write({'state': 'assigned'}) @api.multi - def check_tracking(self, pack_operation): + 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.restrict_lot_id or (pack_operation and (pack_operation.product_id and pack_operation.pack_lot_ids)) or (pack_operation and not pack_operation.product_id)): + not (move.restrict_lot_id or (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') % move.product_id.name) def _prepare_move_line_vals(self, quantity=None, reserved_quant=None): @@ -694,15 +694,15 @@ class StockMove(models.Model): package_id=package_id, owner_id=owner_id, strict=strict ) for reserved_quant, quantity in quants: - to_update = self.pack_operation_ids.filtered(lambda m: m.location_id.id == reserved_quant.location_id.id and m.lot_id.id == reserved_quant.lot_id.id and m.package_id.id == reserved_quant.package_id.id and m.owner_id.id == reserved_quant.owner_id.id) + to_update = self.move_line_ids.filtered(lambda m: m.location_id.id == reserved_quant.location_id.id and m.lot_id.id == reserved_quant.lot_id.id and m.package_id.id == reserved_quant.package_id.id and m.owner_id.id == reserved_quant.owner_id.id) if to_update: to_update[0].with_context(bypass_reservation_update=True).product_uom_qty += self.product_id.uom_id._compute_quantity(taken_quantity, self.product_uom, rounding_method='HALF-UP') else: if self.product_id.tracking == 'serial': for i in range(0, int(quantity)): - self.env['stock.pack.operation'].create(self._prepare_move_line_vals(quantity=1, reserved_quant=reserved_quant)) + self.env['stock.move.line'].create(self._prepare_move_line_vals(quantity=1, reserved_quant=reserved_quant)) else: - self.env['stock.pack.operation'].create(self._prepare_move_line_vals(quantity=quantity, reserved_quant=reserved_quant)) + self.env['stock.move.line'].create(self._prepare_move_line_vals(quantity=quantity, reserved_quant=reserved_quant)) return taken_quantity @api.multi @@ -718,11 +718,11 @@ class StockMove(models.Model): # create the move line(s) but do not impact quants if move.product_id.tracking == 'serial': for i in range(0, int(move.product_qty)): - move_line_id = self.env['stock.pack.operation'].create(move._prepare_move_line_vals(quantity=1)) - move.write({'pack_operation_ids': [(4, move_line_id.id, 0)]}) + move_line_id = self.env['stock.move.line'].create(move._prepare_move_line_vals(quantity=1)) + move.write({'move_line_ids': [(4, move_line_id.id, 0)]}) else: - move_line_id = self.env['stock.pack.operation'].create(move._prepare_move_line_vals(quantity=move.product_qty)) - move.write({'pack_operation_ids': [(4, move_line_id.id, 0)]}) + move_line_id = self.env['stock.move.line'].create(move._prepare_move_line_vals(quantity=move.product_qty)) + move.write({'move_line_ids': [(4, move_line_id.id, 0)]}) move.write({'state': 'assigned'}) else: if not move.move_orig_ids: @@ -741,24 +741,24 @@ class StockMove(models.Model): else: # Check what our parents brought and what our siblings took in order to # determine what we can distribute. - move_lines_in = move.move_orig_ids.filtered(lambda m: m.state == 'done').mapped('pack_operation_ids') + move_lines_in = move.move_orig_ids.filtered(lambda m: m.state == 'done').mapped('move_line_ids') keys_in = ['location_dest_id', 'lot_id', 'result_package_id', 'owner_id'] grouped_move_lines_in = {} for k, g in groupby(sorted(move_lines_in, key=itemgetter(*keys_in)), key=itemgetter(*keys_in)): - grouped_move_lines_in[k] = sum(self.env['stock.pack.operation'].concat(*list(g)).mapped('qty_done')) + grouped_move_lines_in[k] = sum(self.env['stock.move.line'].concat(*list(g)).mapped('qty_done')) move_lines_out_done = (move.move_orig_ids.mapped('move_dest_ids') - move)\ .filtered(lambda m: m.state in ['done'])\ - .mapped('pack_operation_ids') + .mapped('move_line_ids') move_lines_out_reserved = (move.move_orig_ids.mapped('move_dest_ids') - move)\ .filtered(lambda m: m.state in ['partially_available', 'assigned'])\ - .mapped('pack_operation_ids') + .mapped('move_line_ids') keys_out = ['location_id', 'lot_id', 'package_id', 'owner_id'] grouped_move_lines_out = {} for k, g in groupby(sorted(move_lines_out_done, key=itemgetter(*keys_out)), key=itemgetter(*keys_out)): - grouped_move_lines_out[k] = sum(self.env['stock.pack.operation'].concat(*list(g)).mapped('qty_done')) + grouped_move_lines_out[k] = sum(self.env['stock.move.line'].concat(*list(g)).mapped('qty_done')) for k, g in groupby(sorted(move_lines_out_reserved, key=itemgetter(*keys_out)), key=itemgetter(*keys_out)): - grouped_move_lines_out[k] = sum(self.env['stock.pack.operation'].concat(*list(g)).mapped('product_qty')) + grouped_move_lines_out[k] = sum(self.env['stock.move.line'].concat(*list(g)).mapped('product_qty')) available_move_lines = {key: grouped_move_lines_in[key] - grouped_move_lines_out.get(key, 0) for key in grouped_move_lines_in.keys()} # pop key if the quantity available amount to 0 available_move_lines = dict((k, v) for k, v in available_move_lines.iteritems() if v) @@ -769,7 +769,7 @@ class StockMove(models.Model): if available_move_lines.get((move_line.location_id, move_line.lot_id, move_line.result_package_id, move_line.owner_id)): available_move_lines[(move_line.location_id, move_line.lot_id, move_line.result_package_id, move_line.owner_id)] -= move_line.product_qty for (location_id, lot_id, package_id, owner_id), quantity in available_move_lines.items(): - need = move.product_qty - sum(move.pack_operation_ids.mapped('product_qty')) + need = move.product_qty - sum(move.move_line_ids.mapped('product_qty')) taken_quantity = move._increase_reserved_quantity(need, quantity, location_id, lot_id, package_id, owner_id) if need - taken_quantity == 0.0: move.state = 'assigned' @@ -827,7 +827,7 @@ class StockMove(models.Model): extra_move = self.copy(default=extra_move_vals).action_confirm() # link it to some move lines - for move_line in self.pack_operation_ids.filtered(lambda ml: ml.qty_done): + for move_line in self.move_line_ids.filtered(lambda ml: ml.qty_done): if float_compare(move_line.qty_done, extra_move_quantity, precision_rounding=rounding) <= 0: # move this move line to our extra move move_line.move_id = extra_move.id @@ -872,7 +872,7 @@ class StockMove(models.Model): # 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) - for move_line in move.pack_operation_ids: + for move_line in move.move_line_ids: if move_line.product_qty: # FIXME: there will be an issue if the move was partially available # By decreasing `product_qty`, we free the reservation. @@ -883,9 +883,9 @@ class StockMove(models.Model): pass # If you were already putting stock.move.lots on the next one in the work order, transfer those to the new move - move.pack_operation_ids.filtered(lambda x: x.qty_done == 0.0).write({'move_id': 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 - for packop in move.pack_operation_ids: + for packop in move.move_line_ids: if float_compare(packop.qty_done, 0, precision_rounding=rounding) > 0: if move.has_tracking != 'none' and (move.picking_type_id.use_create_lots or move.picking_type_id.use_existing_lots): if packop.lot_name and not packop.lot_id: @@ -905,7 +905,7 @@ class StockMove(models.Model): backorder_picking = picking.copy({ 'name': '/', 'move_lines': [], - 'pack_operation_ids': [], + 'move_line_ids': [], 'backorder_id': picking.id }) picking.message_post('Backorder Created') #message needs to be improved diff --git a/addons/stock/models/stock_move_line.py b/addons/stock/models/stock_move_line.py index c7edd707319..5d4e24b24a9 100644 --- a/addons/stock/models/stock_move_line.py +++ b/addons/stock/models/stock_move_line.py @@ -9,8 +9,8 @@ from odoo.tools.pycompat import izip from odoo.tools.float_utils import float_round, float_compare, float_is_zero -class PackOperation(models.Model): - _name = "stock.pack.operation" #TODO: change to stock.move.operation +class StockMoveLine(models.Model): + _name = "stock.move.line" _description = "Packing Operation" _order = "result_package_id desc, id" @@ -94,7 +94,7 @@ class PackOperation(models.Model): @api.model def create(self, vals): vals['ordered_qty'] = vals.get('product_uom_qty') - ml = super(PackOperation, self).create(vals) + ml = super(StockMoveLine, self).create(vals) if ml.state == 'done': Quant = self.env['stock.quant'] quantity = ml.product_uom_id._compute_quantity(ml.qty_done, ml.move_id.product_id.uom_id,rounding_method='HALF-UP') @@ -121,7 +121,7 @@ class PackOperation(models.Model): the old quants and allocate the new ones. """ if self.env.context.get('bypass_reservation_update'): - return super(PackOperation, self).write(vals) + return super(StockMoveLine, self).write(vals) Quant = self.env['stock.quant'] # We forbid to change the reserved quantity in the interace, but it is needed in the @@ -219,7 +219,7 @@ class PackOperation(models.Model): Quant._increase_available_quantity(product_id, location_dest_id, quantity, lot_id=lot_id, package_id=result_package_id, owner_id=owner_id) # Unreserve and reserve following move in order to have the real reserved quantity on move_line. next_moves |= ml.move_id.move_dest_ids.filtered(lambda move: move.state not in ('done', 'cancel')) - res = super(PackOperation, self).write(vals) + res = super(StockMoveLine, self).write(vals) next_moves.do_unreserve() next_moves.action_assign() return res @@ -234,7 +234,7 @@ class PackOperation(models.Model): if ml.location_id.should_impact_quants() and ml.product_id.type == 'product' and not float_is_zero(ml.product_qty, precision_digits=precision): self.env['stock.quant']._decrease_reserved_quantity(ml.product_id, ml.location_id, ml.product_qty, lot_id=ml.lot_id, package_id=ml.package_id, owner_id=ml.owner_id) - return super(PackOperation, self).unlink() + return super(StockMoveLine, self).unlink() def action_done(self): """ This method will finalize the work with a move line by "moving" quants to the @@ -296,7 +296,7 @@ class PackOperation(models.Model): ('qty_done', '=', 0.0), ('id', '!=', self.id), ] - oudated_candidates = self.env['stock.pack.operation'].search(oudated_move_lines_domain) + oudated_candidates = self.env['stock.move.line'].search(oudated_move_lines_domain) # As the move's state is not computed over the move lines, we'll have to manually # recompute the moves which we adapted their lines. diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index cd696d6c929..eea788a7a15 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -268,12 +268,12 @@ class Picking(models.Model): index=True, required=True, states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}) - pack_operation_ids = fields.One2many( - 'stock.pack.operation', 'picking_id', 'Operations', + move_line_ids = fields.One2many( + 'stock.move.line', 'picking_id', 'Operations', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}) - pack_operation_exist = fields.Boolean( - 'Has Pack Operations', compute='_compute_pack_operation_exist', + move_line_exist = fields.Boolean( + 'Has Pack Operations', compute='_compute_move_line_exist', help='Check the existence of pack operation on the picking') has_packages = fields.Boolean( @@ -370,13 +370,13 @@ class Picking(models.Model): self.has_scrap_move = bool(self.env['stock.move'].search_count([('picking_id', '=', self.id), ('scrapped', '=', True)])) @api.one - def _compute_pack_operation_exist(self): - self.pack_operation_exist = bool(self.pack_operation_ids) + def _compute_move_line_exist(self): + self.move_line_exist = bool(self.move_line_ids) @api.one def _compute_has_packages(self): has_packages = False - for pack_op in self.pack_operation_ids: + for pack_op in self.move_line_ids: if pack_op.result_package_id: has_packages = True break @@ -458,7 +458,7 @@ class Picking(models.Model): @api.one def action_assign_owner(self): - self.pack_operation_ids.write({'owner_id': self.owner_id.id}) + self.move_line_ids.write({'owner_id': self.owner_id.id}) @api.multi def do_print_picking(self): @@ -518,9 +518,9 @@ class Picking(models.Model): # Check if there are ops not linked to moves yet for pick in self: # # Explode manually added packages - # for ops in pick.pack_operation_ids.filtered(lambda x: not x.move_id and not x.product_id): + # for ops in pick.move_line_ids.filtered(lambda x: not x.move_id and not x.product_id): # for quant in ops.package_id.quant_ids: #Or use get_content for multiple levels - # self.pack_operation_ids.create({'product_id': quant.product_id.id, + # self.move_line_ids.create({'product_id': quant.product_id.id, # 'package_id': quant.package_id.id, # 'result_package_id': ops.result_package_id, # 'lot_id': quant.lot_id.id, @@ -533,7 +533,7 @@ class Picking(models.Model): # 'picking_id': pick.id # }) # Might change first element # # Link existing moves or add moves when no one is related - for ops in pick.pack_operation_ids.filtered(lambda x: not x.move_id): + for ops in pick.move_line_ids.filtered(lambda x: not x.move_id): # Search move with this product moves = pick.move_lines.filtered(lambda x: x.product_id == ops.product_id) if moves: #could search move that needs it the most (that has some quantities left) @@ -561,10 +561,10 @@ class Picking(models.Model): def _check_entire_pack(self): """ This function check if entire packs are moved in the picking""" for picking in self: - origin_packages = picking.pack_operation_ids.mapped("package_id") + origin_packages = picking.move_line_ids.mapped("package_id") for pack in origin_packages: all_in = True - packops = picking.pack_operation_ids.filtered(lambda x: x.package_id == pack) + packops = picking.move_line_ids.filtered(lambda x: x.package_id == pack) keys = ['product_id', 'lot_id'] grouped_quants = {} @@ -573,7 +573,7 @@ class Picking(models.Model): grouped_ops = {} for k, g in groupby(sorted(packops, key=itemgetter(*keys)), key=itemgetter(*keys)): - grouped_ops[k] = sum(self.env['stock.pack.operation'].concat(*list(g)).mapped('product_qty')) + grouped_ops[k] = sum(self.env['stock.move.line'].concat(*list(g)).mapped('product_qty')) if any(grouped_quants[key] - grouped_ops.get(key, 0) != 0 for key in grouped_quants)\ or any(grouped_ops[key] - grouped_quants[key] != 0 for key in grouped_ops): all_in = False @@ -590,15 +590,15 @@ class Picking(models.Model): @api.multi def button_validate(self): self.ensure_one() - pack_operations_delete = self.env['stock.pack.operation'] - if not self.move_lines and not self.pack_operation_ids: + move_line_delete = self.env['stock.move.line'] + if not self.move_lines and not self.move_line_ids: raise UserError(_('Please add some lines to move')) # In draft or with no pack operations edited yet, ask if we can just do everything - if self.state == 'draft' or all([x.qty_done == 0.0 for x in self.pack_operation_ids]): + if self.state == 'draft' or all([x.qty_done == 0.0 for x in self.move_line_ids]): # If no lots when needed, raise error picking_type = self.picking_type_id if (picking_type.use_create_lots or picking_type.use_existing_lots): - for pack in self.pack_operation_ids: + for pack in self.move_line_ids: if pack.product_id and pack.product_id.tracking != 'none': raise UserError(_('Some products require lots/serial numbers, so you need to specify those first!')) view = self.env.ref('stock.view_immediate_transfer') @@ -632,16 +632,16 @@ class Picking(models.Model): 'res_id': wiz.id, 'context': self.env.context, } - for operation in self.pack_operation_ids: + for operation in self.move_line_ids: if operation.qty_done < 0: raise UserError(_('No negative quantities allowed')) if operation.qty_done > 0: pass #operation.write({'product_qty': operation.qty_done}) else: - pack_operations_delete |= operation - if pack_operations_delete: - pack_operations_delete.unlink() + move_line_delete |= operation + if move_line_delete: + move_line_delete.unlink() self.action_done() return @@ -656,11 +656,11 @@ class Picking(models.Model): quantity_done.setdefault(move.product_id.id, 0) quantity_todo[move.product_id.id] += move.product_qty quantity_done[move.product_id.id] += move.quantity_done #TODO: convert to base units - for ops in self.pack_operation_ids.filtered(lambda x: x.package_id and not x.product_id and not x.move_id): + for ops in self.move_line_ids.filtered(lambda x: x.package_id and not x.product_id and not x.move_id): for quant in ops.package_id.quant_ids: quantity_done.setdefault(quant.product_id.id, 0) quantity_done[quant.product_id.id] += quant.qty - for pack in self.pack_operation_ids.filtered(lambda x: x.product_id and not x.move_id): + for pack in self.move_line_ids.filtered(lambda x: x.product_id and not x.move_id): quantity_done.setdefault(pack.product_id.id, 0) quantity_done[pack.product_id.id] += pack.qty_done return any(quantity_done[x] < quantity_todo.get(x, 0) for x in quantity_done) @@ -672,10 +672,10 @@ class Picking(models.Model): # TDE FIXME: move to batch self.ensure_one() moves = self.env['stock.move'] - for pack_operation in self.pack_operation_ids: - for product, remaining_qty in pycompat.items(pack_operation._get_remaining_prod_quantities()): + for move_line in self.move_line_ids: + for product, remaining_qty in pycompat.items(move_line._get_remaining_prod_quantities()): if float_compare(remaining_qty, 0, precision_rounding=product.uom_id.rounding) > 0: - vals = self._prepare_values_extra_move(pack_operation, product, remaining_qty) + 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() @@ -733,7 +733,7 @@ class Picking(models.Model): backorder_picking = picking.copy({ 'name': '/', 'move_lines': [], - 'pack_operation_ids': [], + 'move_line_ids': [], 'backorder_id': picking.id }) picking.message_post(body=_("Back order <em>%s</em> <b>created</b>.") % (backorder_picking.name)) @@ -749,8 +749,8 @@ class Picking(models.Model): def _put_in_pack(self): package = False for pick in self: - operations = pick.pack_operation_ids.filtered(lambda o: o.qty_done > 0 and not o.result_package_id) - operation_ids = self.env['stock.pack.operation'] + operations = pick.move_line_ids.filtered(lambda o: o.qty_done > 0 and not o.result_package_id) + operation_ids = self.env['stock.move.line'] if operations: package = self.env['stock.quant.package'].create({}) for operation in operations: @@ -779,7 +779,7 @@ class Picking(models.Model): def button_scrap(self): self.ensure_one() # only stockable products are scrapeable - scrapeable_products = self.pack_operation_ids.mapped('product_id').filtered(lambda p: p.type == 'product') + scrapeable_products = self.move_line_ids.mapped('product_id').filtered(lambda p: p.type == 'product') return { 'name': _('Scrap'), 'view_type': 'form', @@ -803,7 +803,7 @@ class Picking(models.Model): def action_see_packages(self): self.ensure_one() action = self.env.ref('stock.action_package_view').read()[0] - packages = self.pack_operation_ids.mapped('result_package_id') + packages = self.move_line_ids.mapped('result_package_id') action['domain'] = [('id', 'in', packages.ids)] action['context'] = {'picking_id': self.id} return action diff --git a/addons/stock/models/stock_production_lot.py b/addons/stock/models/stock_production_lot.py index d0c11f18247..88602d3523a 100644 --- a/addons/stock/models/stock_production_lot.py +++ b/addons/stock/models/stock_production_lot.py @@ -32,7 +32,7 @@ class ProductionLot(models.Model): def create(self, vals): pack_id = self.env.context.get('active_pack_operation', False) if pack_id: - pack = self.env['stock.pack.operation'].browse(pack_id) + pack = self.env['stock.move.line'].browse(pack_id) if pack.picking_id and not pack.picking_id.picking_type_id.use_create_lots: raise UserError(_("You are not allowed to create a lot for this picking type")) return super(ProductionLot, self).create(vals) diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index 7f5b7527e7e..73634b3ea18 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -245,8 +245,8 @@ class QuantPackage(models.Model): owner_id = fields.Many2one( 'res.partner', 'Owner', compute='_compute_package_info', search='_search_owner', index=True, readonly=True) - move_line_ids = fields.One2many('stock.pack.operation', 'result_package_id') - current_picking_move_line_ids = fields.One2many('stock.pack.operation', compute="_compute_current_picking_info") + move_line_ids = fields.One2many('stock.move.line', 'result_package_id') + current_picking_move_line_ids = fields.One2many('stock.move.line', compute="_compute_current_picking_info") current_picking_id = fields.Boolean(compute="_compute_current_picking_info") @api.depends('quant_ids.package_id', 'quant_ids.location_id', 'quant_ids.company_id', 'quant_ids.owner_id') @@ -331,7 +331,7 @@ class QuantPackage(models.Model): def action_view_picking(self): action = self.env.ref('stock.action_picking_tree_all').read()[0] - pickings = self.env['stock.pack.operation'].search([('result_package_id', 'in', self.ids)]).mapped('picking_id') + pickings = self.env['stock.move.line'].search([('result_package_id', 'in', self.ids)]).mapped('picking_id') action['domain'] = [('id', 'in', pickings.ids)] return action diff --git a/addons/stock/models/stock_scrap.py b/addons/stock/models/stock_scrap.py index 96ef8443196..3d3f8eb9116 100644 --- a/addons/stock/models/stock_scrap.py +++ b/addons/stock/models/stock_scrap.py @@ -101,7 +101,7 @@ class StockScrap(models.Model): 'location_id': self.location_id.id, 'scrapped': True, 'location_dest_id': self.scrap_location_id.id, - 'pack_operation_ids': [(0, 0, {'product_id': self.product_id.id, + 'move_line_ids': [(0, 0, {'product_id': self.product_id.id, 'product_uom_id': self.product_uom_id.id, 'qty_done': self.scrap_qty, 'location_id': self.location_id.id, diff --git a/addons/stock/models/stock_traceability.py b/addons/stock/models/stock_traceability.py index f627ee7aa96..711036a0f4f 100644 --- a/addons/stock/models/stock_traceability.py +++ b/addons/stock/models/stock_traceability.py @@ -21,16 +21,16 @@ class MrpStockReport(models.TransientModel): @api.model def get_move_lines_upstream(self, move_lines): - res = self.env['stock.pack.operation'] + res = self.env['stock.move.line'] for move_line in move_lines: # if MTO if move_line.move_id.move_orig_ids: - res |= move_line.move_id.move_orig_ids.mapped('pack_operation_ids').filtered( + res |= move_line.move_id.move_orig_ids.mapped('move_line_ids').filtered( lambda m: m.lot_id.id == move_line.lot_id.id) # if MTS else: if move_line.location_id.usage == 'internal': - res |= self.env['stock.pack.operation'].search([ + res |= self.env['stock.move.line'].search([ ('product_id', '=', move_line.product_id.id), ('lot_id', '=', move_line.lot_id.id), ('location_dest_id', '=', move_line.location_id.id), @@ -42,16 +42,16 @@ class MrpStockReport(models.TransientModel): @api.model def get_move_lines_downstream(self, move_lines): - res = self.env['stock.pack.operation'] + res = self.env['stock.move.line'] for move_line in move_lines: # if MTO if move_line.move_id.move_dest_ids: - res |= move_line.move_id.move_dest_ids.mapped('pack_operation_ids').filtered( + res |= move_line.move_id.move_dest_ids.mapped('move_line_ids').filtered( lambda m: m.lot_id.id == move_line.lot_id.id) # if MTS else: if move_line.location_dest_id.usage == 'internal': - res |= self.env['stock.pack.operation'].search([ + res |= self.env['stock.move.line'].search([ ('product_id', '=', move_line.product_id.id), ('lot_id', '=', move_line.lot_id.id), ('location_id', '=', move_line.location_dest_id.id), @@ -77,12 +77,12 @@ class MrpStockReport(models.TransientModel): res = [] if context.get('active_id') and not context.get('model') or context.get('model') == 'stock.production.lot': if stream == "downstream": - move_ids = self.env['stock.pack.operation'].search([ + move_ids = self.env['stock.move.line'].search([ ('lot_id', '=', context.get('active_id')), ('location_id.usage', '=', 'supplier'), ('state', '=', 'done'), ]) - res += self._lines(line_id, model_id=model_id, model='stock.pack.operation', level=level, parent_quant=parent_quant, + res += self._lines(line_id, model_id=model_id, model='stock.move.line', level=level, parent_quant=parent_quant, stream=stream, obj_ids=move_ids) quant_ids = self.env['stock.quant'].search([ ('lot_id', '=', context.get('active_id')), @@ -91,12 +91,12 @@ class MrpStockReport(models.TransientModel): res += self._lines(line_id, model_id=model_id, model='stock.quant', level=level, parent_quant=parent_quant, stream=stream, obj_ids=quant_ids) else: - move_ids = self.env['stock.pack.operation'].search([ + move_ids = self.env['stock.move.line'].search([ ('lot_id', '=', context.get('active_id')), ('location_dest_id.usage', '=', 'customer'), ('state', '=', 'done'), ]) - res += self._lines(line_id, model_id=model_id, model='stock.pack.operation', level=level, parent_quant=parent_quant, + res += self._lines(line_id, model_id=model_id, model='stock.move.line', level=level, parent_quant=parent_quant, stream=stream, obj_ids=move_ids) quant_ids = self.env['stock.quant'].search([ ('lot_id', '=', context.get('active_id')), @@ -105,10 +105,10 @@ class MrpStockReport(models.TransientModel): res += self._lines(line_id, model_id=model_id, model='stock.quant', level=level, parent_quant=parent_quant, stream=stream, obj_ids=quant_ids) elif context.get('active_id') and context.get('model') == 'stock.picking': - move_ids = self.env['stock.picking'].browse(context['active_id']).move_lines.mapped('pack_operation_ids').filtered(lambda m: m.lot_id and m.state == 'done') - res = self._lines(line_id, model_id=model_id, model='stock.pack.operation', level=level, parent_quant=parent_quant, stream=stream, obj_ids=move_ids) - elif context.get('active_id') and context.get('model') == 'stock.pack.operation': - move_line_ids = self.env['stock.pack.operation'].browse(context.get('active_id')) + move_ids = self.env['stock.picking'].browse(context['active_id']).move_lines.mapped('move_line_ids').filtered(lambda m: m.lot_id and m.state == 'done') + res = self._lines(line_id, model_id=model_id, model='stock.move.line', level=level, parent_quant=parent_quant, stream=stream, obj_ids=move_ids) + elif context.get('active_id') and context.get('model') == 'stock.move.line': + move_line_ids = self.env['stock.move.line'].browse(context.get('active_id')) res = self._lines(line_id, model_id=context.get('active_id'), model=context.get('model'), level=level, parent_quant=parent_quant, stream=stream, obj_ids=move_line_ids) else: res = self._lines(line_id, model_id=model_id, model=model, level=level, parent_quant=parent_quant, stream=stream) @@ -137,7 +137,7 @@ class MrpStockReport(models.TransientModel): 'date': move_line.move_id.date, 'parent_id': parent_id, 'model_id': move_line.id, - 'model':'stock.pack.operation', + 'model':'stock.move.line', 'product_id': move_line.product_id.display_name, 'product_qty_uom': str(move_line.qty_done) + ' ' + move_line.product_id.uom_id.name, 'location_source': move_line.location_id.name, @@ -150,14 +150,14 @@ class MrpStockReport(models.TransientModel): def make_dict_head(self, level, parent_id, model=False, stream=False, move_line=False): data = [] - if model == 'stock.pack.operation': + if model == 'stock.move.line': data = [{ 'level': level, 'unfoldable': True, 'date': move_line.move_id.date, 'model_id': move_line.id, 'parent_id': parent_id, - 'model': model or 'stock.pack.operation', + 'model': model or 'stock.move.line', 'product_id': move_line.product_id.display_name+' ('+move_line.lot_id.name+')', 'product_qty_uom': str(move_line.qty_done) + ' ' + move_line.product_id.uom_id.name, 'location_source': move_line.location_id.name, @@ -183,12 +183,12 @@ class MrpStockReport(models.TransientModel): def upstream_traceability(self, level, stream=False, line_id=False, model=False, model_id=False, parent_quant=False): model_obj = self.env[model].browse(model_id) final_vals =[] - if model == 'stock.pack.operation': + if model == 'stock.move.line': moves = self.get_move_lines_upstream(model_obj) for move in moves.sorted(key=lambda m: m.date, reverse=True): final_vals += self.make_dict_move(level, stream=stream, parent_id=line_id, move_line=move) elif model == 'stock.quant': - moves = self.env['stock.pack.operation'].search([ + moves = self.env['stock.move.line'].search([ ('location_dest_id', '=', model_obj.location_id.id), ('lot_id', '=', model_obj.lot_id.id), ('date', '<=', model_obj.write_date), @@ -203,12 +203,12 @@ class MrpStockReport(models.TransientModel): def downstream_traceability(self, level, stream=False, line_id=False, model=False, model_id=False, parent_quant=False): model_obj = self.env[model].browse(model_id) final_vals = [] - if model == 'stock.pack.operation': + if model == 'stock.move.line': moves = self.get_move_lines_downstream(model_obj) for move in moves.sorted(key=lambda r: r.date): final_vals += self.make_dict_move(level, stream=stream, parent_id=line_id, move_line=move) elif model == 'stock.quant': - moves = self.env['stock.pack.operation'].search([ + moves = self.env['stock.move.line'].search([ ('location_id', '=', model_obj.location_id.id), ('lot_id', '=', model_obj.lot_id.id), ('date', '>=', model_obj.write_date), @@ -230,7 +230,7 @@ class MrpStockReport(models.TransientModel): final_vals += self.upstream_traceability(level, stream='upstream', line_id=line_id, model=model, model_id=model_id, parent_quant=parent_quant) else: for move_line in obj_ids: - final_vals += self.make_dict_head(level, stream=stream, parent_id=line_id, model=model or 'stock.pack.operation', move_line=move_line) + final_vals += self.make_dict_head(level, stream=stream, parent_id=line_id, model=model or 'stock.move.line', move_line=move_line) for data in final_vals: lines.append({ 'id': autoIncrement(), @@ -263,7 +263,7 @@ class MrpStockReport(models.TransientModel): if line.get('unfoldable'): final_vals += self.make_dict_head(line['level'], model=line['model_name'], parent_id=line['id'], move_line=model) else: - if line['model_name'] == 'stock.pack.operation': + if line['model_name'] == 'stock.move.line': final_vals += self.make_dict_move(line['level'], parent_id=line['id'], move_line=model) for data in final_vals: lines.append({ diff --git a/addons/stock/report/report_deliveryslip.xml b/addons/stock/report/report_deliveryslip.xml index 8f38a88a6fe..46620401195 100644 --- a/addons/stock/report/report_deliveryslip.xml +++ b/addons/stock/report/report_deliveryslip.xml @@ -49,7 +49,7 @@ </tr> </tbody> </table> - <table class="table table-condensed mt48" t-if="not o.pack_operation_ids"> + <table class="table table-condensed mt48" t-if="not o.move_line_ids"> <thead> <tr> <th><strong>Product</strong></th> @@ -67,8 +67,8 @@ </tbody> </table> <t t-set="backorder" t-value="False"/> - <table class="table table-condensed mt48" t-if="o.pack_operation_ids"> - <t t-set="has_serial_number" t-value="o.pack_operation_ids.filtered('pack_lot_ids')" groups="stock.group_production_lot"/> + <table class="table table-condensed mt48" t-if="o.move_line_ids"> + <t t-set="has_serial_number" t-value="o.move_line_ids.filtered('pack_lot_ids')" groups="stock.group_production_lot"/> <thead> <tr> <th><strong>Product</strong></th> @@ -76,13 +76,13 @@ <span class="pull-left">Lot/Serial Number</span> </th> <th class="text-center"><strong>Ordered Quantity</strong></th> - <th t-if="any([pack_operation.state == 'done' for pack_operation in o.pack_operation_ids])" class="text-right"> + <th t-if="any([pack_operation.state == 'done' for pack_operation in o.move_line_ids])" class="text-right"> <strong>Delivered Quantity</strong> </th> </tr> </thead> <tbody> - <tr t-foreach="o.pack_operation_ids" t-as="pack_operation"> + <tr t-foreach="o.move_line_ids" t-as="pack_operation"> <td> <span t-field="pack_operation.product_id"/> <p t-if="o.picking_type_code == 'outgoing'"> diff --git a/addons/stock/report/report_stockpicking_operations.xml b/addons/stock/report/report_stockpicking_operations.xml index ba8cd025246..689982a63bb 100644 --- a/addons/stock/report/report_stockpicking_operations.xml +++ b/addons/stock/report/report_stockpicking_operations.xml @@ -72,9 +72,9 @@ </table> <br/> <br/> - <table class="table table-condensed" t-if="o.pack_operation_ids"> - <t t-set="has_barcode" t-value="any([pack_operation.product_id and pack_operation.product_id.sudo().barcode or pack_operation.package_id for pack_operation in o.pack_operation_ids])"/> - <t t-set="has_serial_number" t-value="o.pack_operation_ids.filtered('pack_lot_ids')" groups="stock.group_production_lot"/> + <table class="table table-condensed" t-if="o.move_line_ids"> + <t t-set="has_barcode" t-value="any([pack_operation.product_id and pack_operation.product_id.sudo().barcode or pack_operation.package_id for pack_operation in o.move_line_ids])"/> + <t t-set="has_serial_number" t-value="o.move_line_ids.filtered('pack_lot_ids')" groups="stock.group_production_lot"/> <thead> <tr> <th><strong>Product</strong></th> @@ -90,7 +90,7 @@ </tr> </thead> <tbody> - <tr t-foreach="o.pack_operation_ids" t-as="pack_operation"> + <tr t-foreach="o.move_line_ids" t-as="pack_operation"> <td><span t-field="pack_operation.product_id"/><br/> <span t-field="pack_operation.product_id.description_picking"/> <t t-if="not pack_operation.product_id and pack_operation.package_id"><span t-field="pack_operation.package_id"/></t></td> diff --git a/addons/stock/security/ir.model.access.csv b/addons/stock/security/ir.model.access.csv index 781a2b1156f..06bab5388b9 100644 --- a/addons/stock/security/ir.model.access.csv +++ b/addons/stock/security/ir.model.access.csv @@ -54,15 +54,15 @@ access_stock_location_path_stock_user,stock.location.path stock user,model_stock access_stock_location_route_stock_manager,stock.location.route,model_stock_location_route,stock.group_stock_manager,1,1,1,1 access_stock_location_route,stock.location.route,model_stock_location_route,base.group_user,1,0,0,0 access_procurement_rule_internal,procurement.rule.flow internal,model_procurement_rule,base.group_user,1,0,0,0 -access_stock_pack_operation_manager,stock.pack.operation manager,model_stock_pack_operation,stock.group_stock_manager,1,1,1,1 -access_stock_pack_operation_user,stock.pack.operation user,model_stock_pack_operation,stock.group_stock_user,1,1,1,1 -access_stock_pack_operation_all,stock.pack.operation all users,model_stock_pack_operation,base.group_user,1,1,1,1 +access_stock_move_line_manager,stock.move.line manager,model_stock_move_line,stock.group_stock_manager,1,1,1,1 +access_stock_move_line_user,stock.move.line user,model_stock_move_line,stock.group_stock_user,1,1,1,1 +access_stock_move_line_all,stock.move.line all users,model_stock_move_line,base.group_user,1,1,1,1 access_product_putaway_all,product.putaway all users,model_product_putaway,base.group_user,1,0,0,0 access_product_putaway_manager,product.putaway all managers,model_product_putaway,stock.group_stock_manager,1,1,1,1 access_stock_removal_all,product.removal all users,model_product_removal,base.group_user,1,0,0,0 access_stock_fixed_putaway_strat,stock_fixed_putaway_strat managers,model_stock_fixed_putaway_strat,stock.group_stock_manager,1,1,1,1 access_stock_fixed_putaway_user,stock_fixed_putaway_strat user,model_stock_fixed_putaway_strat,stock.group_stock_user,1,0,0,0 -access_stock_pack_operation_portal,stock.pack.operation portal,stock.model_stock_pack_operation,base.group_portal,1,0,0,0 +access_stock_move_line_portal,stock.move.line portal,stock.model_stock_move_line,base.group_portal,1,0,0,0 access_product_price_history_stock_user,prices.history stock user,product.model_product_price_history,stock.group_stock_user,1,0,0,0 access_product_price_history_stock_manager,prices.history stock manager,product.model_product_price_history,stock.group_stock_manager,1,1,1,1 access_barcode_nomenclature_stock_user,barcode.nomenclature.stock.user,barcodes.model_barcode_nomenclature,stock.group_stock_user,1,0,0,0 diff --git a/addons/stock/security/stock_security.xml b/addons/stock/security/stock_security.xml index 5ef72718132..4f69671f6a1 100644 --- a/addons/stock/security/stock_security.xml +++ b/addons/stock/security/stock_security.xml @@ -142,9 +142,9 @@ <field name="groups" eval="[(4, ref('base.group_portal'))]"/> </record> - <record id="stock_pack_operation_rule_portal" model="ir.rule"> + <record id="stock_move_line_rule_portal" model="ir.rule"> <field name="name">Portal Follower Pack Operations</field> - <field name="model_id" ref="stock.model_stock_pack_operation"/> + <field name="model_id" ref="stock.model_stock_move_line"/> <field name="domain_force">['|', ('picking_id.message_partner_ids','in',[user.partner_id.id]), ('picking_id.partner_id.id','=',user.partner_id.id)]</field> <field name="groups" eval="[(4, ref('base.group_portal'))]"/> </record> diff --git a/addons/stock/static/src/xml/stock_traceability_report_line.xml b/addons/stock/static/src/xml/stock_traceability_report_line.xml index e2817032822..1343ecfb39b 100644 --- a/addons/stock/static/src/xml/stock_traceability_report_line.xml +++ b/addons/stock/static/src/xml/stock_traceability_report_line.xml @@ -12,7 +12,7 @@ <t t-name="report_mrp_line"> <t t-set="trclass" t-value="'o_stock_reports_default_style'"/> - <t t-if="l.model == 'stock.pack.operation'"><t t-set="trclass" t-value="'o_stock_reports_level0'"/></t> + <t t-if="l.model == 'stock.move.line'"><t t-set="trclass" t-value="'o_stock_reports_level0'"/></t> <t t-if="l.model == 'stock.quant'"><t t-set="trclass" t-value="'o_stock_reports_level1'"/></t> <t t-set="space_td" t-value="'margin-left: '+ l.level + 'px;'"/> <t t-set="domainClass" t-value="'o_stock_reports_domain_line_0'"/> @@ -53,7 +53,7 @@ </td> </t> <td> - <t t-if="l.model == 'stock.pack.operation'"> + <t t-if="l.model == 'stock.move.line'"> <span t-if="l.stream == 'downstream'" class="o_stock_reports_stream text-muted" data-stream="upstream" title="Upstream Traceability"><i class="fa fa-arrow-up"></i></span> <span t-if="l.stream == 'upstream'" class="o_stock_reports_stream" data-stream="downstream" title="Downstream Traceability"><i class="fa fa-arrow-down"></i></span> </t> diff --git a/addons/stock/test/packing.yml b/addons/stock/test/packing.yml index 3f8dfddde45..b1c18b0d767 100644 --- a/addons/stock/test/packing.yml +++ b/addons/stock/test/packing.yml @@ -36,7 +36,7 @@ - !python {model: stock.picking, id: pick1}: | #Change quantity of first to 120 and create 2 others quant operations - stock_pack = self.env['stock.pack.operation'] + stock_pack = self.env['stock.move.line'] stock_quant_pack = self.env['stock.quant.package'] #create lot A lot_a = self.env['stock.production.lot'].create({'name': 'Lot A', 'product_id': ref('product1')}) @@ -46,7 +46,7 @@ package3 = stock_quant_pack.create({'name': 'Pallet 3'}) #Create package for each line and assign it as result_package_id #create pack operation - self.pack_operation_ids[0].write({'result_package_id': package1.id, 'qty_done': 120}) + self.move_line_ids[0].write({'result_package_id': package1.id, 'qty_done': 120}) new_pack1 = stock_pack.create({ 'product_id': ref('product1'), 'product_uom_id': ref('product.product_uom_unit'), @@ -114,7 +114,7 @@ Instead of doing the 300 pieces, you decide to take pallet 1 (do not mention product in operation here) and 20 pieces from lot A and 10 pieces from pallet 3 - !python {model: stock.picking, id: delivery_order1}: | - for rec in self.pack_operation_ids: + for rec in self.move_line_ids: if rec.package_id.name == 'Pallet 1': rec.qty_done = 120 if rec.package_id.name == 'Pallet 2': @@ -146,8 +146,8 @@ assert backorders, "Backorder should have been created" backorders.action_assign() picking = backorders[0] - assert len(picking.pack_operation_ids) == 2, "Wrong number of pack operation" - for pack_op in picking.pack_operation_ids: + assert len(picking.move_line_ids) == 2, "Wrong number of pack operation" + for pack_op in picking.move_line_ids: assert pack_op.package_id.name in ('Pallet 2', 'Pallet 3'), "Wrong pallet info in pack operation (%s found)" % (pack_op.package_id.name) if pack_op.package_id.name == 'Pallet 2': assert pack_op.product_qty == 100 diff --git a/addons/stock/test/packingneg.yml b/addons/stock/test/packingneg.yml index eb25bcc580b..49931e0b1ca 100644 --- a/addons/stock/test/packingneg.yml +++ b/addons/stock/test/packingneg.yml @@ -36,7 +36,7 @@ - !python {model: stock.picking, id: pick_neg}: | #Change quantity of first to 120 and create 2 others quant operations - stock_pack = self.env['stock.pack.operation'] + stock_pack = self.env['stock.move.line'] stock_quant_pack = self.env['stock.quant.package'] #create lot A lot_a = self.env['stock.production.lot'].create({'name': 'Lot neg', 'product_id': ref('product_neg')}) @@ -46,7 +46,7 @@ package3 = stock_quant_pack.create({'name': 'Palneg 3'}) #Create package for each line and assign it as result_package_id #create pack operation - self.pack_operation_ids[0].write({'result_package_id': package1.id, 'qty_done': 120}) + self.move_line_ids[0].write({'result_package_id': package1.id, 'qty_done': 120}) new_pack1 = stock_pack.create({ 'product_id': ref('product_neg'), 'product_uom_id': ref('product.product_uom_unit'), @@ -93,7 +93,7 @@ Instead of doing the 300 pieces, you decide to take pallet 1 (do not mention product in operation here) and 140 pieces from lot A/pallet 2 and 10 pieces from pallet 3 - !python {model: stock.picking, id: delivery_order_neg}: | - for rec in self.pack_operation_ids: + for rec in self.move_line_ids: if rec.package_id.name == 'Palneg 1': rec.qty_done = rec.product_qty elif rec.package_id.name == 'Palneg 2' and rec.lot_id.name == 'Lot neg' : @@ -142,7 +142,7 @@ pack_obj = self.env["stock.quant.package"] lot = self.env["stock.production.lot"].search([('product_id', '=', ref('product_neg')), ('name','=','Lot neg')], limit=1) pack = pack_obj.search([('name', '=', 'Palneg 2')], limit=1) - self.pack_operation_ids[0].write({'lot_id': lot.id, 'qty_done': 20.0, 'result_package_id': pack.id}) + self.move_line_ids[0].write({'lot_id': lot.id, 'qty_done': 20.0, 'result_package_id': pack.id}) self.do_transfer() - Check the negative quant was reconciled diff --git a/addons/stock/test/wiseoperator.yml b/addons/stock/test/wiseoperator.yml index ec7cfc2e1da..b79072a9699 100644 --- a/addons/stock/test/wiseoperator.yml +++ b/addons/stock/test/wiseoperator.yml @@ -29,10 +29,10 @@ Put 4 pieces in shelf1 and 6 pieces in shelf2 - !python {model: stock.picking, id: pick1_wise}: | - stock_pack = self.env['stock.pack.operation'] + stock_pack = self.env['stock.move.line'] stock_quant_pack = self.env['stock.quant.package'] package1 = stock_quant_pack.create({'name': 'Pack 1'}) - self.pack_operation_ids[0].write({ + self.move_line_ids[0].write({ 'result_package_id': package1.id, 'qty_done': 4, 'location_dest_id': ref('stock_location_components') @@ -102,8 +102,8 @@ picking2 = self.browse(ref('delivery_order_wise2')) move1 = picking1.move_lines[0] move2 = picking2.move_lines[0] - pack_ids1 = picking1.pack_operation_ids - pack_ids2 = picking2.pack_operation_ids + pack_ids1 = picking1.move_line_ids + pack_ids2 = picking2.move_line_ids assert pack_ids1.location_id.id == ref('stock_location_14') assert set(pack_ids2.mapped('location_id.id')) == set([ref('stock_location_components'), ref('stock_location_14')]) @@ -114,7 +114,7 @@ new_pack_id1.qty_done = new_pack_id1.product_qty new_pack_id1.with_context(bypass_reservation_update=True).product_uom_qty = 0 - new_move_lines = picking1.pack_operation_ids.filtered(lambda p: p.qty_done) + new_move_lines = picking1.move_line_ids.filtered(lambda p: p.qty_done) assert sum(new_move_lines.mapped('product_qty')) == 0 assert sum(new_move_lines.mapped('qty_done')) == 5 assert set(new_move_lines.mapped('location_id.id')) == set([ref('stock_location_components'), ref('stock_location_14')]) @@ -124,7 +124,7 @@ new_pack_id2.qty_done = new_pack_id2.product_qty new_pack_id2.with_context(bypass_reservation_update=True).product_uom_qty = 0 - new_move_lines = picking2.pack_operation_ids.filtered(lambda p: p.qty_done) + new_move_lines = picking2.move_line_ids.filtered(lambda p: p.qty_done) assert len(new_move_lines) == 1 assert sum(new_move_lines.mapped('product_qty')) == 0 assert sum(new_move_lines.mapped('qty_done')) == 5 diff --git a/addons/stock/tests/common.py b/addons/stock/tests/common.py index ec11da4eafc..f10c42db152 100644 --- a/addons/stock/tests/common.py +++ b/addons/stock/tests/common.py @@ -12,7 +12,7 @@ class TestStockCommon(common.TransactionCase): self.UomObj = self.env['product.uom'] self.PartnerObj = self.env['res.partner'] self.ModelDataObj = self.env['ir.model.data'] - self.StockPackObj = self.env['stock.pack.operation'] + self.StockPackObj = self.env['stock.move.line'] self.StockQuantObj = self.env['stock.quant'] self.PickingObj = self.env['stock.picking'] self.MoveObj = self.env['stock.move'] diff --git a/addons/stock/tests/common2.py b/addons/stock/tests/common2.py index 65dc08cecfa..58ebe96f6c6 100644 --- a/addons/stock/tests/common2.py +++ b/addons/stock/tests/common2.py @@ -6,7 +6,7 @@ from odoo.addons.product.tests import common class TestStockCommon(common.TestProductCommon): def _create_pack_operation(self, product, product_qty, picking_id, **values): - PackOperation = self.env['stock.pack.operation'].sudo(self.user_stock_manager) + PackOperation = self.env['stock.move.line'].sudo(self.user_stock_manager) vals = { 'picking_id': picking_id.id, 'product_id': product.id, diff --git a/addons/stock/tests/test_move.py b/addons/stock/tests/test_move.py index cde1160a82c..3c1a87e1518 100644 --- a/addons/stock/tests/test_move.py +++ b/addons/stock/tests/test_move.py @@ -53,10 +53,10 @@ class StockMove(TransactionCase): # assignment move1.action_assign() self.assertEqual(move1.state, 'assigned') - self.assertEqual(len(move1.pack_operation_ids), 1) + self.assertEqual(len(move1.move_line_ids), 1) # fill the move line - move_line = move1.pack_operation_ids[0] + move_line = move1.move_line_ids[0] self.assertEqual(move_line.product_qty, 100.0) self.assertEqual(move_line.qty_done, 0.0) move_line.qty_done = 100.0 @@ -94,8 +94,8 @@ class StockMove(TransactionCase): # assignment move1.action_assign() self.assertEqual(move1.state, 'assigned') - self.assertEqual(len(move1.pack_operation_ids), 1) - move_line = move1.pack_operation_ids[0] + self.assertEqual(len(move1.move_line_ids), 1) + move_line = move1.move_line_ids[0] self.assertEqual(move_line.product_qty, 5) move_line.lot_name = 'lot1' move_line.qty_done = 5.0 @@ -134,12 +134,12 @@ class StockMove(TransactionCase): # assignment move1.action_assign() self.assertEqual(move1.state, 'assigned') - self.assertEqual(len(move1.pack_operation_ids), 5) - move_line = move1.pack_operation_ids[0] + self.assertEqual(len(move1.move_line_ids), 5) + move_line = move1.move_line_ids[0] self.assertEqual(move1.reserved_availability, 5) i = 0 - for move_line in move1.pack_operation_ids: + for move_line in move1.move_line_ids: move_line.lot_name = 'sn%s' % i move_line.qty_done = 1 i += 1 @@ -186,13 +186,13 @@ class StockMove(TransactionCase): # assignment move1.action_assign() self.assertEqual(move1.state, 'assigned') - self.assertEqual(len(move1.pack_operation_ids), 1) + self.assertEqual(len(move1.move_line_ids), 1) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0) # Should be a reserved quantity and thus a quant. self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.stock_location)), 1.0) # fill the move line - move_line = move1.pack_operation_ids[0] + move_line = move1.move_line_ids[0] self.assertEqual(move_line.product_qty, 100.0) self.assertEqual(move_line.qty_done, 0.0) move_line.qty_done = 100.0 @@ -235,13 +235,13 @@ class StockMove(TransactionCase): # assignment move1.action_assign() self.assertEqual(move1.state, 'assigned') - self.assertEqual(len(move1.pack_operation_ids), 1) + self.assertEqual(len(move1.move_line_ids), 1) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0) # Should be a reserved quantity and thus a quant. self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.stock_location)), 0.0) # fill the move line - move_line = move1.pack_operation_ids[0] + move_line = move1.move_line_ids[0] self.assertEqual(move_line.product_qty, 100.0) self.assertEqual(move_line.qty_done, 0.0) move_line.qty_done = 100.0 @@ -281,7 +281,7 @@ class StockMove(TransactionCase): move1.action_confirm() move1.action_assign() - self.assertEqual(len(move1.pack_operation_ids), 2) + self.assertEqual(len(move1.move_line_ids), 2) def test_mixed_tracking_reservation_2(self): """ Send products tracked by lot to a customer. In your stock, there two tracked and @@ -313,8 +313,8 @@ class StockMove(TransactionCase): }) move1.action_confirm() move1.action_assign() - self.assertEqual(len(move1.pack_operation_ids), 4) - for ml in move1.pack_operation_ids: + self.assertEqual(len(move1.move_line_ids), 4) + for ml in move1.move_line_ids: self.assertEqual(ml.product_qty, 1.0) # assign lot3 and lot 4 to both untracked move lines @@ -326,10 +326,10 @@ class StockMove(TransactionCase): 'name': 'lot4', 'product_id': self.product2.id, }) - untracked_move_line = move1.pack_operation_ids.filtered(lambda ml: not ml.lot_id) + untracked_move_line = move1.move_line_ids.filtered(lambda ml: not ml.lot_id) untracked_move_line[0].lot_id = lot3 untracked_move_line[1].lot_id = lot4 - for ml in move1.pack_operation_ids: + for ml in move1.move_line_ids: self.assertEqual(ml.product_qty, 1.0) # no changes on quants, even if i made some move lines with a lot id whom reserved on untracked quants @@ -339,7 +339,7 @@ class StockMove(TransactionCase): self.assertEqual(len(self.env['stock.quant']._gather(self.product2, self.stock_location, lot_id=lot3, strict=True)), 0) self.assertEqual(len(self.env['stock.quant']._gather(self.product2, self.stock_location, lot_id=lot4, strict=True)), 0) - move1.pack_operation_ids.write({'qty_done': 1.0}) + move1.move_line_ids.write({'qty_done': 1.0}) move1.action_done() @@ -378,7 +378,7 @@ class StockMove(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.write({'qty_done': 1.0}) + move1.move_line_ids.write({'qty_done': 1.0}) move1.action_done() self.env['stock.quant']._increase_available_quantity(self.product2, self.stock_location, 2) @@ -391,7 +391,7 @@ class StockMove(TransactionCase): 'product_id': self.product2.id, }) - self.env['stock.pack.operation'].create({ + self.env['stock.move.line'].create({ 'move_id': move1.id, 'product_id': move1.product_id.id, 'qty_done': 1, @@ -400,7 +400,7 @@ class StockMove(TransactionCase): 'location_dest_id': move1.location_dest_id.id, 'lot_id': lot3.id, }) - self.env['stock.pack.operation'].create({ + self.env['stock.move.line'].create({ 'move_id': move1.id, 'product_id': move1.product_id.id, 'qty_done': 1, @@ -445,7 +445,7 @@ class StockMove(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.write({'qty_done': 1.0}) + move1.move_line_ids.write({'qty_done': 1.0}) move1.action_done() self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location), 0.0) @@ -458,7 +458,7 @@ class StockMove(TransactionCase): 'product_id': self.product2.id, }) - move1.with_context(debug=True).pack_operation_ids[1].lot_id = lot3 + move1.with_context(debug=True).move_line_ids[1].lot_id = lot3 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location), 1.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location, lot_id=lot1, strict=True), 0.0) @@ -486,7 +486,7 @@ class StockMove(TransactionCase): }) # create a new move line with a lot not assigned to any quant - self.env['stock.pack.operation'].create({ + self.env['stock.move.line'].create({ 'move_id': move1.id, 'product_id': move1.product_id.id, 'qty_done': 1, @@ -495,7 +495,7 @@ class StockMove(TransactionCase): 'location_dest_id': move1.location_dest_id.id, 'lot_id': lot1.id }) - self.assertEqual(len(move1.pack_operation_ids), 1) + self.assertEqual(len(move1.move_line_ids), 1) self.assertEqual(move1.reserved_availability, 0) # validating the move line should move the lot, not create a negative quant in stock @@ -527,7 +527,7 @@ class StockMove(TransactionCase): 'product_id': self.product2.id, }) - move_line = move1.pack_operation_ids + move_line = move1.move_line_ids move_line.lot_id = lot1 self.assertEqual(move_line.product_qty, 1.0) move_line.lot_id = lot2 @@ -576,10 +576,10 @@ class StockMove(TransactionCase): # assignment move1.action_assign() self.assertEqual(move1.state, 'assigned') - self.assertEqual(len(move1.pack_operation_ids), 1) + self.assertEqual(len(move1.move_line_ids), 1) # check if the putaway was rightly applied - self.assertEqual(move1.pack_operation_ids.location_dest_id.id, shelf1_location.id) + self.assertEqual(move1.move_line_ids.location_dest_id.id, shelf1_location.id) def test_availability_1(self): """ Check that the `availability` field on a move is correctly computed when there is @@ -650,12 +650,12 @@ class StockMove(TransactionCase): # assignment move1.action_assign() self.assertEqual(move1.state, 'assigned') - self.assertEqual(len(move1.pack_operation_ids), 1) + 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() - self.assertEqual(len(move1.pack_operation_ids), 0) + 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') @@ -688,12 +688,12 @@ class StockMove(TransactionCase): # assignment move1.action_assign() self.assertEqual(move1.state, 'assigned') - self.assertEqual(len(move1.pack_operation_ids), 1) + 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() - self.assertEqual(len(move1.pack_operation_ids), 0) + 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') @@ -723,7 +723,7 @@ class StockMove(TransactionCase): # assignment move1.action_assign() self.assertEqual(move1.state, 'assigned') - self.assertEqual(len(move1.pack_operation_ids), 1) + self.assertEqual(len(move1.move_line_ids), 1) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0) quants = self.env['stock.quant']._gather(self.product1, self.stock_location) @@ -736,7 +736,7 @@ class StockMove(TransactionCase): self.assertEqual(len(quants), 1.0) self.assertEqual(quants.quantity, 2.0) self.assertEqual(quants.reserved_quantity, 0.0) - self.assertEqual(len(move1.pack_operation_ids), 0.0) + self.assertEqual(len(move1.move_line_ids), 0.0) def test_unreserve_4(self): """ Check the unreservation of a partially available stock move. @@ -764,7 +764,7 @@ class StockMove(TransactionCase): # assignment move1.action_assign() self.assertEqual(move1.state, 'partially_available') - self.assertEqual(len(move1.pack_operation_ids), 1) + self.assertEqual(len(move1.move_line_ids), 1) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0) quants = self.env['stock.quant']._gather(self.product1, self.stock_location) @@ -777,7 +777,7 @@ class StockMove(TransactionCase): self.assertEqual(len(quants), 1.0) self.assertEqual(quants.quantity, 2.0) self.assertEqual(quants.reserved_quantity, 0.0) - self.assertEqual(len(move1.pack_operation_ids), 0.0) + self.assertEqual(len(move1.move_line_ids), 0.0) def test_link_assign_1(self): """ Test the assignment mechanism when two chained stock moves try to move one unit of an @@ -808,10 +808,10 @@ class StockMove(TransactionCase): (move_stock_pack + move_pack_cust).action_confirm() move_stock_pack.action_assign() - move_stock_pack.pack_operation_ids[0].qty_done = 1.0 + move_stock_pack.move_line_ids[0].qty_done = 1.0 move_stock_pack.action_done() - self.assertEqual(len(move_pack_cust.pack_operation_ids), 1) - move_line = move_pack_cust.pack_operation_ids[0] + 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) self.assertEqual(move_line.location_dest_id.id, self.customer_location.id) self.assertEqual(move_pack_cust.state, 'assigned') @@ -851,7 +851,7 @@ class StockMove(TransactionCase): (move_stock_pack + move_pack_cust).action_confirm() move_stock_pack.action_assign() - move_line_stock_pack = move_stock_pack.pack_operation_ids[0] + move_line_stock_pack = move_stock_pack.move_line_ids[0] self.assertEqual(move_line_stock_pack.lot_id.id, lot1.id) 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)), 1.0) @@ -862,7 +862,7 @@ class StockMove(TransactionCase): 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) - move_line_pack_cust = move_pack_cust.pack_operation_ids[0] + move_line_pack_cust = move_pack_cust.move_line_ids[0] self.assertEqual(move_line_pack_cust.lot_id.id, lot1.id) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.pack_location, lot_id=lot1), 0.0) self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.pack_location, lot1)), 1.0) @@ -908,22 +908,22 @@ class StockMove(TransactionCase): # assign and fulfill the first move move_stock_pack_1.action_assign() self.assertEqual(move_stock_pack_1.state, 'assigned') - self.assertEqual(len(move_stock_pack_1.pack_operation_ids), 1) - move_stock_pack_1.pack_operation_ids[0].qty_done = 1.0 + 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() self.assertEqual(move_stock_pack_1.state, 'done') # the destination move should be partially available and have one move line self.assertEqual(move_pack_cust.state, 'partially_available') - self.assertEqual(len(move_pack_cust.pack_operation_ids), 1) + self.assertEqual(len(move_pack_cust.move_line_ids), 1) # Should have 1 quant in stock_location and another in pack_location 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() self.assertEqual(move_stock_pack_2.state, 'assigned') - self.assertEqual(len(move_stock_pack_2.pack_operation_ids), 1) - move_stock_pack_2.pack_operation_ids[0].qty_done = 1.0 + 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() self.assertEqual(move_stock_pack_2.state, 'done') @@ -931,8 +931,8 @@ class StockMove(TransactionCase): self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.pack_location)), 1.0) self.assertEqual(move_pack_cust.state, 'assigned') - self.assertEqual(len(move_pack_cust.pack_operation_ids), 1) - move_line_1 = move_pack_cust.pack_operation_ids[0] + self.assertEqual(len(move_pack_cust.move_line_ids), 1) + move_line_1 = move_pack_cust.move_line_ids[0] self.assertEqual(move_line_1.location_id.id, self.pack_location.id) self.assertEqual(move_line_1.location_dest_id.id, self.customer_location.id) self.assertEqual(move_line_1.product_qty, 2.0) @@ -983,22 +983,22 @@ class StockMove(TransactionCase): # assign and fulfill the first move move_stock_pack_1.action_assign() - self.assertEqual(len(move_stock_pack_1.pack_operation_ids), 1) - self.assertEqual(move_stock_pack_1.pack_operation_ids[0].lot_id.id, lot1.id) - move_stock_pack_1.pack_operation_ids[0].qty_done = 1.0 + 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() # the destination move should be partially available and have one move line - self.assertEqual(len(move_pack_cust.pack_operation_ids), 1) + self.assertEqual(len(move_pack_cust.move_line_ids), 1) move_stock_pack_2.action_assign() - self.assertEqual(len(move_stock_pack_2.pack_operation_ids), 1) - self.assertEqual(move_stock_pack_2.pack_operation_ids[0].lot_id.id, lot1.id) - move_stock_pack_2.pack_operation_ids[0].qty_done = 1.0 + 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() - self.assertEqual(len(move_pack_cust.pack_operation_ids), 1) - move_line_1 = move_pack_cust.pack_operation_ids[0] + self.assertEqual(len(move_pack_cust.move_line_ids), 1) + move_line_1 = move_pack_cust.move_line_ids[0] self.assertEqual(move_line_1.location_id.id, self.pack_location.id) self.assertEqual(move_line_1.location_dest_id.id, self.customer_location.id) self.assertEqual(move_line_1.product_qty, 2.0) @@ -1044,16 +1044,16 @@ class StockMove(TransactionCase): # assign and fulfill the first move move_stock_pack.action_assign() - self.assertEqual(len(move_stock_pack.pack_operation_ids), 1) - move_stock_pack.pack_operation_ids[0].qty_done = 2.0 + 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() # the destination moves should be available and have one move line - self.assertEqual(len(move_pack_cust_1.pack_operation_ids), 1) - self.assertEqual(len(move_pack_cust_2.pack_operation_ids), 1) + self.assertEqual(len(move_pack_cust_1.move_line_ids), 1) + self.assertEqual(len(move_pack_cust_2.move_line_ids), 1) - move_pack_cust_1.pack_operation_ids[0].qty_done = 1.0 - move_pack_cust_2.pack_operation_ids[0].qty_done = 1.0 + 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() def test_link_assign_6(self): @@ -1106,7 +1106,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.pack_operation_ids.qty_done = 3.0 + move_supp_stock_1.move_line_ids.qty_done = 3.0 move_supp_stock_1.action_done() self.assertEqual(move_supp_stock_1.state, 'done') self.assertEqual(move_supp_stock_2.state, 'confirmed') @@ -1152,7 +1152,7 @@ class StockMove(TransactionCase): self.assertEqual(move2.state, 'assigned') # use the product from the first one - move2.write({'pack_operation_ids': [(0, 0, { + move2.write({'move_line_ids': [(0, 0, { 'product_id': self.product1.id, 'product_uom_id': self.uom_unit.id, 'qty_done': 1, @@ -1213,7 +1213,7 @@ class StockMove(TransactionCase): self.assertEqual(move2.state, 'assigned') # use the product from the first one - move2.write({'pack_operation_ids': [(0, 0, { + move2.write({'move_line_ids': [(0, 0, { 'product_id': self.product1.id, 'product_uom_id': self.uom_unit.id, 'qty_done': 1, @@ -1266,7 +1266,7 @@ class StockMove(TransactionCase): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf2_location), 1.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0) - move1.pack_operation_ids.location_id = shelf2_location.id + move1.move_line_ids.location_id = shelf2_location.id self.assertEqual(move1.reserved_availability, 1.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf1_location), 1.0) @@ -1307,7 +1307,7 @@ class StockMove(TransactionCase): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, lot_id=lot1), 0.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, lot_id=lot2), 1.0) - move1.pack_operation_ids.lot_id = lot2.id + move1.move_line_ids.lot_id = lot2.id self.assertEqual(move1.reserved_availability, 1.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0) @@ -1342,7 +1342,7 @@ class StockMove(TransactionCase): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, package_id=package1), 0.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, package_id=package2), 1.0) - move1.pack_operation_ids.package_id = package2.id + move1.move_line_ids.package_id = package2.id self.assertEqual(move1.reserved_availability, 1.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0) @@ -1377,7 +1377,7 @@ class StockMove(TransactionCase): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, owner_id=owner1), 0.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, owner_id=owner2), 1.0) - move1.pack_operation_ids.owner_id = owner2.id + move1.move_line_ids.owner_id = owner2.id self.assertEqual(move1.reserved_availability, 1.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0) @@ -1419,7 +1419,7 @@ class StockMove(TransactionCase): 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) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, lot_id=lot2), 1.0) - move_line = move1.pack_operation_ids[0] + move_line = move1.move_line_ids[0] move_line.write({'package_id': False, 'lot_id': lot2.id}) self.assertEqual(move1.reserved_availability, 1.0) @@ -1462,7 +1462,7 @@ class StockMove(TransactionCase): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf2_location), 0.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0) - move1.pack_operation_ids.location_id = shelf2_location.id + move1.move_line_ids.location_id = shelf2_location.id self.assertEqual(move1.reserved_availability, 0.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0) @@ -1501,8 +1501,8 @@ class StockMove(TransactionCase): # assignment move1.action_assign() self.assertEqual(move1.state, 'assigned') - self.assertEqual(len(move1.pack_operation_ids), 1) - move_line = move1.pack_operation_ids[0] + self.assertEqual(len(move1.move_line_ids), 1) + move_line = move1.move_line_ids[0] self.assertEqual(move_line.product_qty, 5) move_line.qty_done = 5.0 self.assertEqual(move_line.product_qty, 5) # don't change reservation @@ -1554,11 +1554,11 @@ class StockMove(TransactionCase): # assignment move1.action_assign() self.assertEqual(move1.state, 'assigned') - self.assertEqual(len(move1.pack_operation_ids), 2) + self.assertEqual(len(move1.move_line_ids), 2) tracked_move_line = None untracked_move_line = None - for move_line in move1.pack_operation_ids: + for move_line in move1.move_line_ids: if move_line.lot_id: tracked_move_line = move_line else: @@ -1617,7 +1617,7 @@ class StockMove(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.qty_done = 1 + move1.move_line_ids.qty_done = 1 move1.action_done() self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf1_location), 0.0) @@ -1625,7 +1625,7 @@ class StockMove(TransactionCase): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0) # edit once done, we actually moved from shelf2 - move1.pack_operation_ids.location_id = shelf2_location.id + move1.move_line_ids.location_id = shelf2_location.id self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf1_location), 1.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf2_location), 0.0) @@ -1659,14 +1659,14 @@ class StockMove(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.qty_done = 1 + move1.move_line_ids.qty_done = 1 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) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, lot_id=lot2), 1.0) - move1.pack_operation_ids.lot_id = lot2.id + move1.move_line_ids.lot_id = lot2.id self.assertEqual(move1.reserved_availability, 1.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0) @@ -1696,14 +1696,14 @@ class StockMove(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.qty_done = 1 + move1.move_line_ids.qty_done = 1 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) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, package_id=package2), 1.0) - move1.pack_operation_ids.package_id = package2.id + move1.move_line_ids.package_id = package2.id 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), 1.0) @@ -1732,14 +1732,14 @@ class StockMove(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.qty_done = 1 + move1.move_line_ids.qty_done = 1 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) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, owner_id=owner2), 1.0) - move1.pack_operation_ids.owner_id = owner2.id + move1.move_line_ids.owner_id = owner2.id 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), 1.0) @@ -1776,13 +1776,13 @@ class StockMove(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.qty_done = 1 + move1.move_line_ids.qty_done = 1 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) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location, lot_id=lot2), 1.0) - move_line = move1.pack_operation_ids[0] + move_line = move1.move_line_ids[0] move_line.write({'package_id': False, 'lot_id': lot2.id}) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0) @@ -1819,14 +1819,14 @@ class StockMove(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.qty_done = 1 + move1.move_line_ids.qty_done = 1 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) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0) - move1.pack_operation_ids.location_id = shelf2_location.id + move1.move_line_ids.location_id = shelf2_location.id self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf1_location), 1.0) @@ -1864,7 +1864,7 @@ class StockMove(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.qty_done = 1 + move1.move_line_ids.qty_done = 1 move1.action_done() move2 = self.env['stock.move'].create({ @@ -1883,7 +1883,7 @@ class StockMove(TransactionCase): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf2_location), 0.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0) - move1.pack_operation_ids.location_id = shelf2_location.id + move1.move_line_ids.location_id = shelf2_location.id 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, shelf1_location), 1.0) @@ -1915,14 +1915,14 @@ class StockMove(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.qty_done = 1 + move1.move_line_ids.qty_done = 1 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, self.stock_location), 0.0) # edit once done, we actually moved 2 products - move1.pack_operation_ids.qty_done = 2 + move1.move_line_ids.qty_done = 2 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf1_location), -1.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), -1.0) @@ -1951,14 +1951,14 @@ class StockMove(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.qty_done = 1 + move1.move_line_ids.qty_done = 1 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, self.stock_location), 0.0) # edit once done, we actually moved 2 products - move1.pack_operation_ids.qty_done = 0 + move1.move_line_ids.qty_done = 0 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, shelf1_location), 1.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 1.0) @@ -1978,14 +1978,14 @@ class StockMove(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.qty_done = 10 + move1.move_line_ids.qty_done = 10 move1.action_done() quant = self.env['stock.quant']._gather(self.product1, self.stock_location) self.assertEqual(len(quant), 1.0) # edit once done, we actually moved 2 products - move1.pack_operation_ids.qty_done = 0 + move1.move_line_ids.qty_done = 0 quant = self.env['stock.quant']._gather(self.product1, self.stock_location) self.assertEqual(len(quant), 0.0) @@ -2012,20 +2012,20 @@ class StockMove(TransactionCase): }) picking.action_confirm() picking.action_assign() - move1.pack_operation_ids.qty_done = 10 + move1.move_line_ids.qty_done = 10 picking.action_done() self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 10.0) - self.env['stock.pack.operation'].create({ - 'picking_id': move1.pack_operation_ids.picking_id.id, - 'move_id': move1.pack_operation_ids.move_id.id, - 'product_id': move1.pack_operation_ids.product_id.id, - 'qty_done': move1.pack_operation_ids.qty_done, + self.env['stock.move.line'].create({ + 'picking_id': move1.move_line_ids.picking_id.id, + 'move_id': move1.move_line_ids.move_id.id, + 'product_id': move1.move_line_ids.product_id.id, + 'qty_done': move1.move_line_ids.qty_done, 'product_uom_id': move1.product_uom.id, - 'location_id': move1.pack_operation_ids.location_id.id, - 'location_dest_id': move1.pack_operation_ids.location_dest_id.id, + 'location_id': move1.move_line_ids.location_id.id, + 'location_dest_id': move1.move_line_ids.location_dest_id.id, }) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 20.0) - move1.pack_operation_ids[1].qty_done = 5 + move1.move_line_ids[1].qty_done = 5 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 15.0) def test_immediate_validate_1(self): @@ -2088,9 +2088,9 @@ class StockMove(TransactionCase): wizard = self.env[(res_dict.get('res_model'))].browse(res_dict.get('res_id')) wizard.process() - self.assertEqual(len(picking.move_lines.pack_operation_ids), 1) + self.assertEqual(len(picking.move_lines.move_line_ids), 1) self.assertEqual(picking.move_lines.quantity_done, 5.0) - self.assertEqual(picking.move_lines.pack_operation_ids.qty_done, 5.0) + self.assertEqual(picking.move_lines.move_line_ids.qty_done, 5.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0) self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.stock_location)), 0.0) @@ -2101,7 +2101,7 @@ class StockMove(TransactionCase): def test_immediate_validate_3(self): """ Create a picking and simulates validate button effect. In case of a force assign it should ignore the reserved quantity and set - the quantity done to the initial demand. It should also create the pack_operation line. + the quantity done to the initial demand. It should also create the move line. """ owner = self.env['res.partner'].create({'name': 'Jean'}) picking = self.env['stock.picking'].create({ @@ -2128,9 +2128,9 @@ class StockMove(TransactionCase): self.assertEqual(picking.move_lines.quantity_done, 10.0) # Check move_lines data - self.assertEqual(len(picking.move_lines.pack_operation_ids), 1) - self.assertEqual(picking.move_lines.pack_operation_ids.qty_done, 10.0) - self.assertEqual(picking.move_lines.pack_operation_ids.product_qty, 0.0) + self.assertEqual(len(picking.move_lines.move_line_ids), 1) + self.assertEqual(picking.move_lines.move_line_ids.qty_done, 10.0) + self.assertEqual(picking.move_lines.move_line_ids.product_qty, 0.0) # Check quants data self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), -10.0) self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.stock_location)), 1.0) @@ -2167,15 +2167,15 @@ class StockMove(TransactionCase): picking.action_assign() with self.assertRaises(UserError): picking.button_validate() - picking.move_lines.pack_operation_ids[0].qty_done = 5.0 + picking.move_lines.move_line_ids[0].qty_done = 5.0 # We do not need to catch wizard since everything is already defined and the action_done will be processed immediately picking.button_validate() self.assertEqual(picking.move_lines.quantity_done, 5.0) # Check move_lines data - self.assertEqual(len(picking.move_lines.pack_operation_ids), 1) - self.assertEqual(picking.move_lines.pack_operation_ids.lot_id, lot1) - self.assertEqual(picking.move_lines.pack_operation_ids.qty_done, 5.0) + self.assertEqual(len(picking.move_lines.move_line_ids), 1) + self.assertEqual(picking.move_lines.move_line_ids.lot_id, lot1) + self.assertEqual(picking.move_lines.move_line_ids.qty_done, 5.0) # Check quants data self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0) self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.stock_location)), 0.0) diff --git a/addons/stock/tests/test_move2.py b/addons/stock/tests/test_move2.py index e0e7c1204e6..6a0f6ff86bd 100644 --- a/addons/stock/tests/test_move2.py +++ b/addons/stock/tests/test_move2.py @@ -54,13 +54,13 @@ class TestPickShip(TestStockCommon): # make some stock self.env['stock.quant']._increase_available_quantity(self.productA, location, 10.0) picking_pick.action_assign() - picking_pick.move_lines[0].pack_operation_ids[0].qty_done = 10.0 + picking_pick.move_lines[0].move_line_ids[0].qty_done = 10.0 picking_pick.do_transfer() self.assertEqual(picking_client.state, 'assigned', 'The state of the client should be assigned') # Now partially transfer the ship - picking_client.move_lines[0].pack_operation_ids[0].qty_done = 5 + picking_client.move_lines[0].move_line_ids[0].qty_done = 5 picking_client.do_transfer() # no new in order to create backorder backorder = self.env['stock.picking'].search([('backorder_id', '=', picking_client.id)]) @@ -90,7 +90,7 @@ class TestPickShip(TestStockCommon): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, stock_location), 0.0) self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), 5.0) - move_pick.pack_operation_ids[0].qty_done = 10.0 + move_pick.move_line_ids[0].qty_done = 10.0 picking_pick.do_transfer() self.assertEqual(move_pick.state, 'done') @@ -108,7 +108,7 @@ class TestPickShip(TestStockCommon): self.env['stock.quant']._increase_available_quantity(self.productA, stock_location, 10.0) picking_pick.action_assign() - picking_pick.move_lines[0].pack_operation_ids[0].qty_done = 10.0 + picking_pick.move_lines[0].move_line_ids[0].qty_done = 10.0 picking_pick.do_transfer() self.assertEqual(picking_pick.state, 'done') self.assertEqual(picking_client.state, 'assigned') @@ -120,7 +120,7 @@ class TestPickShip(TestStockCommon): stock_return_picking.product_return_moves.quantity = 2.0 # Return only 2 stock_return_picking_action = stock_return_picking.create_returns() return_pick = self.env['stock.picking'].browse(stock_return_picking_action['res_id']) - return_pick.move_lines[0].pack_operation_ids[0].qty_done = 2.0 + return_pick.move_lines[0].move_line_ids[0].qty_done = 2.0 return_pick.do_transfer() # the client picking should not be assigned anymore, as we returned partially what we took self.assertEqual(picking_client.state, 'confirmed') @@ -137,13 +137,13 @@ class TestPickShip(TestStockCommon): # make some stock self.env['stock.quant']._increase_available_quantity(self.productA, location, 10.0) picking_pick.action_assign() - picking_pick.move_lines[0].pack_operation_ids[0].qty_done = 5.0 + picking_pick.move_lines[0].move_line_ids[0].qty_done = 5.0 # create a backorder picking_pick.do_transfer() picking_pick_backorder = self.env['stock.picking'].search([('backorder_id', '=', picking_pick.id)]) self.assertEqual(picking_pick_backorder.state, 'assigned') - self.assertEqual(picking_pick_backorder.pack_operation_ids.product_qty, 5.0) + self.assertEqual(picking_pick_backorder.move_line_ids.product_qty, 5.0) self.assertEqual(picking_client.state, 'partially_available') @@ -255,7 +255,7 @@ class TestSinglePicking(TestStockCommon): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), 0.0) # valid with backorder creation - delivery_order.move_lines[0].pack_operation_ids[0].qty_done = 1 + delivery_order.move_lines[0].move_line_ids[0].qty_done = 1 delivery_order.do_transfer() self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), 0.0) @@ -292,7 +292,7 @@ class TestSinglePicking(TestStockCommon): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), 0.0) # valid with backorder creation - delivery_order.move_lines[0].pack_operation_ids[0].qty_done = 1 + delivery_order.move_lines[0].move_line_ids[0].qty_done = 1 delivery_order.do_transfer() self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), 0.0) @@ -332,19 +332,19 @@ class TestSinglePicking(TestStockCommon): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), 0.0) # valid with backorder creation - delivery_order.move_lines[0].pack_operation_ids[0].qty_done = 2 + delivery_order.move_lines[0].move_line_ids[0].qty_done = 2 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), 0.0) delivery_order.with_context(debug=True).do_transfer() self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), -1.0) extra_move = delivery_order.move_lines - move1 - extra_move_line = extra_move.pack_operation_ids[0] + extra_move_line = extra_move.move_line_ids[0] # self.assertEqual(move1.product_qty, 1.0) # self.assertEqual(move1.quantity_done, 1.0) self.assertEqual(move1.reserved_availability, 1.0) - self.assertEqual(move1.pack_operation_ids.product_qty, 1.0) # should keep the reservation - self.assertEqual(move1.pack_operation_ids.qty_done, 1.0) + self.assertEqual(move1.move_line_ids.product_qty, 1.0) # should keep the reservation + self.assertEqual(move1.move_line_ids.qty_done, 1.0) self.assertEqual(move1.state, 'done') self.assertEqual(extra_move.product_qty, 1.0) @@ -387,19 +387,19 @@ class TestSinglePicking(TestStockCommon): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), 0.0) # valid with backorder creation - delivery_order.move_lines[0].pack_operation_ids[0].qty_done = 3 + delivery_order.move_lines[0].move_line_ids[0].qty_done = 3 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), 0.0) delivery_order.do_transfer() self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, pack_location), -2.0) extra_move = delivery_order.move_lines - move1 - extra_move_line = extra_move.pack_operation_ids[0] + extra_move_line = extra_move.move_line_ids[0] self.assertEqual(move1.product_qty, 1.0) self.assertEqual(move1.quantity_done, 1.0) self.assertEqual(move1.reserved_availability, 1.0) - self.assertEqual(move1.pack_operation_ids.product_qty, 1.0) # should keep the reservation - self.assertEqual(move1.pack_operation_ids.qty_done, 1.0) + self.assertEqual(move1.move_line_ids.product_qty, 1.0) # should keep the reservation + self.assertEqual(move1.move_line_ids.qty_done, 1.0) self.assertEqual(move1.state, 'done') self.assertEqual(extra_move.product_qty, 2.0) @@ -436,18 +436,18 @@ class TestSinglePicking(TestStockCommon): self.assertEqual(receipt.state, 'assigned') # valid with backorder creation - receipt.move_lines[0].pack_operation_ids[0].qty_done = 2 + receipt.move_lines[0].move_line_ids[0].qty_done = 2 receipt.with_context(debug=True).do_transfer() self.assertEqual(self.env['stock.quant']._get_available_quantity(self.productA, stock_location), 2.0) extra_move = receipt.move_lines - move1 - extra_move_line = extra_move.pack_operation_ids[0] + extra_move_line = extra_move.move_line_ids[0] self.assertEqual(move1.product_qty, 1.0) self.assertEqual(move1.quantity_done, 1.0) self.assertEqual(move1.reserved_availability, 1.0) - self.assertEqual(move1.pack_operation_ids.product_qty, 1.0) # should keep the reservation - self.assertEqual(move1.pack_operation_ids.qty_done, 1.0) + self.assertEqual(move1.move_line_ids.product_qty, 1.0) # should keep the reservation + self.assertEqual(move1.move_line_ids.qty_done, 1.0) self.assertEqual(move1.state, 'done') self.assertEqual(extra_move.product_qty, 1.0) @@ -487,8 +487,8 @@ class TestSinglePicking(TestStockCommon): # Check reserved quantity self.assertEqual(move1.reserved_availability, 1.0) - self.assertEqual(len(move1.pack_operation_ids), 1) - self.assertEqual(move1.pack_operation_ids.product_qty, 1) + self.assertEqual(len(move1.move_line_ids), 1) + self.assertEqual(move1.move_line_ids.product_qty, 1) inventory = self.env['stock.inventory'].create({ 'name': 'remove product1', @@ -505,8 +505,8 @@ class TestSinglePicking(TestStockCommon): # Check reserved quantity self.assertEqual(move1.reserved_availability, 2.0) - self.assertEqual(len(move1.pack_operation_ids), 1) - self.assertEqual(move1.pack_operation_ids.product_qty, 2) + self.assertEqual(len(move1.move_line_ids), 1) + self.assertEqual(move1.move_line_ids.product_qty, 2) def test_recheck_availability_2(self): """ Same check than test_recheck_availability_1 but with lot this time. @@ -544,8 +544,8 @@ class TestSinglePicking(TestStockCommon): # Check reserved quantity self.assertEqual(move1.reserved_availability, 1.0) - self.assertEqual(len(move1.pack_operation_ids), 1) - self.assertEqual(move1.pack_operation_ids.product_qty, 1) + self.assertEqual(len(move1.move_line_ids), 1) + self.assertEqual(move1.move_line_ids.product_qty, 1) inventory = self.env['stock.inventory'].create({ 'name': 'remove product1', @@ -563,9 +563,9 @@ class TestSinglePicking(TestStockCommon): # Check reserved quantity self.assertEqual(move1.reserved_availability, 2.0) - self.assertEqual(len(move1.pack_operation_ids), 1) - self.assertEqual(move1.pack_operation_ids.lot_id.id, lot1.id) - self.assertEqual(move1.pack_operation_ids.product_qty, 2) + self.assertEqual(len(move1.move_line_ids), 1) + self.assertEqual(move1.move_line_ids.lot_id.id, lot1.id) + self.assertEqual(move1.move_line_ids.product_qty, 2) def test_recheck_availability_3(self): """ Same check than test_recheck_availability_2 but with different lots. @@ -604,8 +604,8 @@ class TestSinglePicking(TestStockCommon): # Check reserved quantity self.assertEqual(move1.reserved_availability, 1.0) - self.assertEqual(len(move1.pack_operation_ids), 1) - self.assertEqual(move1.pack_operation_ids.product_qty, 1) + self.assertEqual(len(move1.move_line_ids), 1) + self.assertEqual(move1.move_line_ids.product_qty, 1) inventory = self.env['stock.inventory'].create({ 'name': 'remove product1', @@ -629,9 +629,9 @@ class TestSinglePicking(TestStockCommon): # Check reserved quantity self.assertEqual(move1.reserved_availability, 2.0) - self.assertEqual(len(move1.pack_operation_ids), 2) - self.assertEqual(move1.pack_operation_ids[0].lot_id.id, lot1.id) - self.assertEqual(move1.pack_operation_ids[1].lot_id.id, lot2.id) + self.assertEqual(len(move1.move_line_ids), 2) + self.assertEqual(move1.move_line_ids[0].lot_id.id, lot1.id) + self.assertEqual(move1.move_line_ids[1].lot_id.id, lot2.id) def test_recheck_availability_4(self): """ Same check than test_recheck_availability_2 but with serial number this time. @@ -671,8 +671,8 @@ class TestSinglePicking(TestStockCommon): # Check reserved quantity self.assertEqual(move1.reserved_availability, 1.0) - self.assertEqual(len(move1.pack_operation_ids), 1) - self.assertEqual(move1.pack_operation_ids.product_qty, 1) + self.assertEqual(len(move1.move_line_ids), 1) + self.assertEqual(move1.move_line_ids.product_qty, 1) inventory = self.env['stock.inventory'].create({ 'name': 'remove product1', @@ -696,6 +696,6 @@ class TestSinglePicking(TestStockCommon): # Check reserved quantity self.assertEqual(move1.reserved_availability, 2.0) - self.assertEqual(len(move1.pack_operation_ids), 2) - self.assertEqual(move1.pack_operation_ids[0].lot_id.id, serial1.id) - self.assertEqual(move1.pack_operation_ids[1].lot_id.id, serial2.id) + self.assertEqual(len(move1.move_line_ids), 2) + self.assertEqual(move1.move_line_ids[0].lot_id.id, serial1.id) + self.assertEqual(move1.move_line_ids[1].lot_id.id, serial2.id) diff --git a/addons/stock/tests/test_stock_flow.py b/addons/stock/tests/test_stock_flow.py index b00301f8a52..589e43dbd7e 100644 --- a/addons/stock/tests/test_stock_flow.py +++ b/addons/stock/tests/test_stock_flow.py @@ -77,10 +77,10 @@ class TestStockFlow(TestStockCommon): # Replace pack operation of incoming shipments. # ---------------------------------------------------------------------- picking_in.action_assign() - move_a.pack_operation_ids.qty_done = 4 - move_b.pack_operation_ids.qty_done = 5 - move_c.pack_operation_ids.qty_done = 5 - move_d.pack_operation_ids.qty_done = 5 + move_a.move_line_ids.qty_done = 4 + move_b.move_line_ids.qty_done = 5 + move_c.move_line_ids.qty_done = 5 + move_d.move_line_ids.qty_done = 5 lot2_productC = LotObj.create({'name': 'C Lot 2', 'product_id': self.productC.id}) self.StockPackObj.create({ 'product_id': self.productC.id, @@ -221,8 +221,8 @@ class TestStockFlow(TestStockCommon): # Replace pack operation of outgoing shipment. # ---------------------------------------------------------------------- - move_cust_a.pack_operation_ids.qty_done = 2.0 - move_cust_b.pack_operation_ids.qty_done = 3.0 + move_cust_a.move_line_ids.qty_done = 2.0 + move_cust_b.move_line_ids.qty_done = 3.0 self.StockPackObj.create({ 'product_id': self.productB.id, 'qty_done': 2, @@ -231,7 +231,7 @@ class TestStockFlow(TestStockCommon): 'location_dest_id': self.customer_location, 'move_id': move_cust_b.id}) # TODO care if product_qty and lot_id are set at the same times the system do 2 unreserve. - move_cust_c.pack_operation_ids[0].write({ + move_cust_c.move_line_ids[0].write({ 'qty_done': 2.0, 'lot_id': lot2_productC.id, }) @@ -242,7 +242,7 @@ class TestStockFlow(TestStockCommon): 'location_id': self.stock_location, 'location_dest_id': self.customer_location, 'move_id': move_cust_c.id}) - move_cust_d.pack_operation_ids.qty_done = 6.0 + move_cust_d.move_line_ids.qty_done = 6.0 # Transfer picking. picking_out.action_done() @@ -1370,11 +1370,11 @@ class TestStockFlow(TestStockCommon): self.assertEqual(move.state, 'waiting', 'Wrong state of move line.') # Set the quantity done on the pack operation - move_in.pack_operation_ids.qty_done = 3.0 + move_in.move_line_ids.qty_done = 3.0 # Put in a pack picking_in.put_in_pack() # Get the new package - picking_in_package = move_in.pack_operation_ids.result_package_id + picking_in_package = move_in.move_line_ids.result_package_id # Validate picking picking_in.action_done() @@ -1386,9 +1386,9 @@ class TestStockFlow(TestStockCommon): self.assertEqual(move.state, 'assigned', 'Wrong state of move line.') # Set the quantity done on the pack operation - move_pack.pack_operation_ids.qty_done = 3.0 + move_pack.move_line_ids.qty_done = 3.0 # Get the new package - picking_pack_package = move_pack.pack_operation_ids.result_package_id + picking_pack_package = move_pack.move_line_ids.result_package_id # Validate picking picking_pack.action_done() @@ -1400,8 +1400,8 @@ class TestStockFlow(TestStockCommon): self.assertEqual(move.state, 'assigned', 'Wrong state of move line.') # Validate picking - picking_out.pack_operation_ids.qty_done = 3.0 - picking_out_package = move_out.pack_operation_ids.result_package_id + picking_out.move_line_ids.qty_done = 3.0 + picking_out_package = move_out.move_line_ids.result_package_id picking_out.action_done() # check all pickings are done @@ -1438,9 +1438,9 @@ class TestStockFlow(TestStockCommon): pack_obj = self.env['stock.quant.package'] pack1 = pack_obj.create({'name': 'PACKINOUTTEST1'}) pack2 = pack_obj.create({'name': 'PACKINOUTTEST2'}) - picking_in.pack_operation_ids[0].result_package_id = pack1 - picking_in.pack_operation_ids[0].qty_done = 4 - packop2 = picking_in.pack_operation_ids[0].with_context(bypass_reservation_update=True).copy({'product_uom_qty': 0}) + picking_in.move_line_ids[0].result_package_id = pack1 + picking_in.move_line_ids[0].qty_done = 4 + packop2 = picking_in.move_line_ids[0].with_context(bypass_reservation_update=True).copy({'product_uom_qty': 0}) packop2.qty_done = 6 packop2.result_package_id = pack2 picking_in.action_done() @@ -1464,8 +1464,8 @@ class TestStockFlow(TestStockCommon): 'location_dest_id': self.customer_location}) picking_out.action_confirm() picking_out.action_assign() - packout1 = picking_out.pack_operation_ids[0] - packout2 = picking_out.pack_operation_ids[0].with_context(bypass_reservation_update=True).copy({'product_uom_qty': 0}) + packout1 = picking_out.move_line_ids[0] + packout2 = picking_out.move_line_ids[0].with_context(bypass_reservation_update=True).copy({'product_uom_qty': 0}) packout1.qty_done = 2 packout1.package_id = pack1 packout2.package_id = pack2 @@ -1496,9 +1496,9 @@ class TestStockFlow(TestStockCommon): pack_obj = self.env['stock.quant.package'] pack1 = pack_obj.create({'name': 'PACKINOUTTEST1'}) pack2 = pack_obj.create({'name': 'PACKINOUTTEST2'}) - picking_in.pack_operation_ids[0].result_package_id = pack1 - picking_in.pack_operation_ids[0].qty_done = 120 - packop2 = picking_in.pack_operation_ids[0].with_context(bypass_reservation_update=True).copy({'product_uom_qty': 0}) + picking_in.move_line_ids[0].result_package_id = pack1 + picking_in.move_line_ids[0].qty_done = 120 + packop2 = picking_in.move_line_ids[0].with_context(bypass_reservation_update=True).copy({'product_uom_qty': 0}) packop2.qty_done = 80 packop2.result_package_id = pack2 picking_in.action_done() @@ -1523,8 +1523,8 @@ class TestStockFlow(TestStockCommon): picking_out.action_confirm() picking_out.action_assign() # Convert entire packs into taking out of packs - packout0 = picking_out.pack_operation_ids[0] - packout1 = picking_out.pack_operation_ids[1] + packout0 = picking_out.move_line_ids[0] + packout1 = picking_out.move_line_ids[1] packout0.write({ 'package_id': pack1.id, 'product_id': self.productE.id, diff --git a/addons/stock/views/report_stock_traceability.xml b/addons/stock/views/report_stock_traceability.xml index 35cef6ec41e..3797d5680ce 100644 --- a/addons/stock/views/report_stock_traceability.xml +++ b/addons/stock/views/report_stock_traceability.xml @@ -4,7 +4,7 @@ <template id="report_mrp_line"> <t t-foreach="lines" t-as="a"> <t t-set="trclass" t-value="'o_stock_reports_default_style'"/> - <t t-if="a.get('model') == 'stock.pack.operation'"><t t-set="trclass" t-value="'o_stock_reports_level0'"/></t> + <t t-if="a.get('model') == 'stock.move.line'"><t t-set="trclass" t-value="'o_stock_reports_level0'"/></t> <t t-if="a.get('model') == 'stock.quant'"><t t-set="trclass" t-value="'o_stock_reports_level1'"/></t> <t t-set="domainClass" t-value="'o_stock_reports_domain_line'"/> <t t-if="a['unfoldable'] == false"> @@ -30,7 +30,7 @@ </td> </t> <td> - <t t-if="a.get('model') == 'stock.pack.operation'"> + <t t-if="a.get('model') == 'stock.move.line'"> <span t-if="a['stream'] == 'downstream'" class="o_stock_reports_stream text-muted" data-stream="upstream" title="Upstream Traceability"><i class="fa fa-arrow-up"></i></span> <span t-if="a['stream'] == 'upstream'" class="o_stock_reports_stream" data-stream="downstream" title="Downstream Traceability"><i class="fa fa-arrow-down"></i></span> </t> @@ -101,7 +101,7 @@ <t t-foreach="lines" t-as="a"> <t t-set="space_td" t-value="'margin-left: '+ str(a['level']) + 'px;'"/> <t t-set="trclass" t-value="'o_stock_reports_default_style'"/> - <t t-if="a.get('model') == 'stock.pack.operation'"><t t-set="trclass" t-value="'o_stock_reports_level0'"/></t> + <t t-if="a.get('model') == 'stock.move.line'"><t t-set="trclass" t-value="'o_stock_reports_level0'"/></t> <t t-if="a.get('model') == 'stock.quant'"><t t-set="trclass" t-value="'o_stock_reports_level1'"/></t> <t t-set="column" t-value="0" /> <tr t-att-data-type="a['type']" t-att-data-stream="a['stream']" t-att-data-id="a['id']" t-att-data-model="a['model']" t-att-class="trclass"> diff --git a/addons/stock/views/stock_move_views.xml b/addons/stock/views/stock_move_views.xml index 44f4606373c..3908dd89520 100644 --- a/addons/stock/views/stock_move_views.xml +++ b/addons/stock/views/stock_move_views.xml @@ -165,7 +165,7 @@ </group> </group> - <field name="pack_operation_ids" attrs="{'readonly': ['&', ('state', 'in', ('done', 'cancel')), ('is_editable', '=', False)]}" context="{'default_product_uom_id': product_uom, 'default_picking_id': picking_id, 'default_move_id': id, 'default_product_id': product_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}"> + <field name="move_line_ids" attrs="{'readonly': ['&', ('state', 'in', ('done', 'cancel')), ('is_editable', '=', False)]}" context="{'default_product_uom_id': product_uom, 'default_picking_id': picking_id, 'default_move_id': id, 'default_product_id': product_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}"> <tree editable="bottom" decoration-succes="product_uom_qty==qty_done" decoration-danger="qty_done > product_uom_qty)"> <field name="picking_id" invisible="1"/> <field name="product_id" invisible="1"/> @@ -195,12 +195,12 @@ <field name="mode">primary</field> <field name="inherit_id" ref="stock.view_stock_move_operations"/> <field name="arch" type="xml"> - <field name="pack_operation_ids" position="before"> + <field name="move_line_ids" position="before"> <field name="quantity_done" readonly="1"/> <field name="product_uom_qty" readonly="1"/> </field> - <field name="pack_operation_ids" position="replace"> - <field name="pack_operation_nosuggest_ids" attrs="{'readonly': [('state', 'in', ('done', 'cancel'))]}" context="{'default_picking_id': picking_id, 'default_move_id': id, 'default_product_id': product_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}"> + <field name="move_line_ids" position="replace"> + <field name="move_line_nosuggest_ids" attrs="{'readonly': [('state', 'in', ('done', 'cancel'))]}" context="{'default_picking_id': picking_id, 'default_move_id': id, 'default_product_id': product_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}"> <tree editable="bottom" decoration-succes="product_uom_qty==qty_done" decoration-danger="(product_uom_qty > 0) and (qty_done>product_uom_qty)"> <field name="location_id" invisible="context.get('hide_source')" domain="[('id', 'child_of', parent.location_id)])" groups="stock.group_stock_multi_locations"/> <field name="package_id" groups="stock.group_tracking_lot" invisible="context.get('from_supplier')"/> diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml index 5e68be3ad78..84a2d637ff7 100644 --- a/addons/stock/views/stock_picking_views.xml +++ b/addons/stock/views/stock_picking_views.xml @@ -214,7 +214,7 @@ <field name="picking_type_code" invisible="1"/> <button name="do_unreserve" string="Unreserve" groups="base.group_user" type="object" attrs="{'invisible': ['|', ('picking_type_code', '=', 'incoming'), ('state', 'not in', ('assigned', 'partially_available'))]}"/> <field name="show_operations" invisible="1"/> - <field name="pack_operation_exist" invisible="1"/> + <field name="move_line_exist" invisible="1"/> <field name="has_packages" invisible="1"/> <button name="button_scrap" type="object" string="Scrap" attrs="{'invisible': ['|', '&', ('picking_type_code', '!=', 'incoming'), ('state', 'in', ('draft', 'cancel', 'waiting')), '&', ('picking_type_code', '=', 'incoming'), ('state', '!=', 'done')]}"/> <field name="state" widget="statusbar" statusbar_visible="draft,confirmed,partially_available,assigned,done" /> @@ -247,14 +247,14 @@ <!--<label for="owner_id" groups="stock.group_tracking_owner"/>--> <div groups="stock.group_tracking_owner"> <!--<field name="owner_id"/>--> - <button name="action_assign_owner" string="Assign Owner" type="object" attrs="{'invisible': ['|',('pack_operation_exist', '=', False),('state', 'not in', ('draft','assigned','confirmed'))]}" + <button name="action_assign_owner" string="Assign Owner" type="object" attrs="{'invisible': ['|',('move_line_exist', '=', False),('state', 'not in', ('draft','assigned','confirmed'))]}" class="oe_link oe_edit_only"/> </div> </group> </group> <notebook> <page string="Detailed Operations" attrs="{'invisible': ['|', '&', ('show_operations', '=', True), ('state', '=', 'draft'), ('show_operations', '=', False)]}"> - <field name="pack_operation_ids" context="{'default_picking_id': id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}"> + <field name="move_line_ids" context="{'default_picking_id': id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}"> <tree editable="bottom" decoration-muted="result_package_id" decoration-danger="qty_done>product_uom_qty" decoration-success="qty_done==product_uom_qty and state!='done' and not result_package_id"> <field name="product_id" required="1"/> <field name="product_uom_id" attrs="{'readonly': [('state', '!=', 'draft')]}" groups="product.group_uom"/> diff --git a/addons/stock/wizard/stock_immediate_transfer.py b/addons/stock/wizard/stock_immediate_transfer.py index a0d82a9f174..eecb6a70b95 100644 --- a/addons/stock/wizard/stock_immediate_transfer.py +++ b/addons/stock/wizard/stock_immediate_transfer.py @@ -29,8 +29,8 @@ class StockImmediateTransfer(models.TransientModel): if self.pick_id.state != 'assigned': raise UserError(_("Could not reserve all requested products. Please use the \'Mark as Todo\' button to handle the reservation manually.")) for move in self.pick_id.move_lines: - if move.pack_operation_ids: - for move_line in move.pack_operation_ids: + if move.move_line_ids: + for move_line in move.move_line_ids: move_line.qty_done = move_line.product_uom_qty else: move.quantity_done = move.product_uom_qty diff --git a/addons/stock/wizard/stock_picking_return.py b/addons/stock/wizard/stock_picking_return.py index adb520f68f8..9afd8026193 100644 --- a/addons/stock/wizard/stock_picking_return.py +++ b/addons/stock/wizard/stock_picking_return.py @@ -48,7 +48,7 @@ class ReturnPicking(models.TransientModel): if move.move_dest_ids: move_dest_exists = True quantity = move.product_qty - sum(move.move_dest_ids.filtered(lambda m: m.state in ['partially_available', 'assigned', 'done']).\ - mapped('pack_operation_ids').mapped('product_qty')) + mapped('move_line_ids').mapped('product_qty')) product_return_moves.append((0, 0, {'product_id': move.product_id.id, 'quantity': quantity, 'move_id': move.id})) if not product_return_moves: diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py index 6e1bd2e4960..d9504d7bc9e 100644 --- a/addons/stock_account/models/stock.py +++ b/addons/stock_account/models/stock.py @@ -50,12 +50,12 @@ class StockLocation(models.Model): "This has no effect for internal locations.") -class StockPackOperation(models.Model): - _inherit = 'stock.pack.operation' +class StockMoveLine(models.Model): + _inherit = 'stock.move.line' @api.multi def write(self, vals): - super(StockPackOperation, self).write(vals) + super(StockMoveLine, self).write(vals) if 'qty_done' in vals: for move in self.mapped('move_id').filtered(lambda m: m.state == 'done'): move.value = move.quantity_done * move.price_unit diff --git a/addons/stock_account/tests/test_stockvaluation.py b/addons/stock_account/tests/test_stockvaluation.py index 44fe950364b..7cb07ada7f1 100644 --- a/addons/stock_account/tests/test_stockvaluation.py +++ b/addons/stock_account/tests/test_stockvaluation.py @@ -33,7 +33,7 @@ class TestStockValuation(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.qty_done = 68.0 + move1.move_line_ids.qty_done = 68.0 move1.action_done() self.assertEqual(move1.value, 1020.0) @@ -53,7 +53,7 @@ class TestStockValuation(TransactionCase): }) move2.action_confirm() move2.action_assign() - move2.pack_operation_ids.qty_done = 140.0 + move2.move_line_ids.qty_done = 140.0 move2.action_done() self.assertEqual(move2.value, 2170.0) @@ -73,7 +73,7 @@ class TestStockValuation(TransactionCase): }) move3.action_confirm() move3.action_assign() - move3.pack_operation_ids.qty_done = 94.0 + move3.move_line_ids.qty_done = 94.0 move3.action_done() self.assertEqual(move3.price_unit, 0.0) # unused in out moves @@ -99,7 +99,7 @@ class TestStockValuation(TransactionCase): }) move4.action_confirm() move4.action_assign() - move4.pack_operation_ids.qty_done = 40.0 + move4.move_line_ids.qty_done = 40.0 move4.action_done() self.assertEqual(move4.value, 640.0) @@ -122,7 +122,7 @@ class TestStockValuation(TransactionCase): }) move5.action_confirm() move5.action_assign() - move5.pack_operation_ids.qty_done = 78.0 + move5.move_line_ids.qty_done = 78.0 move5.action_done() self.assertEqual(move5.value, 1287.0) @@ -145,7 +145,7 @@ class TestStockValuation(TransactionCase): }) move6.action_confirm() move6.action_assign() - move6.pack_operation_ids.qty_done = 116.0 + move6.move_line_ids.qty_done = 116.0 move6.action_done() # note: it' ll have to get 114 units from the move2 and 2 from move4 @@ -171,7 +171,7 @@ class TestStockValuation(TransactionCase): }) move7.action_confirm() move7.action_assign() - move7.pack_operation_ids.qty_done = 62.0 + move7.move_line_ids.qty_done = 62.0 move7.action_done() # note: it' ll have to get 38 units from the move4 and 24 from move5 @@ -203,7 +203,7 @@ class TestStockValuation(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.qty_done = 10.0 + move1.move_line_ids.qty_done = 10.0 move1.action_done() self.assertEqual(move1.value, 1000.0) @@ -223,7 +223,7 @@ class TestStockValuation(TransactionCase): }) move2.action_confirm() move2.action_assign() - move2.pack_operation_ids.qty_done = 10.0 + move2.move_line_ids.qty_done = 10.0 move2.action_done() self.assertEqual(move2.value, 800.0) @@ -243,7 +243,7 @@ class TestStockValuation(TransactionCase): }) move3.action_confirm() move3.action_assign() - move3.pack_operation_ids.qty_done = 15.0 + move3.move_line_ids.qty_done = 15.0 move3.action_done() self.assertEqual(move3.price_unit, 0.0) # unused in out moves @@ -269,7 +269,7 @@ class TestStockValuation(TransactionCase): }) move4.action_confirm() move4.action_assign() - move4.pack_operation_ids.qty_done = 5.0 + move4.move_line_ids.qty_done = 5.0 move4.action_done() self.assertEqual(move4.value, 300.0) @@ -291,7 +291,7 @@ class TestStockValuation(TransactionCase): }) move5.action_confirm() move5.action_assign() - move5.pack_operation_ids.qty_done = 7.0 + move5.move_line_ids.qty_done = 7.0 move5.action_done() # note: it' ll have to get 5 units from the move2 and 2 from move4 @@ -322,7 +322,7 @@ class TestStockValuation(TransactionCase): }) move1.action_confirm() move1.action_assign() - move1.pack_operation_ids.qty_done = 60.0 + move1.move_line_ids.qty_done = 60.0 move1.action_done() self.assertEqual(move1.value, 900.0) @@ -342,7 +342,7 @@ class TestStockValuation(TransactionCase): }) move2.action_confirm() move2.action_assign() - move2.pack_operation_ids.qty_done = 140.0 + move2.move_line_ids.qty_done = 140.0 move2.action_done() self.assertEqual(move2.value, 2170.0) @@ -359,7 +359,7 @@ class TestStockValuation(TransactionCase): }) move3.action_confirm() move3.action_assign() - move3.pack_operation_ids.qty_done = 190.0 + move3.move_line_ids.qty_done = 190.0 move3.action_done() self.assertEqual(move3.price_unit, 0.0) # unused in out moves @@ -379,7 +379,7 @@ class TestStockValuation(TransactionCase): }) move4.action_confirm() move4.action_assign() - move4.pack_operation_ids.qty_done = 70.0 + move4.move_line_ids.qty_done = 70.0 move4.action_done() self.assertEqual(move4.value, 1120.0) @@ -396,7 +396,7 @@ class TestStockValuation(TransactionCase): }) move5.action_confirm() move5.action_assign() - move5.pack_operation_ids.qty_done = 30.0 + move5.move_line_ids.qty_done = 30.0 move5.action_done() self.assertEqual(move5.value, -477.6) diff --git a/addons/stock_dropshipping/test/dropship.yml b/addons/stock_dropshipping/test/dropship.yml index 5aacbf2d8ec..1436cb275c1 100644 --- a/addons/stock_dropshipping/test/dropship.yml +++ b/addons/stock_dropshipping/test/dropship.yml @@ -72,7 +72,7 @@ - Check one move line was created in Customers location with 200 pieces - - !python {model: stock.pack.operation, id: False}: | + !python {model: stock.move.line, id: False}: | move_line = self.search([('location_dest_id', '=', ref('stock.stock_location_customers')), ('product_id', '=', ref("drop_shop_product"))]) assert move_line, 'No move line found' assert len(move_line.ids) == 1, 'There should be exactly one move line' |
