diff --git a/addons/mrp/data/mrp_demo.xml b/addons/mrp/data/mrp_demo.xml index e9a0cfb67af..e62afc6aceb 100644 --- a/addons/mrp/data/mrp_demo.xml +++ b/addons/mrp/data/mrp_demo.xml @@ -489,24 +489,24 @@ lot - + 0000000000030 - + 0000000000031 - + 0000000010001 - + 0000000020045 diff --git a/addons/mrp/models/__init__.py b/addons/mrp/models/__init__.py index c6b32ff80fc..8fb29e7b1c6 100644 --- a/addons/mrp/models/__init__.py +++ b/addons/mrp/models/__init__.py @@ -15,7 +15,7 @@ from . import res_company from . import stock_move from . import stock_orderpoint from . import stock_picking -from . import stock_production_lot +from . import stock_lot from . import stock_rule from . import stock_scrap from . import stock_warehouse diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 804ca70c898..9a21dac95cb 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -105,7 +105,7 @@ class MrpProduction(models.Model): readonly=True, required=True, states={'draft': [('readonly', False)]}, domain="[('category_id', '=', product_uom_category_id)]") lot_producing_id = fields.Many2one( - 'stock.production.lot', string='Lot/Serial Number', copy=False, + 'stock.lot', string='Lot/Serial Number', copy=False, domain="[('product_id', '=', product_id), ('company_id', '=', company_id)]", check_company=True) qty_producing = fields.Float(string="Quantity Producing", digits='Product Unit of Measure', copy=False) product_uom_category_id = fields.Many2one(related='product_id.uom_id.category_id') @@ -1129,10 +1129,10 @@ class MrpProduction(models.Model): def action_generate_serial(self): self.ensure_one() - self.lot_producing_id = self.env['stock.production.lot'].create({ + self.lot_producing_id = self.env['stock.lot'].create({ 'product_id': self.product_id.id, 'company_id': self.company_id.id, - 'name': self.env['stock.production.lot']._get_next_serial(self.company_id, self.product_id) or self.env['ir.sequence'].next_by_code('stock.lot.serial'), + 'name': self.env['stock.lot']._get_next_serial(self.company_id, self.product_id) or self.env['ir.sequence'].next_by_code('stock.lot.serial'), }) if self.move_finished_ids.filtered(lambda m: m.product_id == self.product_id).move_line_ids: self.move_finished_ids.filtered(lambda m: m.product_id == self.product_id).move_line_ids.lot_id = self.lot_producing_id @@ -1743,7 +1743,7 @@ class MrpProduction(models.Model): message += "\n".join(component.name for component in multiple_lot_components) if message: raise UserError(message) - next_serial = self.env['stock.production.lot']._get_next_serial(self.company_id, self.product_id) + next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id) action = self.env["ir.actions.actions"]._for_xml_id("mrp.act_assign_serial_numbers_production") action['context'] = { 'default_production_id': self.id, @@ -1945,7 +1945,7 @@ class MrpProduction(models.Model): backorder.action_confirm() production.name = self._get_name_backorder(production.name, production.backorder_sequence) production.product_qty = 1 - production.lot_producing_id = self.env['stock.production.lot'].create({ + production.lot_producing_id = self.env['stock.lot'].create({ 'product_id': production.product_id.id, 'company_id': production.company_id.id, 'name': serial_number, diff --git a/addons/mrp/models/mrp_unbuild.py b/addons/mrp/models/mrp_unbuild.py index 63b9bf73933..d7698766a5b 100644 --- a/addons/mrp/models/mrp_unbuild.py +++ b/addons/mrp/models/mrp_unbuild.py @@ -49,7 +49,7 @@ class MrpUnbuild(models.Model): states={'done': [('readonly', True)]}, check_company=True) mo_bom_id = fields.Many2one('mrp.bom', 'Bill of Material used on the Production Order', related='mo_id.bom_id') lot_id = fields.Many2one( - 'stock.production.lot', 'Lot/Serial Number', + 'stock.lot', 'Lot/Serial Number', domain="[('product_id', '=', product_id), ('company_id', '=', company_id)]", check_company=True, states={'done': [('readonly', True)]}, help="Lot/Serial Number of the product to unbuild.") has_tracking=fields.Selection(related='product_id.tracking', readonly=True) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 7ea435fe6cd..ed3ac10c748 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -125,7 +125,7 @@ class MrpWorkorder(models.Model): 'stock.move.line', 'workorder_id', 'Moves to Track', help="Inventory moves for which you must scan a lot number at this work order") finished_lot_id = fields.Many2one( - 'stock.production.lot', string='Lot/Serial Number', compute='_compute_finished_lot_id', + 'stock.lot', string='Lot/Serial Number', compute='_compute_finished_lot_id', inverse='_set_finished_lot_id', domain="[('product_id', '=', product_id), ('company_id', '=', company_id)]", check_company=True) time_ids = fields.One2many( diff --git a/addons/mrp/models/stock_production_lot.py b/addons/mrp/models/stock_lot.py similarity index 83% rename from addons/mrp/models/stock_production_lot.py rename to addons/mrp/models/stock_lot.py index 2df39cd7648..74a731f46d7 100644 --- a/addons/mrp/models/stock_production_lot.py +++ b/addons/mrp/models/stock_lot.py @@ -5,8 +5,8 @@ from odoo import models, _ from odoo.exceptions import UserError -class StockProductionLot(models.Model): - _inherit = 'stock.production.lot' +class StockLot(models.Model): + _inherit = 'stock.lot' def _check_create(self): active_mo_id = self.env.context.get('active_mo_id') @@ -14,4 +14,4 @@ class StockProductionLot(models.Model): active_mo = self.env['mrp.production'].browse(active_mo_id) if not active_mo.picking_type_id.use_create_components_lots: raise UserError(_('You are not allowed to create or edit a lot or serial number for the components with the operation type "Manufacturing". To change this, go on the operation type and tick the box "Create New Lots/Serial Numbers for Components".')) - return super(StockProductionLot, self)._check_create() + return super()._check_create() diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index a263b26c8e7..c68232133d6 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -131,7 +131,7 @@ class StockMove(models.Model): 'Done', compute='_compute_is_done', store=True, help='Technical Field to order moves') - order_finished_lot_ids = fields.Many2many('stock.production.lot', string="Finished Lot/Serial Number", compute='_compute_order_finished_lot_ids') + order_finished_lot_ids = fields.Many2many('stock.lot', string="Finished Lot/Serial Number", compute='_compute_order_finished_lot_ids') should_consume_qty = fields.Float('Quantity To Consume', compute='_compute_should_consume_qty', digits='Product Unit of Measure') cost_share = fields.Float( "Cost Share (%)", digits=(5, 2), # decimal = 2 is important for rounding calculations!! diff --git a/addons/mrp/tests/test_backorder.py b/addons/mrp/tests/test_backorder.py index 8d8b2fa0904..cefb374b1fc 100644 --- a/addons/mrp/tests/test_backorder.py +++ b/addons/mrp/tests/test_backorder.py @@ -171,17 +171,17 @@ class TestMrpProductionBackorder(TestMrpCommon): """ nb_product_todo = 4 production, _, p_final, p1, p2 = self.generate_mo(qty_final=nb_product_todo, tracking_final='lot', tracking_base_1='lot', tracking_base_2='lot') - lot_final = self.env['stock.production.lot'].create({ + lot_final = self.env['stock.lot'].create({ 'name': 'lot_final', 'product_id': p_final.id, 'company_id': self.env.company.id, }) - lot_1 = self.env['stock.production.lot'].create({ + lot_1 = self.env['stock.lot'].create({ 'name': 'lot_consumed_1', 'product_id': p1.id, 'company_id': self.env.company.id, }) - lot_2 = self.env['stock.production.lot'].create({ + lot_2 = self.env['stock.lot'].create({ 'name': 'lot_consumed_2', 'product_id': p2.id, 'company_id': self.env.company.id, @@ -229,17 +229,17 @@ class TestMrpProductionBackorder(TestMrpCommon): production, _, p_final, p1, p2 = self.generate_mo(qty_final=nb_product_todo, tracking_final='serial', tracking_base_1='serial', tracking_base_2='serial', qty_base_1=1) serials_final, serials_p1, serials_p2 = [], [], [] for i in range(nb_product_todo): - serials_final.append(self.env['stock.production.lot'].create({ + serials_final.append(self.env['stock.lot'].create({ 'name': f'lot_final_{i}', 'product_id': p_final.id, 'company_id': self.env.company.id, })) - serials_p1.append(self.env['stock.production.lot'].create({ + serials_p1.append(self.env['stock.lot'].create({ 'name': f'lot_consumed_1_{i}', 'product_id': p1.id, 'company_id': self.env.company.id, })) - serials_p2.append(self.env['stock.production.lot'].create({ + serials_p2.append(self.env['stock.lot'].create({ 'name': f'lot_consumed_2_{i}', 'product_id': p2.id, 'company_id': self.env.company.id, @@ -304,7 +304,7 @@ class TestMrpProductionBackorder(TestMrpCommon): immediate_wizard.process() self.assertEqual(self.env['stock.quant']._get_available_quantity(p_final, self.stock_location), 2, "Incorrect number of final product produced.") - self.assertEqual(len(self.env['stock.production.lot'].search([('product_id', '=', p_final.id)])), 2, "Serial Numbers were not correctly produced.") + self.assertEqual(len(self.env['stock.lot'].search([('product_id', '=', p_final.id)])), 2, "Serial Numbers were not correctly produced.") def test_backorder_name(self): def produce_one(mo): diff --git a/addons/mrp/tests/test_multicompany.py b/addons/mrp/tests/test_multicompany.py index fd4298ae059..83e4d3fe051 100644 --- a/addons/mrp/tests/test_multicompany.py +++ b/addons/mrp/tests/test_multicompany.py @@ -122,7 +122,7 @@ class TestMrpMulticompany(common.TransactionCase): component = self.env['product.product'].create({ 'name': 'p2', }) - lot_b = self.env['stock.production.lot'].create({ + lot_b = self.env['stock.lot'].create({ 'product_id': product.id, 'company_id': self.company_b.id, }) @@ -150,7 +150,7 @@ class TestMrpMulticompany(common.TransactionCase): 'name': 'p2', 'tracking': 'lot', }) - lot_b = self.env['stock.production.lot'].create({ + lot_b = self.env['stock.lot'].create({ 'product_id': component.id, 'company_id': self.company_b.id, }) diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py index 579dbd3c194..7455780c75a 100644 --- a/addons/mrp/tests/test_order.py +++ b/addons/mrp/tests/test_order.py @@ -240,12 +240,12 @@ class TestMrpOrder(TestMrpCommon): mo, bom, p_final, p1, p2 = self.generate_mo(tracking_base_1='lot') self.assertEqual(len(mo), 1, 'MO should have been created') - lot_1 = self.env['stock.production.lot'].create({ + lot_1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': p1.id, 'company_id': self.env.company.id, }) - lot_2 = self.env['stock.production.lot'].create({ + lot_2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': p1.id, 'company_id': self.env.company.id, @@ -510,12 +510,12 @@ class TestMrpOrder(TestMrpCommon): mo, bom, p_final, p1, p2 = self.generate_mo(tracking_base_1='serial', qty_base_1=1, qty_final=2) self.assertEqual(len(mo), 1, 'MO should have been created') - lot_p1_1 = self.env['stock.production.lot'].create({ + lot_p1_1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': p1.id, 'company_id': self.env.company.id, }) - lot_p1_2 = self.env['stock.production.lot'].create({ + lot_p1_2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': p1.id, 'company_id': self.env.company.id, @@ -569,18 +569,18 @@ class TestMrpOrder(TestMrpCommon): mo, _, p_final, p1, p2 = self.generate_mo(tracking_base_1='lot', qty_base_1=10, qty_final=1) self.assertEqual(len(mo), 1, 'MO should have been created') - first_lot_for_p1 = self.env['stock.production.lot'].create({ + first_lot_for_p1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': p1.id, 'company_id': self.env.company.id, }) - second_lot_for_p1 = self.env['stock.production.lot'].create({ + second_lot_for_p1 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': p1.id, 'company_id': self.env.company.id, }) - final_product_lot = self.env['stock.production.lot'].create({ + final_product_lot = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': p_final.id, 'company_id': self.env.company.id, @@ -883,12 +883,12 @@ class TestMrpOrder(TestMrpCommon): 'type': 'product', 'tracking': 'serial' }) - self.serial_1 = self.env['stock.production.lot'].create({ + self.serial_1 = self.env['stock.lot'].create({ 'product_id': self.byproduct1.id, 'name': 'serial 1', 'company_id': self.env.company.id, }) - self.serial_2 = self.env['stock.production.lot'].create({ + self.serial_2 = self.env['stock.lot'].create({ 'product_id': self.byproduct1.id, 'name': 'serial 2', 'company_id': self.env.company.id, @@ -899,12 +899,12 @@ class TestMrpOrder(TestMrpCommon): 'type': 'product', 'tracking': 'lot', }) - self.lot_1 = self.env['stock.production.lot'].create({ + self.lot_1 = self.env['stock.lot'].create({ 'product_id': self.byproduct2.id, 'name': 'Lot 1', 'company_id': self.env.company.id, }) - self.lot_2 = self.env['stock.production.lot'].create({ + self.lot_2 = self.env['stock.lot'].create({ 'product_id': self.byproduct2.id, 'name': 'Lot 2', 'company_id': self.env.company.id, @@ -1111,7 +1111,7 @@ class TestMrpOrder(TestMrpCommon): """ produce a finished product with component tracked by serial number 2 times with the same SN. Check that an error is raised the second time""" mo1, bom, p_final, p1, p2 = self.generate_mo(tracking_base_2='serial', qty_final=1, qty_base_1=1,) - sn = self.env['stock.production.lot'].create({ + sn = self.env['stock.lot'].create({ 'name': 'sn used twice', 'product_id': p2.id, 'company_id': self.env.company.id, @@ -1167,7 +1167,7 @@ class TestMrpOrder(TestMrpCommon): mo = mo_form.save() mo.action_confirm() - sn = self.env['stock.production.lot'].create({ + sn = self.env['stock.lot'].create({ 'name': 'sn used twice', 'product_id': byproduct.id, 'company_id': self.env.company.id, @@ -1205,7 +1205,7 @@ class TestMrpOrder(TestMrpCommon): """ Consuming the same serial number two times should not give an error if a repair order of the first production has been made before the second one""" mo1, bom, p_final, p1, p2 = self.generate_mo(tracking_base_2='serial', qty_final=1, qty_base_1=1,) - sn = self.env['stock.production.lot'].create({ + sn = self.env['stock.lot'].create({ 'name': 'sn used twice', 'product_id': p2.id, 'company_id': self.env.company.id, @@ -1350,7 +1350,7 @@ class TestMrpOrder(TestMrpCommon): mo_form.product_qty = 1 mo = mo_form.save() - final_product_lot = self.env['stock.production.lot'].create({ + final_product_lot = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': plastic_laminate.id, 'company_id': self.env.company.id, @@ -1740,13 +1740,13 @@ class TestMrpOrder(TestMrpCommon): }) # the products are tracked by lot, so we go through _generate_consumed_move_line - lot_final = self.env['stock.production.lot'].create({ + self.env['stock.lot'].create({ 'name': 'Lot Final', 'product_id': product_final.id, 'company_id': self.env.company.id, }) - lot_comp = self.env['stock.production.lot'].create({ + lot_comp = self.env['stock.lot'].create({ 'name': 'Lot Component', 'product_id': product_comp.id, 'company_id': self.env.company.id, @@ -1803,7 +1803,7 @@ class TestMrpOrder(TestMrpCommon): mo, _, p_final, _, _ = self.generate_mo(tracking_final='serial', qty_base_1=1, qty_final=1) self.assertEqual(len(mo), 1, 'MO should have been created') - sn1 = self.env['stock.production.lot'].create({ + sn1 = self.env['stock.lot'].create({ 'name': 'serial1', 'product_id': p_final.id, 'company_id': self.env.company.id, diff --git a/addons/mrp/tests/test_stock.py b/addons/mrp/tests/test_stock.py index aaee7279ca6..68574ae7ed9 100644 --- a/addons/mrp/tests/test_stock.py +++ b/addons/mrp/tests/test_stock.py @@ -96,12 +96,12 @@ class TestWarehouseMrp(common.TestMrpCommon): self.bom_3.bom_line_ids.filtered(lambda x: x.product_id == self.product_5).unlink() # Create Inventory Adjustment For Stick and Stone Tools with lot. - lot_product_4 = self.env['stock.production.lot'].create({ + lot_product_4 = self.env['stock.lot'].create({ 'name': '0000000000001', 'product_id': self.product_4.id, 'company_id': self.env.company.id, }) - lot_product_2 = self.env['stock.production.lot'].create({ + lot_product_2 = self.env['stock.lot'].create({ 'name': '0000000000002', 'product_id': self.product_2.id, 'company_id': self.env.company.id, @@ -159,7 +159,7 @@ class TestWarehouseMrp(common.TestMrpCommon): """ self.laptop.tracking = 'serial' mo_laptop = self.new_mo_laptop() - serial = self.env['stock.production.lot'].create({'product_id': self.laptop.id, 'company_id': self.env.company.id}) + serial = self.env['stock.lot'].create({'product_id': self.laptop.id, 'company_id': self.env.company.id}) mo_form = Form(mo_laptop) mo_form.qty_producing = 1 diff --git a/addons/mrp/tests/test_traceability.py b/addons/mrp/tests/test_traceability.py index d878d1110df..b10080253f8 100644 --- a/addons/mrp/tests/test_traceability.py +++ b/addons/mrp/tests/test_traceability.py @@ -24,7 +24,7 @@ class TestTraceability(TestMrpCommon): consumed_lot = self._create_product('lot') consumed_serial = self._create_product('serial') stock_id = self.env.ref('stock.stock_location_stock').id - Lot = self.env['stock.production.lot'] + Lot = self.env['stock.lot'] # create inventory quants = self.env['stock.quant'].create({ 'location_id': stock_id, @@ -84,7 +84,7 @@ class TestTraceability(TestMrpCommon): mo_form = Form(mo) mo_form.qty_producing = 1 if finished_product.tracking != 'none': - mo_form.lot_producing_id = self.env['stock.production.lot'].create({'name': 'Serial or Lot finished', 'product_id': finished_product.id, 'company_id': self.env.company.id}) + mo_form.lot_producing_id = self.env['stock.lot'].create({'name': 'Serial or Lot finished', 'product_id': finished_product.id, 'company_id': self.env.company.id}) mo = mo_form.save() details_operation_form = Form(mo.move_raw_ids[1], view=self.env.ref('stock.view_stock_move_operations')) @@ -178,7 +178,7 @@ class TestTraceability(TestMrpCommon): mo.action_confirm() mo_form = Form(mo) - mo_form.lot_producing_id = self.env['stock.production.lot'].create({ + mo_form.lot_producing_id = self.env['stock.lot'].create({ 'product_id': product_final.id, 'name': 'Final_lot_1', 'company_id': self.env.company.id, @@ -187,7 +187,7 @@ class TestTraceability(TestMrpCommon): details_operation_form = Form(mo.move_raw_ids[0], view=self.env.ref('stock.view_stock_move_operations')) with details_operation_form.move_line_ids.new() as ml: - ml.lot_id = self.env['stock.production.lot'].create({ + ml.lot_id = self.env['stock.lot'].create({ 'product_id': product_1.id, 'name': 'Raw_1_lot_1', 'company_id': self.env.company.id, @@ -196,7 +196,7 @@ class TestTraceability(TestMrpCommon): details_operation_form.save() details_operation_form = Form(mo.move_raw_ids[1], view=self.env.ref('stock.view_stock_move_operations')) with details_operation_form.move_line_ids.new() as ml: - ml.lot_id = self.env['stock.production.lot'].create({ + ml.lot_id = self.env['stock.lot'].create({ 'product_id': product_2.id, 'name': 'Raw_2_lot_1', 'company_id': self.env.company.id, @@ -208,7 +208,7 @@ class TestTraceability(TestMrpCommon): view=self.env.ref('stock.view_stock_move_operations') ) with details_operation_form.move_line_ids.new() as ml: - ml.lot_id = self.env['stock.production.lot'].create({ + ml.lot_id = self.env['stock.lot'].create({ 'product_id': byproduct_1.id, 'name': 'Byproduct_1_lot_1', 'company_id': self.env.company.id, @@ -220,7 +220,7 @@ class TestTraceability(TestMrpCommon): view=self.env.ref('stock.view_stock_move_operations') ) with details_operation_form.move_line_ids.new() as ml: - ml.lot_id = self.env['stock.production.lot'].create({ + ml.lot_id = self.env['stock.lot'].create({ 'product_id': byproduct_2.id, 'name': 'Byproduct_2_lot_1', 'company_id': self.env.company.id, @@ -233,7 +233,7 @@ class TestTraceability(TestMrpCommon): backorder.save().action_backorder() mo_backorder = mo.procurement_group_id.mrp_production_ids[-1] mo_form = Form(mo_backorder) - mo_form.lot_producing_id = self.env['stock.production.lot'].create({ + mo_form.lot_producing_id = self.env['stock.lot'].create({ 'product_id': product_final.id, 'name': 'Final_lot_2', 'company_id': self.env.company.id, @@ -246,7 +246,7 @@ class TestTraceability(TestMrpCommon): view=self.env.ref('stock.view_stock_move_operations') ) with details_operation_form.move_line_ids.new() as ml: - ml.lot_id = self.env['stock.production.lot'].create({ + ml.lot_id = self.env['stock.lot'].create({ 'product_id': product_1.id, 'name': 'Raw_1_lot_2', 'company_id': self.env.company.id, @@ -258,7 +258,7 @@ class TestTraceability(TestMrpCommon): view=self.env.ref('stock.view_stock_move_operations') ) with details_operation_form.move_line_ids.new() as ml: - ml.lot_id = self.env['stock.production.lot'].create({ + ml.lot_id = self.env['stock.lot'].create({ 'product_id': product_2.id, 'name': 'Raw_2_lot_2', 'company_id': self.env.company.id, @@ -270,7 +270,7 @@ class TestTraceability(TestMrpCommon): view=self.env.ref('stock.view_stock_move_operations') ) with details_operation_form.move_line_ids.new() as ml: - ml.lot_id = self.env['stock.production.lot'].create({ + ml.lot_id = self.env['stock.lot'].create({ 'product_id': byproduct_1.id, 'name': 'Byproduct_1_lot_2', 'company_id': self.env.company.id, @@ -282,7 +282,7 @@ class TestTraceability(TestMrpCommon): view=self.env.ref('stock.view_stock_move_operations') ) with details_operation_form.move_line_ids.new() as ml: - ml.lot_id = self.env['stock.production.lot'].create({ + ml.lot_id = self.env['stock.lot'].create({ 'product_id': byproduct_2.id, 'name': 'Byproduct_2_lot_2', 'company_id': self.env.company.id, diff --git a/addons/mrp/tests/test_unbuild.py b/addons/mrp/tests/test_unbuild.py index e3ab2e0e25f..af6f533b176 100644 --- a/addons/mrp/tests/test_unbuild.py +++ b/addons/mrp/tests/test_unbuild.py @@ -84,7 +84,7 @@ class TestUnbuild(TestMrpCommon): mo, bom, p_final, p1, p2 = self.generate_mo(tracking_final='lot') self.assertEqual(len(mo), 1, 'MO should have been created') - lot = self.env['stock.production.lot'].create({ + lot = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': p_final.id, 'company_id': self.env.company.id, @@ -161,7 +161,7 @@ class TestUnbuild(TestMrpCommon): mo, bom, p_final, p1, p2 = self.generate_mo(tracking_base_1='lot') self.assertEqual(len(mo), 1, 'MO should have been created') - lot = self.env['stock.production.lot'].create({ + lot = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': p1.id, 'company_id': self.env.company.id, @@ -245,17 +245,17 @@ class TestUnbuild(TestMrpCommon): mo, bom, p_final, p1, p2 = self.generate_mo(tracking_final='lot', tracking_base_2='lot', tracking_base_1='lot') self.assertEqual(len(mo), 1, 'MO should have been created') - lot_final = self.env['stock.production.lot'].create({ + lot_final = self.env['stock.lot'].create({ 'name': 'lot_final', 'product_id': p_final.id, 'company_id': self.env.company.id, }) - lot_1 = self.env['stock.production.lot'].create({ + lot_1 = self.env['stock.lot'].create({ 'name': 'lot_consumed_1', 'product_id': p1.id, 'company_id': self.env.company.id, }) - lot_2 = self.env['stock.production.lot'].create({ + lot_2 = self.env['stock.lot'].create({ 'name': 'lot_consumed_2', 'product_id': p2.id, 'company_id': self.env.company.id, @@ -357,17 +357,17 @@ class TestUnbuild(TestMrpCommon): mo, bom, p_final, p1, p2 = self.generate_mo(tracking_final='none', tracking_base_2='lot', tracking_base_1='none') self.assertEqual(len(mo), 1, 'MO should have been created') - lot_1 = self.env['stock.production.lot'].create({ + lot_1 = self.env['stock.lot'].create({ 'name': 'lot_1', 'product_id': p2.id, 'company_id': self.env.company.id, }) - lot_2 = self.env['stock.production.lot'].create({ + lot_2 = self.env['stock.lot'].create({ 'name': 'lot_2', 'product_id': p2.id, 'company_id': self.env.company.id, }) - lot_3 = self.env['stock.production.lot'].create({ + lot_3 = self.env['stock.lot'].create({ 'name': 'lot_3', 'product_id': p2.id, 'company_id': self.env.company.id, @@ -419,14 +419,14 @@ class TestUnbuild(TestMrpCommon): # Young Tom # \ Botox - 4 - p1 # \ Old Tom - 1 - p2 - lot_1 = self.env['stock.production.lot'].create({ + lot_1 = self.env['stock.lot'].create({ 'name': 'lot_1', 'product_id': p2.id, 'company_id': self.env.company.id, }) self.env['stock.quant']._update_available_quantity(p2, self.stock_location, 3, lot_id=lot_1) - lot_finished_1 = self.env['stock.production.lot'].create({ + lot_finished_1 = self.env['stock.lot'].create({ 'name': 'lot_finished_1', 'product_id': p_final.id, 'company_id': self.env.company.id, @@ -447,14 +447,14 @@ class TestUnbuild(TestMrpCommon): backorder = Form(self.env[action['res_model']].with_context(**action['context'])) backorder.save().action_backorder() - lot_2 = self.env['stock.production.lot'].create({ + lot_2 = self.env['stock.lot'].create({ 'name': 'lot_2', 'product_id': p2.id, 'company_id': self.env.company.id, }) self.env['stock.quant']._update_available_quantity(p2, self.stock_location, 4, lot_id=lot_2) - lot_finished_2 = self.env['stock.production.lot'].create({ + lot_finished_2 = self.env['stock.lot'].create({ 'name': 'lot_finished_2', 'product_id': p_final.id, 'company_id': self.env.company.id, diff --git a/addons/mrp/wizard/stock_assign_serial_numbers.py b/addons/mrp/wizard/stock_assign_serial_numbers.py index 5ac8277fe2c..25e5268fa80 100644 --- a/addons/mrp/wizard/stock_assign_serial_numbers.py +++ b/addons/mrp/wizard/stock_assign_serial_numbers.py @@ -19,7 +19,7 @@ class StockAssignSerialNumbers(models.TransientModel): def generate_serial_numbers_production(self): if self.next_serial_number and self.next_serial_count: - generated_serial_numbers = "\n".join(self.env['stock.production.lot'].generate_lot_names(self.next_serial_number, self.next_serial_count)) + generated_serial_numbers = "\n".join(self.env['stock.lot'].generate_lot_names(self.next_serial_number, self.next_serial_count)) self.serial_numbers = "\n".join([self.serial_numbers, generated_serial_numbers]) if self.serial_numbers else generated_serial_numbers self._onchange_serial_numbers() action = self.env["ir.actions.actions"]._for_xml_id("mrp.act_assign_serial_numbers_production") @@ -41,7 +41,7 @@ class StockAssignSerialNumbers(models.TransientModel): self.serial_numbers = "" self.produced_qty = 0 raise UserError(_('Duplicate Serial Numbers (%s)') % ','.join(duplicate_serial_numbers)) - existing_serial_numbers = self.env['stock.production.lot'].search([ + existing_serial_numbers = self.env['stock.lot'].search([ ('company_id', '=', self.production_id.company_id.id), ('product_id', '=', self.production_id.product_id.id), ('name', 'in', serial_numbers), diff --git a/addons/mrp_product_expiry/tests/test_mrp_product_expiry.py b/addons/mrp_product_expiry/tests/test_mrp_product_expiry.py index 137877c95a0..fd9024a2780 100644 --- a/addons/mrp_product_expiry/tests/test_mrp_product_expiry.py +++ b/addons/mrp_product_expiry/tests/test_mrp_product_expiry.py @@ -7,11 +7,11 @@ from odoo.tests.common import Form from odoo.exceptions import UserError -class TestStockProductionLot(TestStockCommon): +class TestStockLot(TestStockCommon): @classmethod def setUpClass(cls): - super(TestStockProductionLot, cls).setUpClass() + super().setUpClass() # Creates a tracked product using expiration dates. cls.product_apple = cls.ProductObj.create({ 'name': 'Apple', diff --git a/addons/mrp_repair/tests/test_tracability.py b/addons/mrp_repair/tests/test_tracability.py index 354fa061f71..112e4f44e44 100644 --- a/addons/mrp_repair/tests/test_tracability.py +++ b/addons/mrp_repair/tests/test_tracability.py @@ -16,7 +16,7 @@ class TestRepairTraceability(TestMrpCommon): 'name': 'product first serial to act repair', 'tracking': 'serial', }) - ptrepair_lot = self.env['stock.production.lot'].create({ + ptrepair_lot = self.env['stock.lot'].create({ 'name': 'A1', 'product_id': product_to_repair.id, 'company_id': self.env.user.company_id.id @@ -25,7 +25,7 @@ class TestRepairTraceability(TestMrpCommon): 'name': 'other first serial to remove with repair', 'tracking': 'serial', }) - ptremove_lot = self.env['stock.production.lot'].create({ + ptremove_lot = self.env['stock.lot'].create({ 'name': 'B2', 'product_id': product_to_remove.id, 'company_id': self.env.user.company_id.id @@ -65,7 +65,7 @@ class TestRepairTraceability(TestMrpCommon): mo2 = mo2_form.save() mo2.action_confirm() # Set serial to A2 - mo2.lot_producing_id = self.env['stock.production.lot'].create({ + mo2.lot_producing_id = self.env['stock.lot'].create({ 'name': 'A2', 'product_id': product_to_repair.id, 'company_id': self.env.user.company_id.id diff --git a/addons/mrp_subcontracting/tests/test_subcontracting.py b/addons/mrp_subcontracting/tests/test_subcontracting.py index 2a4a1e6e4d9..e9a5a141aa6 100644 --- a/addons/mrp_subcontracting/tests/test_subcontracting.py +++ b/addons/mrp_subcontracting/tests/test_subcontracting.py @@ -679,12 +679,12 @@ class TestSubcontractingTracking(TransactionCase): self.assertEqual(len(picking), 1) self.assertEqual(picking.picking_type_id, wh.subcontracting_resupply_type_id) - lot_id = self.env['stock.production.lot'].create({ + lot_id = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.finished_product.id, 'company_id': self.env.company.id, }) - serial_id = self.env['stock.production.lot'].create({ + serial_id = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.comp1_sn.id, 'company_id': self.env.company.id, @@ -787,7 +787,7 @@ class TestSubcontractingTracking(TransactionCase): self.assertEqual(mo.picking_type_id, wh.subcontracting_type_id) self.assertFalse(mo.picking_type_id.active) - lot_comp2 = self.env['stock.production.lot'].create({ + lot_comp2 = self.env['stock.lot'].create({ 'name': 'lot_comp2', 'product_id': self.comp2.id, 'company_id': self.env.company.id, @@ -795,12 +795,12 @@ class TestSubcontractingTracking(TransactionCase): serials_finished = [] serials_comp1 = [] for i in range(todo_nb): - serials_finished.append(self.env['stock.production.lot'].create({ + serials_finished.append(self.env['stock.lot'].create({ 'name': 'serial_fin_%s' % i, 'product_id': self.finished_product.id, 'company_id': self.env.company.id, })) - serials_comp1.append(self.env['stock.production.lot'].create({ + serials_comp1.append(self.env['stock.lot'].create({ 'name': 'serials_comp1_%s' % i, 'product_id': self.comp1_sn.id, 'company_id': self.env.company.id, @@ -861,7 +861,7 @@ class TestSubcontractingTracking(TransactionCase): bom_line.product_qty = 1 bom = bom_form.save() - finished_lot, component_lot = self.env['stock.production.lot'].create([{ + finished_lot, component_lot = self.env['stock.lot'].create([{ 'name': 'lot_%s' % product.name, 'product_id': product.id, 'company_id': self.env.company.id, diff --git a/addons/mrp_subcontracting_account/tests/test_subcontracting_account.py b/addons/mrp_subcontracting_account/tests/test_subcontracting_account.py index 60a1da5d0c7..d973c7652a4 100644 --- a/addons/mrp_subcontracting_account/tests/test_subcontracting_account.py +++ b/addons/mrp_subcontracting_account/tests/test_subcontracting_account.py @@ -115,7 +115,7 @@ class TestAccountSubcontractingFlows(TestMrpSubcontractingCommon): # We should be able to call the 'record_components' button self.assertTrue(picking_receipt.display_action_record_components) - lot_comp2 = self.env['stock.production.lot'].create({ + lot_comp2 = self.env['stock.lot'].create({ 'name': 'lot_comp2', 'product_id': self.comp2.id, 'company_id': self.env.company.id, @@ -123,12 +123,12 @@ class TestAccountSubcontractingFlows(TestMrpSubcontractingCommon): serials_finished = [] serials_comp1 = [] for i in range(todo_nb): - serials_finished.append(self.env['stock.production.lot'].create({ + serials_finished.append(self.env['stock.lot'].create({ 'name': 'serial_fin_%s' % i, 'product_id': self.finished.id, 'company_id': self.env.company.id, })) - serials_comp1.append(self.env['stock.production.lot'].create({ + serials_comp1.append(self.env['stock.lot'].create({ 'name': 'serials_comp1_%s' % i, 'product_id': self.comp1.id, 'company_id': self.env.company.id, diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index de7d1247bf7..70cf52763b9 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -821,7 +821,7 @@ class PosOrder(models.Model): 'lines': [[0, 0, line] for line in order.lines.export_for_ui()], 'statement_ids': [[0, 0, payment] for payment in order.payment_ids.export_for_ui()], 'name': order.pos_reference, - 'uid': re.search('([0-9]|-){14}', order.pos_reference).group(0), + 'uid': re.search('([0-9-] r){14}', order.pos_reference).group(0), 'amount_paid': order.amount_paid, 'amount_total': order.amount_total, 'amount_tax': order.amount_tax, diff --git a/addons/point_of_sale/models/stock_picking.py b/addons/point_of_sale/models/stock_picking.py index 89cd7d05dae..39555439b25 100644 --- a/addons/point_of_sale/models/stock_picking.py +++ b/addons/point_of_sale/models/stock_picking.py @@ -106,13 +106,13 @@ class StockPicking(models.Model): ml_vals = move._prepare_move_line_vals() ml_vals.update({'qty_done':qty}) if self.picking_type_id.use_existing_lots: - existing_lot = self.env['stock.production.lot'].search([ + existing_lot = self.env['stock.lot'].search([ ('company_id', '=', self.company_id.id), ('product_id', '=', line.product_id.id), ('name', '=', lot.lot_name) ]) if not existing_lot and self.picking_type_id.use_create_lots: - existing_lot = self.env['stock.production.lot'].create({ + existing_lot = self.env['stock.lot'].create({ 'company_id': self.company_id.id, 'product_id': line.product_id.id, 'name': lot.lot_name, diff --git a/addons/point_of_sale/tests/test_point_of_sale_flow.py b/addons/point_of_sale/tests/test_point_of_sale_flow.py index 4dc2928390b..810b6b013f9 100644 --- a/addons/point_of_sale/tests/test_point_of_sale_flow.py +++ b/addons/point_of_sale/tests/test_point_of_sale_flow.py @@ -101,12 +101,12 @@ class TestPointOfSaleFlow(TestPointOfSaleCommon): 'categ_id': self.env.ref('product.product_category_all').id, }) - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': '1001', 'product_id': self.product2.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': '1002', 'product_id': self.product2.id, 'company_id': self.env.company.id, @@ -416,7 +416,7 @@ class TestPointOfSaleFlow(TestPointOfSaleCommon): 'usage': 'internal', 'location_id': wh_location.id, }) - lot = self.env['stock.production.lot'].create({ + lot = self.env['stock.lot'].create({ 'name': 'SuperLot', 'product_id': tracked_product.id, 'company_id': self.env.company.id, diff --git a/addons/product_expiry/data/product_expiry_data.xml b/addons/product_expiry/data/product_expiry_data.xml index dd0711c79d5..9cb695b5f2f 100644 --- a/addons/product_expiry/data/product_expiry_data.xml +++ b/addons/product_expiry/data/product_expiry_data.xml @@ -7,7 +7,7 @@ Alert Date Reached default - stock.production.lot + stock.lot fa-tasks 0 diff --git a/addons/product_expiry/models/production_lot.py b/addons/product_expiry/models/production_lot.py index c84d6171048..3e35394d747 100644 --- a/addons/product_expiry/models/production_lot.py +++ b/addons/product_expiry/models/production_lot.py @@ -4,8 +4,8 @@ import datetime from odoo import api, fields, models, SUPERUSER_ID, _ -class StockProductionLot(models.Model): - _inherit = 'stock.production.lot' +class StockLot(models.Model): + _inherit = 'stock.lot' use_expiration_date = fields.Boolean( string='Use Expiration Date', related='product_id.use_expiration_date') @@ -82,7 +82,7 @@ class StockProductionLot(models.Model): No further activity will be generated on lots whose alert_date has already been reached (even if the alert_date is changed). """ - alert_lots = self.env['stock.production.lot'].search([ + alert_lots = self.env['stock.lot'].search([ ('alert_date', '<=', fields.Date.today()), ('product_expiry_reminded', '=', False)]) @@ -129,6 +129,6 @@ class ProcurementGroup(models.Model): @api.model def _run_scheduler_tasks(self, use_new_cursor=False, company_id=False): super(ProcurementGroup, self)._run_scheduler_tasks(use_new_cursor=use_new_cursor, company_id=company_id) - self.env['stock.production.lot']._alert_date_exceeded() + self.env['stock.lot']._alert_date_exceeded() if use_new_cursor: self.env.cr.commit() diff --git a/addons/product_expiry/tests/__init__.py b/addons/product_expiry/tests/__init__.py index 858d9530d50..8e1d8c8bebb 100644 --- a/addons/product_expiry/tests/__init__.py +++ b/addons/product_expiry/tests/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import test_stock_production_lot +from . import test_stock_lot diff --git a/addons/product_expiry/tests/test_stock_production_lot.py b/addons/product_expiry/tests/test_stock_lot.py similarity index 96% rename from addons/product_expiry/tests/test_stock_production_lot.py rename to addons/product_expiry/tests/test_stock_lot.py index 69dccb1a181..3c80bbc13d0 100644 --- a/addons/product_expiry/tests/test_stock_production_lot.py +++ b/addons/product_expiry/tests/test_stock_lot.py @@ -10,11 +10,11 @@ from odoo.addons.stock.tests.common import TestStockCommon from odoo.tests.common import Form -class TestStockProductionLot(TestStockCommon): +class TestStockLot(TestStockCommon): @classmethod def setUpClass(cls): - super(TestStockProductionLot, cls).setUpClass() + super().setUpClass() # Creates a tracked product with expiration dates. cls.apple_product = cls.ProductObj.create({ 'name': 'Apple', @@ -30,7 +30,7 @@ class TestStockProductionLot(TestStockCommon): def test_00_stock_production_lot(self): """ Test Scheduled Task on lot with an alert_date in the past creates an activity """ - # create product + # create product self.productAAA = self.ProductObj.create({ 'name': 'Product AAA', 'type': 'product', @@ -61,7 +61,7 @@ class TestStockProductionLot(TestStockCommon): 'location_id': self.supplier_location, 'location_dest_id': self.stock_location }) - + self.assertEqual(picking_in.move_ids.state, 'draft', 'Wrong state of move line.') picking_in.action_confirm() self.assertEqual(picking_in.move_ids.state, 'assigned', 'Wrong state of move line.') @@ -75,24 +75,24 @@ class TestStockProductionLot(TestStockCommon): picking_in._action_done() # run scheduled tasks - self.env['stock.production.lot']._alert_date_exceeded() + self.env['stock.lot']._alert_date_exceeded() # check a new activity has been created activity_id = self.env.ref('product_expiry.mail_activity_type_alert_date_reached').id activity_count = self.env['mail.activity'].search_count([ ('activity_type_id', '=', activity_id), - ('res_model_id', '=', self.env.ref('stock.model_stock_production_lot').id), + ('res_model_id', '=', self.env.ref('stock.model_stock_lot').id), ('res_id', '=', self.lot1_productAAA.id) ]) self.assertEqual(activity_count, 1, 'No activity created while there should be one') # run the scheduler a second time - self.env['stock.production.lot']._alert_date_exceeded() + self.env['stock.lot']._alert_date_exceeded() # check there is still only one activity, no additional activity is created if there is already an existing activity activity_count = self.env['mail.activity'].search_count([ ('activity_type_id', '=', activity_id), - ('res_model_id', '=', self.env.ref('stock.model_stock_production_lot').id), + ('res_model_id', '=', self.env.ref('stock.model_stock_lot').id), ('res_id', '=', self.lot1_productAAA.id) ]) self.assertEqual(activity_count, 1, 'There should be one and only one activity') @@ -100,7 +100,7 @@ class TestStockProductionLot(TestStockCommon): # mark the activity as done mail_activity = self.env['mail.activity'].search([ ('activity_type_id', '=', activity_id), - ('res_model_id', '=', self.env.ref('stock.model_stock_production_lot').id), + ('res_model_id', '=', self.env.ref('stock.model_stock_lot').id), ('res_id', '=', self.lot1_productAAA.id) ]) mail_activity.action_done() @@ -108,18 +108,18 @@ class TestStockProductionLot(TestStockCommon): # check there is no more activity (because it is already done) activity_count = self.env['mail.activity'].search_count([ ('activity_type_id', '=', activity_id), - ('res_model_id', '=', self.env.ref('stock.model_stock_production_lot').id), + ('res_model_id', '=', self.env.ref('stock.model_stock_lot').id), ('res_id', '=', self.lot1_productAAA.id) ]) self.assertEqual(activity_count, 0,"As activity is done, there shouldn't be any related activity") - + # run the scheduler a third time - self.env['stock.production.lot']._alert_date_exceeded() + self.env['stock.lot']._alert_date_exceeded() # check there is no activity created activity_count = self.env['mail.activity'].search_count([ ('activity_type_id', '=', activity_id), - ('res_model_id', '=', self.env.ref('stock.model_stock_production_lot').id), + ('res_model_id', '=', self.env.ref('stock.model_stock_lot').id), ('res_id', '=',self.lot1_productAAA.id) ]) self.assertEqual(activity_count, 0, "As there is already an activity marked as done, there shouldn't be any related activity created for this lot") @@ -127,9 +127,9 @@ class TestStockProductionLot(TestStockCommon): def test_01_stock_production_lot(self): """ Test Scheduled Task on lot with an alert_date in future does not create an activity """ - # create product + # create product self.productBBB = self.ProductObj.create({ - 'name': 'Product BBB', + 'name': 'Product BBB', 'type': 'product', 'tracking':'lot' }) @@ -155,7 +155,7 @@ class TestStockProductionLot(TestStockCommon): 'picking_id': picking_in.id, 'location_id': self.supplier_location, 'location_dest_id': self.stock_location}) - + self.assertEqual(picking_in.move_ids.state, 'draft', 'Wrong state of move line.') picking_in.action_confirm() self.assertEqual(picking_in.move_ids.state, 'assigned', 'Wrong state of move line.') @@ -169,13 +169,13 @@ class TestStockProductionLot(TestStockCommon): picking_in._action_done() # run scheduled tasks - self.env['stock.production.lot']._alert_date_exceeded() + self.env['stock.lot']._alert_date_exceeded() # check a new activity has not been created activity_id = self.env.ref('product_expiry.mail_activity_type_alert_date_reached').id activity_count = self.env['mail.activity'].search_count([ ('activity_type_id', '=', activity_id), - ('res_model_id', '=', self.env.ref('stock.model_stock_production_lot').id), + ('res_model_id', '=', self.env.ref('stock.model_stock_lot').id), ('res_id', '=', self.lot1_productBBB.id) ]) self.assertEqual(activity_count, 0, "An activity has been created while it shouldn't") @@ -183,7 +183,7 @@ class TestStockProductionLot(TestStockCommon): def test_02_stock_production_lot(self): """ Test Scheduled Task on lot without an alert_date does not create an activity """ - # create product + # create product self.productCCC = self.ProductObj.create({'name': 'Product CCC', 'type': 'product', 'tracking':'lot'}) # create a new lot with with alert date in the past @@ -202,7 +202,7 @@ class TestStockProductionLot(TestStockCommon): 'picking_id': picking_in.id, 'location_id': self.supplier_location, 'location_dest_id': self.stock_location}) - + self.assertEqual(picking_in.move_ids.state, 'draft', 'Wrong state of move line.') picking_in.action_confirm() self.assertEqual(picking_in.move_ids.state, 'assigned', 'Wrong state of move line.') @@ -216,13 +216,13 @@ class TestStockProductionLot(TestStockCommon): picking_in._action_done() # run scheduled tasks - self.env['stock.production.lot']._alert_date_exceeded() + self.env['stock.lot']._alert_date_exceeded() # check a new activity has not been created activity_id = self.env.ref('product_expiry.mail_activity_type_alert_date_reached').id activity_count = self.env['mail.activity'].search_count([ ('activity_type_id', '=', activity_id), - ('res_model_id', '=', self.env.ref('stock.model_stock_production_lot').id), + ('res_model_id', '=', self.env.ref('stock.model_stock_lot').id), ('res_id', '=', self.lot1_productCCC.id) ]) self.assertEqual(activity_count, 0, "An activity has been created while it shouldn't") @@ -302,7 +302,7 @@ class TestStockProductionLot(TestStockCommon): receipt._action_done() # Get back the lot created when the picking was done... - apple_lot = self.env['stock.production.lot'].search( + apple_lot = self.env['stock.lot'].search( [('product_id', '=', self.apple_product.id)], limit=1, ) @@ -350,7 +350,7 @@ class TestStockProductionLot(TestStockCommon): receipt._action_done() # Get back the lot created when the picking was done... - apple_lot = self.env['stock.production.lot'].search( + apple_lot = self.env['stock.lot'].search( [('product_id', '=', self.apple_product.id)], limit=1, ) diff --git a/addons/product_expiry/views/production_lot_views.xml b/addons/product_expiry/views/production_lot_views.xml index 34a5a14450f..6b75e89a27f 100644 --- a/addons/product_expiry/views/production_lot_views.xml +++ b/addons/product_expiry/views/production_lot_views.xml @@ -2,7 +2,7 @@ stock.production.lot.inherit.form - stock.production.lot + stock.lot @@ -29,7 +29,7 @@ stock.production.lot.search.inherit - stock.production.lot + stock.lot @@ -40,7 +40,7 @@ stock.production.lot.tree.inherit.product.expiry - stock.production.lot + stock.lot diff --git a/addons/product_expiry/wizard/confirm_expiry.py b/addons/product_expiry/wizard/confirm_expiry.py index 80a6255d6d0..eb2c2d8d34a 100644 --- a/addons/product_expiry/wizard/confirm_expiry.py +++ b/addons/product_expiry/wizard/confirm_expiry.py @@ -8,7 +8,7 @@ class ConfirmExpiry(models.TransientModel): _name = 'expiry.picking.confirmation' _description = 'Confirm Expiry' - lot_ids = fields.Many2many('stock.production.lot', readonly=True, required=True) + lot_ids = fields.Many2many('stock.lot', readonly=True, required=True) picking_ids = fields.Many2many('stock.picking', readonly=True) description = fields.Char('Description', compute='_compute_descriptive_fields') show_lots = fields.Boolean('Show Lots', compute='_compute_descriptive_fields') diff --git a/addons/purchase_stock/__manifest__.py b/addons/purchase_stock/__manifest__.py index fa009dbcd4d..dd2f231955d 100644 --- a/addons/purchase_stock/__manifest__.py +++ b/addons/purchase_stock/__manifest__.py @@ -19,7 +19,7 @@ 'views/stock_rule_views.xml', 'views/res_config_settings_views.xml', 'views/res_partner_views.xml', - 'views/stock_production_lot_views.xml', + 'views/stock_lot_views.xml', 'views/product_category_views.xml', 'report/purchase_report_views.xml', 'report/purchase_report_templates.xml', diff --git a/addons/purchase_stock/models/stock.py b/addons/purchase_stock/models/stock.py index c698d5ce841..4ab6461def9 100644 --- a/addons/purchase_stock/models/stock.py +++ b/addons/purchase_stock/models/stock.py @@ -274,8 +274,8 @@ class Orderpoint(models.Model): return date -class ProductionLot(models.Model): - _inherit = 'stock.production.lot' +class StockLot(models.Model): + _inherit = 'stock.lot' purchase_order_ids = fields.Many2many('purchase.order', string="Purchase Orders", compute='_compute_purchase_order_ids', readonly=True, store=False) purchase_order_count = fields.Integer('Purchase order count', compute='_compute_purchase_order_ids') diff --git a/addons/purchase_stock/views/stock_production_lot_views.xml b/addons/purchase_stock/views/stock_lot_views.xml similarity index 96% rename from addons/purchase_stock/views/stock_production_lot_views.xml rename to addons/purchase_stock/views/stock_lot_views.xml index 7102471d383..3c40675398d 100644 --- a/addons/purchase_stock/views/stock_production_lot_views.xml +++ b/addons/purchase_stock/views/stock_lot_views.xml @@ -2,7 +2,7 @@ stock.production.lot.view.form - stock.production.lot + stock.lot diff --git a/addons/repair/__manifest__.py b/addons/repair/__manifest__.py index c69466d64ca..5a8fd994e57 100644 --- a/addons/repair/__manifest__.py +++ b/addons/repair/__manifest__.py @@ -29,7 +29,7 @@ The following topics are covered by this module: 'wizard/stock_warn_insufficient_qty_views.xml', 'views/stock_move_views.xml', 'views/repair_views.xml', - 'views/stock_production_lot_views.xml', + 'views/stock_lot_views.xml', 'report/repair_reports.xml', 'report/repair_templates_repair_order.xml', 'data/ir_sequence_data.xml', diff --git a/addons/repair/models/__init__.py b/addons/repair/models/__init__.py index 975c1b98256..b082b6a40bb 100644 --- a/addons/repair/models/__init__.py +++ b/addons/repair/models/__init__.py @@ -3,5 +3,5 @@ from . import repair from . import stock_traceability -from . import stock_production_lot +from . import stock_lot from . import account_move diff --git a/addons/repair/models/repair.py b/addons/repair/models/repair.py index 56366cdd857..4e7da44f79a 100644 --- a/addons/repair/models/repair.py +++ b/addons/repair/models/repair.py @@ -72,7 +72,7 @@ class Repair(models.Model): help="This is the location where the product to repair is located.", states={'draft': [('readonly', False)], 'confirmed': [('readonly', True)]}) lot_id = fields.Many2one( - 'stock.production.lot', 'Lot/Serial', + 'stock.lot', 'Lot/Serial', domain="[('product_id','=', product_id), ('company_id', '=', company_id)]", check_company=True, help="Products repaired are all belonging to this lot") guarantee_limit = fields.Date('Warranty Expiration', states={'confirmed': [('readonly', True)]}) @@ -655,7 +655,7 @@ class RepairLine(models.Model): 'stock.move', 'Inventory Move', copy=False, readonly=True) lot_id = fields.Many2one( - 'stock.production.lot', 'Lot/Serial', + 'stock.lot', 'Lot/Serial', domain="[('product_id','=', product_id), ('company_id', '=', company_id)]", check_company=True) state = fields.Selection([ ('draft', 'Draft'), diff --git a/addons/repair/models/stock_production_lot.py b/addons/repair/models/stock_lot.py similarity index 95% rename from addons/repair/models/stock_production_lot.py rename to addons/repair/models/stock_lot.py index f830bbac4b5..84606d71fc9 100644 --- a/addons/repair/models/stock_production_lot.py +++ b/addons/repair/models/stock_lot.py @@ -3,8 +3,8 @@ from collections import defaultdict from odoo import api, fields, models, _ -class ProductionLot(models.Model): - _inherit = 'stock.production.lot' +class StockLot(models.Model): + _inherit = 'stock.lot' repair_order_ids = fields.Many2many('repair.order', string="Repair Orders", compute="_compute_repair_order_ids") repair_order_count = fields.Integer('Repair order count', compute="_compute_repair_order_ids") diff --git a/addons/repair/views/stock_production_lot_views.xml b/addons/repair/views/stock_lot_views.xml similarity index 94% rename from addons/repair/views/stock_production_lot_views.xml rename to addons/repair/views/stock_lot_views.xml index f68bfd22410..8fa41f02c8e 100644 --- a/addons/repair/views/stock_production_lot_views.xml +++ b/addons/repair/views/stock_lot_views.xml @@ -2,7 +2,7 @@ stock.production.lot.view.form - stock.production.lot + stock.lot diff --git a/addons/sale_stock/__manifest__.py b/addons/sale_stock/__manifest__.py index c9167d60f8f..fe5f98cd4ed 100644 --- a/addons/sale_stock/__manifest__.py +++ b/addons/sale_stock/__manifest__.py @@ -27,7 +27,7 @@ Preferences 'views/stock_views.xml', 'views/res_config_settings_views.xml', 'views/sale_stock_portal_template.xml', - 'views/stock_production_lot_views.xml', + 'views/stock_lot_views.xml', 'views/res_users_views.xml', 'report/report_stock_forecasted.xml', 'report/sale_order_report_templates.xml', diff --git a/addons/sale_stock/models/stock.py b/addons/sale_stock/models/stock.py index f6f27e6fcc2..35dca64007c 100644 --- a/addons/sale_stock/models/stock.py +++ b/addons/sale_stock/models/stock.py @@ -151,8 +151,8 @@ class StockPicking(models.Model): return super(StockPicking, self)._log_less_quantities_than_expected(moves) -class ProductionLot(models.Model): - _inherit = 'stock.production.lot' +class StockLot(models.Model): + _inherit = 'stock.lot' sale_order_ids = fields.Many2many('sale.order', string="Sales Orders", compute='_compute_sale_order_ids') sale_order_count = fields.Integer('Sale order count', compute='_compute_sale_order_ids') diff --git a/addons/sale_stock/views/stock_production_lot_views.xml b/addons/sale_stock/views/stock_lot_views.xml similarity index 96% rename from addons/sale_stock/views/stock_production_lot_views.xml rename to addons/sale_stock/views/stock_lot_views.xml index 817285d258e..0eb2b50eb6f 100644 --- a/addons/sale_stock/views/stock_production_lot_views.xml +++ b/addons/sale_stock/views/stock_lot_views.xml @@ -2,7 +2,7 @@ stock.production.lot.view.form - stock.production.lot + stock.lot diff --git a/addons/stock/__manifest__.py b/addons/stock/__manifest__.py index 819f157723c..ddff4d0100a 100644 --- a/addons/stock/__manifest__.py +++ b/addons/stock/__manifest__.py @@ -69,7 +69,7 @@ 'views/res_partner_views.xml', 'views/product_strategy_views.xml', 'views/product_views.xml', - 'views/stock_production_lot_views.xml', + 'views/stock_lot_views.xml', 'views/stock_scrap_views.xml', 'views/stock_quant_views.xml', 'views/stock_location_views.xml', diff --git a/addons/stock/data/stock_demo.xml b/addons/stock/data/stock_demo.xml index 31d7ee6ae0e..c4abbaff653 100644 --- a/addons/stock/data/stock_demo.xml +++ b/addons/stock/data/stock_demo.xml @@ -5,7 +5,7 @@ - + 0000000000029 diff --git a/addons/stock/data/stock_demo2.xml b/addons/stock/data/stock_demo2.xml index def2a09aabd..8e6d8429a89 100644 --- a/addons/stock/data/stock_demo2.xml +++ b/addons/stock/data/stock_demo2.xml @@ -39,19 +39,19 @@ - + LOT-000001 - + CM-BOX-00001 - + CM-BOX-00002 diff --git a/addons/stock/models/__init__.py b/addons/stock/models/__init__.py index 03ac4fdf92a..67a86ae4376 100644 --- a/addons/stock/models/__init__.py +++ b/addons/stock/models/__init__.py @@ -10,7 +10,7 @@ from . import stock_location from . import stock_move from . import stock_move_line from . import stock_orderpoint -from . import stock_production_lot +from . import stock_lot from . import stock_picking from . import stock_quant from . import stock_rule diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index a88998535f0..ce8e787eadc 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -592,7 +592,7 @@ class Product(models.Model): def _filter_to_unlink(self): domain = [('product_id', 'in', self.ids)] - lines = self.env['stock.production.lot'].read_group(domain, ['product_id'], ['product_id']) + lines = self.env['stock.lot'].read_group(domain, ['product_id'], ['product_id']) linked_product_ids = [group['product_id'][0] for group in lines] return super(Product, self - self.browse(linked_product_ids))._filter_to_unlink() diff --git a/addons/stock/models/stock_production_lot.py b/addons/stock/models/stock_lot.py similarity index 96% rename from addons/stock/models/stock_production_lot.py rename to addons/stock/models/stock_lot.py index 78d897957ed..cbbf671a2cc 100644 --- a/addons/stock/models/stock_production_lot.py +++ b/addons/stock/models/stock_lot.py @@ -9,8 +9,8 @@ from odoo import _, api, fields, models from odoo.exceptions import UserError, ValidationError -class ProductionLot(models.Model): - _name = 'stock.production.lot' +class StockLot(models.Model): + _name = 'stock.lot' _inherit = ['mail.thread', 'mail.activity.mixin'] _description = 'Lot/Serial' _check_company_auto = True @@ -64,11 +64,11 @@ class ProductionLot(models.Model): def _get_next_serial(self, company, product): """Return the next serial number to be attributed to the product.""" if product.tracking == "serial": - last_serial = self.env['stock.production.lot'].search( + last_serial = self.env['stock.lot'].search( [('company_id', '=', company.id), ('product_id', '=', product.id)], limit=1, order='id DESC') if last_serial: - return self.env['stock.production.lot'].generate_lot_names(last_serial.name, 2)[1] + return self.env['stock.lot'].generate_lot_names(last_serial.name, 2)[1] return False @api.constrains('name', 'product_id', 'company_id') @@ -131,7 +131,7 @@ class ProductionLot(models.Model): @api.model_create_multi def create(self, vals_list): self._check_create() - return super(ProductionLot, self.with_context(mail_create_nosubscribe=True)).create(vals_list) + return super(StockLot, self.with_context(mail_create_nosubscribe=True)).create(vals_list) def write(self, vals): if 'company_id' in vals: @@ -146,7 +146,7 @@ class ProductionLot(models.Model): 'if some stock moves have already been created with that number. ' 'This would lead to inconsistencies in your stock.' )) - return super(ProductionLot, self).write(vals) + return super().write(vals) def copy(self, default=None): if default is None: diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 0ee92874890..b0771a5e7b6 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -171,7 +171,7 @@ class StockMove(models.Model): orderpoint_id = fields.Many2one('stock.warehouse.orderpoint', 'Original Reordering Rule', check_company=True, index=True) forecast_availability = fields.Float('Forecast Availability', compute='_compute_forecast_information', digits='Product Unit of Measure', compute_sudo=True) forecast_expected_date = fields.Datetime('Forecasted Expected date', compute='_compute_forecast_information', compute_sudo=True) - lot_ids = fields.Many2many('stock.production.lot', compute='_compute_lot_ids', inverse='_set_lot_ids', string='Serial Numbers', readonly=False) + lot_ids = fields.Many2many('stock.lot', compute='_compute_lot_ids', inverse='_set_lot_ids', string='Serial Numbers', readonly=False) reservation_date = fields.Date('Date to Reserve', compute='_compute_reservation_date', store=True, help="This is a technical field for calculating when a move should be reserved") product_packaging_id = fields.Many2one('product.packaging', 'Packaging', domain="[('product_id', '=', product_id)]", check_company=True) @@ -657,7 +657,7 @@ class StockMove(models.Model): view = self.env.ref('stock.view_stock_move_nosuggest_operations') if self.product_id.tracking == "serial" and self.state == "assigned": - self.next_serial = self.env['stock.production.lot']._get_next_serial(self.company_id, self.product_id) + self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id) return { 'name': _('Detailed Operations'), @@ -766,7 +766,7 @@ class StockMove(models.Model): `next_serial`) and create a move line for each generated `lot_name`. """ self.ensure_one() - lot_names = self.env['stock.production.lot'].generate_lot_names(self.next_serial, next_serial_count or self.next_serial_count) + lot_names = self.env['stock.lot'].generate_lot_names(self.next_serial, next_serial_count or self.next_serial_count) move_lines_commands = self._generate_serial_move_line_commands(lot_names) self.write({'move_line_ids': move_lines_commands}) return True @@ -993,7 +993,7 @@ class StockMove(models.Model): self.update({'move_line_ids': move_lines_commands}) else: self.update({'move_line_nosuggest_ids': move_lines_commands}) - existing_lots = self.env['stock.production.lot'].search([ + existing_lots = self.env['stock.lot'].search([ ('company_id', '=', self.company_id.id), ('product_id', '=', self.product_id.id), ('name', 'in', split_lines), @@ -1317,7 +1317,7 @@ class StockMove(models.Model): self.ensure_one() if not lot_id: - lot_id = self.env['stock.production.lot'] + lot_id = self.env['stock.lot'] if not package_id: package_id = self.env['stock.quant.package'] if not owner_id: diff --git a/addons/stock/models/stock_move_line.py b/addons/stock/models/stock_move_line.py index bfad8ec94ea..b4c38da24a3 100644 --- a/addons/stock/models/stock_move_line.py +++ b/addons/stock/models/stock_move_line.py @@ -41,7 +41,7 @@ class StockMoveLine(models.Model): domain="[('location_id', '=', location_id)]") package_level_id = fields.Many2one('stock.package_level', 'Package Level', check_company=True) lot_id = fields.Many2one( - 'stock.production.lot', 'Lot/Serial Number', + 'stock.lot', 'Lot/Serial Number', domain="[('product_id', '=', product_id), ('company_id', '=', company_id)]", check_company=True) lot_name = fields.Char('Lot/Serial Number Name') result_package_id = fields.Many2one( @@ -161,7 +161,7 @@ class StockMoveLine(models.Model): if counter.get(self.lot_name) and counter[self.lot_name] > 1: message = _('You cannot use the same serial number twice. Please correct the serial numbers encoded.') elif not self.lot_id: - lots = self.env['stock.production.lot'].search([('product_id', '=', self.product_id.id), + lots = self.env['stock.lot'].search([('product_id', '=', self.product_id.id), ('name', '=', self.lot_name), ('company_id', '=', self.company_id.id)]) quants = lots.quant_ids.filtered(lambda q: q.quantity != 0 and q.location_id.usage in ['customer', 'internal', 'transit']) @@ -312,7 +312,7 @@ class StockMoveLine(models.Model): triggers = [ ('location_id', 'stock.location'), ('location_dest_id', 'stock.location'), - ('lot_id', 'stock.production.lot'), + ('lot_id', 'stock.lot'), ('package_id', 'stock.quant.package'), ('result_package_id', 'stock.quant.package'), ('owner_id', 'res.partner'), @@ -520,7 +520,7 @@ class StockMoveLine(models.Model): # the fly before assigning it to the move line if the user checked both # `use_create_lots` and `use_existing_lots`. if ml.lot_name and not ml.lot_id: - lot = self.env['stock.production.lot'].search([ + lot = self.env['stock.lot'].search([ ('company_id', '=', ml.company_id.id), ('product_id', '=', ml.product_id.id), ('name', '=', ml.lot_name), @@ -625,7 +625,7 @@ class StockMoveLine(models.Model): key_to_index[key] = len(lot_vals) lot_vals.append(ml._prepare_new_lot_vals()) - lots = self.env['stock.production.lot'].create(lot_vals) + lots = self.env['stock.lot'].create(lot_vals) for key, mls in key_to_mls.items(): mls._assign_production_lot(lots[key_to_index[key]].with_prefetch(lots._ids)) # With prefetch to reconstruct the ones broke by accessing by index @@ -645,7 +645,7 @@ class StockMoveLine(models.Model): def _log_message(self, record, move, template, vals): data = vals.copy() if 'lot_id' in vals and vals['lot_id'] != move.lot_id.id: - data['lot_name'] = self.env['stock.production.lot'].browse(vals.get('lot_id')).name + data['lot_name'] = self.env['stock.lot'].browse(vals.get('lot_id')).name if 'location_id' in vals: data['location_name'] = self.env['stock.location'].browse(vals.get('location_id')).name if 'location_dest_id' in vals: diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index 668d862fa2e..4d013a2a724 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -67,7 +67,7 @@ class StockQuant(models.Model): domain=lambda self: self._domain_location_id(), auto_join=True, ondelete='restrict', required=True, index=True, check_company=True) lot_id = fields.Many2one( - 'stock.production.lot', 'Lot/Serial Number', index=True, + 'stock.lot', 'Lot/Serial Number', index=True, ondelete='restrict', check_company=True, domain=lambda self: self._domain_lot_id()) package_id = fields.Many2one( @@ -185,7 +185,7 @@ class StockQuant(models.Model): # Create an empty quant or write on a similar one. product = self.env['product.product'].browse(vals['product_id']) location = self.env['stock.location'].browse(vals['location_id']) - lot_id = self.env['stock.production.lot'].browse(vals.get('lot_id')) + lot_id = self.env['stock.lot'].browse(vals.get('lot_id')) package_id = self.env['stock.quant.package'].browse(vals.get('package_id')) owner_id = self.env['res.partner'].browse(vals.get('owner_id')) quant = self._gather(product, location, lot_id=lot_id, package_id=package_id, owner_id=owner_id, strict=True) diff --git a/addons/stock/models/stock_scrap.py b/addons/stock/models/stock_scrap.py index 69dd6669fa1..85b47f11102 100644 --- a/addons/stock/models/stock_scrap.py +++ b/addons/stock/models/stock_scrap.py @@ -38,7 +38,7 @@ class StockScrap(models.Model): product_uom_category_id = fields.Many2one(related='product_id.uom_id.category_id') tracking = fields.Selection(string='Product Tracking', readonly=True, related="product_id.tracking") lot_id = fields.Many2one( - 'stock.production.lot', 'Lot/Serial', + 'stock.lot', 'Lot/Serial', states={'done': [('readonly', True)]}, domain="[('product_id', '=', product_id), ('company_id', '=', company_id)]", check_company=True) package_id = fields.Many2one( 'stock.quant.package', 'Package', diff --git a/addons/stock/populate/stock.py b/addons/stock/populate/stock.py index 6b0488653ae..deaaf89ec49 100644 --- a/addons/stock/populate/stock.py +++ b/addons/stock/populate/stock.py @@ -534,7 +534,7 @@ class StockMove(models.Model): package_values.append(package_for_picking) _logger.info("Create lots (%d) for pickings to validate" % len(lot_values)) - lots = self.env["stock.production.lot"].create(lot_values) + lots = self.env["stock.lot"].create(lot_values) _logger.info("Create packages (%d) for pickings to validate" % len(package_values)) packages = self.env["stock.quant.package"].create(package_values) diff --git a/addons/stock/report/stock_report_views.xml b/addons/stock/report/stock_report_views.xml index 2af587cc4dd..7d6337b319d 100644 --- a/addons/stock/report/stock_report_views.xml +++ b/addons/stock/report/stock_report_views.xml @@ -61,12 +61,12 @@ Lot/Serial Number (PDF) - stock.production.lot + stock.lot qweb-pdf stock.report_lot_label stock.report_lot_label 'Lot-Serial - %s' % object.name - + report @@ -97,11 +97,11 @@ Lot/Serial Number (ZPL) - stock.production.lot + stock.lot qweb-text stock.label_lot_template_view stock.label_lot_template_view - + report diff --git a/addons/stock/report/stock_traceability.py b/addons/stock/report/stock_traceability.py index dee6395a1fd..e87bfb6f11b 100644 --- a/addons/stock/report/stock_traceability.py +++ b/addons/stock/report/stock_traceability.py @@ -58,7 +58,7 @@ class MrpStockReport(models.TransientModel): level = kw and kw['level'] or 1 lines = self.env['stock.move.line'] move_line = self.env['stock.move.line'] - if rec_id and model == 'stock.production.lot': + if rec_id and model == 'stock.lot': lines = move_line.search([ ('lot_id', '=', context.get('lot_name') or rec_id), ('state', '=', 'done'), @@ -184,7 +184,7 @@ class MrpStockReport(models.TransientModel): lines = self._get_move_lines(move_line, line_id=line_id) for line in lines: unfoldable = False - if line.consume_line_ids or ( line.lot_id and self._get_move_lines(line) and model != "stock.production.lot"): + if line.consume_line_ids or (line.lot_id and self._get_move_lines(line) and model != "stock.lot"): unfoldable = True final_vals += self._make_dict_move(level, parent_id=line_id, move_line=line, unfoldable=unfoldable) return final_vals diff --git a/addons/stock/security/ir.model.access.csv b/addons/stock/security/ir.model.access.csv index 3a081dd3345..4289439534d 100644 --- a/addons/stock/security/ir.model.access.csv +++ b/addons/stock/security/ir.model.access.csv @@ -10,7 +10,7 @@ access_stock_picking_manager,stock.picking manager,model_stock_picking,stock.gro access_stock_picking_type_all,stock.picking.type all users,model_stock_picking_type,base.group_user,1,0,0,0 access_stock_picking_type_user,stock.picking.type user,model_stock_picking_type,stock.group_stock_user,1,0,0,0 access_stock_picking_type_manager,stock.picking.type manager,model_stock_picking_type,stock.group_stock_manager,1,1,1,1 -access_stock_production_lot_user,stock.production.lot user,model_stock_production_lot,stock.group_stock_user,1,1,1,1 +access_stock_lot_user,stock.lot user,model_stock_lot,stock.group_stock_user,1,1,1,1 access_stock_move_manager,stock.move manager,model_stock_move,stock.group_stock_manager,1,1,1,1 access_stock_move_user,stock.move user,model_stock_move,stock.group_stock_user,1,1,1,0 access_product_product_stock_user,product_product_stock_user,product.model_product_product,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 3ac7aed0c3e..d278afa9bcf 100644 --- a/addons/stock/security/stock_security.xml +++ b/addons/stock/security/stock_security.xml @@ -105,7 +105,7 @@ Stock Production Lot multi-company - + [('company_id','in', company_ids)] diff --git a/addons/stock/static/src/js/stock_traceability_report_widgets.js b/addons/stock/static/src/js/stock_traceability_report_widgets.js index 97468a48135..f78ef87e17e 100644 --- a/addons/stock/static/src/js/stock_traceability_report_widgets.js +++ b/addons/stock/static/src/js/stock_traceability_report_widgets.js @@ -42,7 +42,7 @@ var ReportWidget = Widget.extend({ name: $el.data('lot_name') !== undefined && $el.data('lot_name').toString(), context: { active_id : $el.data('lot_id'), - active_model : 'stock.production.lot', + active_model : 'stock.lot', url: '/stock/output_format/stock/active_id' }, }); diff --git a/addons/stock/tests/common.py b/addons/stock/tests/common.py index cdbd6c499f8..8f24d430b77 100644 --- a/addons/stock/tests/common.py +++ b/addons/stock/tests/common.py @@ -16,7 +16,7 @@ class TestStockCommon(common.TransactionCase): cls.StockQuantObj = cls.env['stock.quant'] cls.PickingObj = cls.env['stock.picking'] cls.MoveObj = cls.env['stock.move'] - cls.LotObj = cls.env['stock.production.lot'] + cls.LotObj = cls.env['stock.lot'] # Model Data cls.picking_type_in = cls.ModelDataObj._xmlid_to_res_id('stock.picking_type_in') diff --git a/addons/stock/tests/test_inventory.py b/addons/stock/tests/test_inventory.py index 3794e4ee42e..edfff18fc22 100644 --- a/addons/stock/tests/test_inventory.py +++ b/addons/stock/tests/test_inventory.py @@ -62,7 +62,7 @@ class TestInventory(TransactionCase): self.assertEqual(len(inventory_quant), 0) - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'sn2', 'product_id': self.product2.id, 'company_id': self.env.company.id, @@ -94,7 +94,7 @@ class TestInventory(TransactionCase): ]) self.assertEqual(len(inventory_quant), 0) - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'sn2', 'product_id': self.product2.id, 'company_id': self.env.company.id, @@ -122,7 +122,7 @@ class TestInventory(TransactionCase): ] inventory_quants = self.env['stock.quant'].search(quant_domain) self.assertEqual(len(inventory_quants), 0) - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'sn2', 'product_id': self.product2.id, 'company_id': self.env.company.id, diff --git a/addons/stock/tests/test_move.py b/addons/stock/tests/test_move.py index 79000d5e7cd..3b59d2a3069 100644 --- a/addons/stock/tests/test_move.py +++ b/addons/stock/tests/test_move.py @@ -277,7 +277,7 @@ class StockMove(TransactionCase): untracked quants. Two moves lines should be created: one for the tracked ones, another for the untracked ones. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, @@ -306,12 +306,12 @@ class StockMove(TransactionCase): reserved. Edit the reserve move lines to set them to new serial numbers, the reservation should stay. Validate and the final quantity in stock should be 0, not negative. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -336,12 +336,12 @@ class StockMove(TransactionCase): self.assertEqual(ml.product_qty, 1.0) # assign lot3 and lot 4 to both untracked move lines - lot3 = self.env['stock.production.lot'].create({ + lot3 = self.env['stock.lot'].create({ 'name': 'lot3', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, }) - lot4 = self.env['stock.production.lot'].create({ + lot4 = self.env['stock.lot'].create({ 'name': 'lot4', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -375,12 +375,12 @@ class StockMove(TransactionCase): ones and assign them serial numbers on the fly. The final quantity in stock should be 0, not negative. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -404,12 +404,12 @@ class StockMove(TransactionCase): move1._action_done() self.env['stock.quant']._update_available_quantity(self.product_serial, self.stock_location, 2) - lot3 = self.env['stock.production.lot'].create({ + lot3 = self.env['stock.lot'].create({ 'name': 'lot3', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, }) - lot4 = self.env['stock.production.lot'].create({ + lot4 = self.env['stock.lot'].create({ 'name': 'lot4', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -446,12 +446,12 @@ class StockMove(TransactionCase): serial number to one that is not in stock. The original serial should go back to stock and the untracked quant should be tracked on the fly and sent instead. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -479,7 +479,7 @@ class StockMove(TransactionCase): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product_serial, self.stock_location, lot_id=lot2, strict=True), 0.0) self.env['stock.quant']._update_available_quantity(self.product_serial, self.stock_location, 1) - lot3 = self.env['stock.production.lot'].create({ + lot3 = self.env['stock.lot'].create({ 'name': 'lot3', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -507,7 +507,7 @@ class StockMove(TransactionCase): # create an untracked quant self.env['stock.quant']._update_available_quantity(self.product_serial, self.stock_location, 1.0) - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -546,12 +546,12 @@ class StockMove(TransactionCase): move1._action_assign() self.assertEqual(move1.state, 'assigned') - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -575,12 +575,12 @@ class StockMove(TransactionCase): untracked quant then increase a non-existing tracked one that will fallback on the untracked quant. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -624,7 +624,7 @@ class StockMove(TransactionCase): system will update the reservation and use the untracked quant. Now unreserve, no error should happen """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -650,7 +650,7 @@ class StockMove(TransactionCase): # change the lot_id to one not available in stock while an untracked quant is available self.env['stock.quant']._update_available_quantity(self.product_serial, self.stock_location, 1) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -1647,12 +1647,12 @@ class StockMove(TransactionCase): self.assertEqual(move1.availability, 50.0) def test_availability_3(self): - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -1803,7 +1803,7 @@ class StockMove(TransactionCase): # make 12 quants of 1 for i in range(1, 13): - lot_id = self.env['stock.production.lot'].create({ + lot_id = self.env['stock.lot'].create({ 'name': 'lot%s' % str(i), 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -2127,7 +2127,7 @@ class StockMove(TransactionCase): 'type': 'product', }) - serial_numbers = self.env['stock.production.lot'].create([{ + serial_numbers = self.env['stock.lot'].create([{ 'name': str(x), 'product_id': product.id, 'company_id': self.env.company.id, @@ -2214,7 +2214,7 @@ class StockMove(TransactionCase): """ Test the assignment mechanism when two chained stock moves try to move one unit of a tracked product. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product.id, 'company_id': self.env.company.id, @@ -2337,7 +2337,7 @@ class StockMove(TransactionCase): """ Test the assignment mechanism when three chained stock moves (2 sources, 1 dest) try to move multiple units of a tracked by lot product. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product.id, 'company_id': self.env.company.id, @@ -2624,7 +2624,7 @@ class StockMove(TransactionCase): # 6 units are available in stock for i in range(1, 13): - lot_id = self.env['stock.production.lot'].create({ + lot_id = self.env['stock.lot'].create({ 'name': 'lot%s' % str(i), 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -2692,7 +2692,7 @@ class StockMove(TransactionCase): 'uom_type': 'bigger', }) for i in range(1, 4): - lot_id = self.env['stock.production.lot'].create({ + lot_id = self.env['stock.lot'].create({ 'name': 'lot%s' % str(i), 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -2751,7 +2751,7 @@ class StockMove(TransactionCase): self.assertEqual(backordered_move.reserved_availability, 0) # force the serial number and validate - lot3 = self.env['stock.production.lot'].search([('name', '=', "lot3")]) + lot3 = self.env['stock.lot'].search([('name', '=', "lot3")]) backorder.write({'move_line_ids': [(0, 0, { 'product_id': self.product_serial.id, 'product_uom_id': self.uom_unit.id, @@ -2960,7 +2960,7 @@ class StockMove(TransactionCase): """ Test that validating a stock move linked to a tracked product reserved by another one correctly unreserves the other one. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product.id, 'company_id': self.env.company.id, @@ -3145,12 +3145,12 @@ class StockMove(TransactionCase): """ Test that editing a stock move line linked to a tracked product correctly and directly adapts the reservation. In this case, we edit the lot to another available one. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product.id, 'company_id': self.env.company.id, @@ -3259,12 +3259,12 @@ class StockMove(TransactionCase): and directly adapts the reservation. In this case, we edit the lot to another available one that is not in a pack. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product.id, 'company_id': self.env.company.id, @@ -3350,7 +3350,7 @@ class StockMove(TransactionCase): Validating the stock move should should not create a negative quant for this lot in stock location. # """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, @@ -3399,12 +3399,12 @@ class StockMove(TransactionCase): that does not have any should not change its reservation, and validating should not create a negative quant for this lot in stock. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, @@ -3512,12 +3512,12 @@ class StockMove(TransactionCase): """ Test that editing a done stock move line linked to a tracked product correctly and directly adapts the transfer. In this case, we edit the lot to another available one. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product.id, 'company_id': self.env.company.id, @@ -3630,12 +3630,12 @@ class StockMove(TransactionCase): and directly adapts the transfer. In this case, we edit the lot to another available one that is not in a pack. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product.id, 'company_id': self.env.company.id, @@ -3925,12 +3925,12 @@ class StockMove(TransactionCase): adapts the transfer. In this case, we edit the lot to another one, but the original move line is not in the default product's UOM. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, @@ -3960,12 +3960,12 @@ class StockMove(TransactionCase): and directly adapts the transfer. In this case, we edit the lot to another available one that we put in the same pack. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, @@ -4174,7 +4174,7 @@ class StockMove(TransactionCase): filling any quantities should pop up the immediate transfer wizard. """ partner = self.env['res.partner'].create({'name': 'Jean'}) - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, @@ -4634,7 +4634,7 @@ class StockMove(TransactionCase): 'location_id': self.stock_location.id }) - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'serial1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -4702,12 +4702,12 @@ class StockMove(TransactionCase): correctly restores the original lot with its incoming date and remove the new lot with its incoming date. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, @@ -4811,12 +4811,12 @@ class StockMove(TransactionCase): """ Check that, when creating a move line on a done stock move, the lot and its incoming date are correctly moved to the destination location. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, @@ -5394,7 +5394,7 @@ class StockMove(TransactionCase): - Check for dupes when assigning serial number to a stock move line """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'serial1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, diff --git a/addons/stock/tests/test_move2.py b/addons/stock/tests/test_move2.py index c66e51e0c3b..375d45607da 100644 --- a/addons/stock/tests/test_move2.py +++ b/addons/stock/tests/test_move2.py @@ -336,12 +336,12 @@ class TestPickShip(TestStockCommon): Editing the lot on the move line of the first move should impact the reservation of the second one. """ self.productA.tracking = 'lot' - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.productA.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.productA.id, 'company_id': self.env.company.id, @@ -439,7 +439,7 @@ class TestPickShip(TestStockCommon): pack_location = self.env['stock.location'].browse(self.pack_location) customer_location = self.env['stock.location'].browse(self.customer_location) self.productA.tracking = 'lot' - lot = self.env['stock.production.lot'].create({ + lot = self.env['stock.lot'].create({ 'product_id': self.productA.id, 'name': '123456789', 'company_id': self.env.company.id, @@ -522,7 +522,7 @@ class TestPickShip(TestStockCommon): picking_pick, picking_pack, picking_ship = self.create_pick_pack_ship() stock_location = self.env['stock.location'].browse(self.stock_location) self.productA.tracking = 'serial' - lot = self.env['stock.production.lot'].create({ + lot = self.env['stock.lot'].create({ 'product_id': self.productA.id, 'name': '123456789', 'company_id': self.env.company.id, @@ -744,17 +744,17 @@ class TestPickShip(TestStockCommon): return of the second picking suggest the lot from the picking returned. """ self.productA.tracking = 'lot' - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.productA.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.productA.id, 'company_id': self.env.company.id, }) - lot3 = self.env['stock.production.lot'].create({ + lot3 = self.env['stock.lot'].create({ 'name': 'lot3', 'product_id': self.productA.id, 'company_id': self.env.company.id, @@ -1236,7 +1236,7 @@ class TestSinglePicking(TestStockCommon): Otherwise a new move lines with the new lot should be added. """ self.productA.tracking = 'lot' - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.productA.id, 'company_id': self.env.company.id, @@ -1289,12 +1289,12 @@ class TestSinglePicking(TestStockCommon): """ Same check than test_recheck_availability_2 but with different lots. """ self.productA.tracking = 'lot' - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.productA.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.productA.id, 'company_id': self.env.company.id, @@ -1349,12 +1349,12 @@ class TestSinglePicking(TestStockCommon): Serial number reservation should always create a new move line. """ self.productA.tracking = 'serial' - serial1 = self.env['stock.production.lot'].create({ + serial1 = self.env['stock.lot'].create({ 'name': 'serial1', 'product_id': self.productA.id, 'company_id': self.env.company.id, }) - serial2 = self.env['stock.production.lot'].create({ + serial2 = self.env['stock.lot'].create({ 'name': 'serial2', 'product_id': self.productA.id, 'company_id': self.env.company.id, @@ -1555,7 +1555,7 @@ class TestSinglePicking(TestStockCommon): # creating a lot from the view should raise with self.assertRaises(UserError): - self.env['stock.production.lot']\ + self.env['stock.lot']\ .with_context(active_picking_id=delivery_order.id)\ .create({ 'name': 'lot1', @@ -1564,7 +1564,7 @@ class TestSinglePicking(TestStockCommon): }) # enter an existing lot_id, should work - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.productA.id, 'company_id': self.env.company.id, @@ -2197,7 +2197,7 @@ class TestStockUOM(TestStockCommon): self.assertEqual(move.product_uom_qty, 60.00, 'Wrong T_GT quantity') self.assertEqual(move.product_qty, 134400.00, 'Wrong T_LBS quantity') - lot = self.env['stock.production.lot'].create({'name': 'Lot TEST', 'product_id': T_TEST.id, 'company_id': self.env.company.id, }) + lot = self.env['stock.lot'].create({'name': 'Lot TEST', 'product_id': T_TEST.id, 'company_id': self.env.company.id, }) self.env['stock.move.line'].create({ 'move_id': move.id, 'product_id': T_TEST.id, @@ -3388,17 +3388,17 @@ class TestAutoAssign(TestStockCommon): 'picking_type_id': self.env.ref('stock.picking_type_in').id, }) self.assertEqual(move.state, 'draft') - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'serial1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'serial2', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, }) - lot3 = self.env['stock.production.lot'].create({ + lot3 = self.env['stock.lot'].create({ 'name': 'serial3', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, diff --git a/addons/stock/tests/test_multicompany.py b/addons/stock/tests/test_multicompany.py index 1740852afa2..55acfdf8dd4 100644 --- a/addons/stock/tests/test_multicompany.py +++ b/addons/stock/tests/test_multicompany.py @@ -166,12 +166,12 @@ class TestMultiCompany(TransactionCase): 'tracking': 'lot', 'name': 'product lot', }) - self.env['stock.production.lot'].create({ + self.env['stock.lot'].create({ 'name': 'lotA', 'company_id': self.company_a.id, 'product_id': product_lot.id, }) - self.env['stock.production.lot'].create({ + self.env['stock.lot'].create({ 'name': 'lotA', 'company_id': self.company_b.id, 'product_id': product_lot.id, @@ -210,7 +210,7 @@ class TestMultiCompany(TransactionCase): self.assertEqual(move1.move_line_ids[0].company_id, self.company_a) picking.with_user(self.user_b).button_validate() self.assertEqual(picking.state, 'done') - created_serial = self.env['stock.production.lot'].search([ + created_serial = self.env['stock.lot'].search([ ('name', '=', 'receipt_serial') ]) self.assertEqual(created_serial.company_id, self.company_a) diff --git a/addons/stock/tests/test_packing.py b/addons/stock/tests/test_packing.py index 9944761e4b7..941ab531719 100644 --- a/addons/stock/tests/test_packing.py +++ b/addons/stock/tests/test_packing.py @@ -635,7 +635,7 @@ class TestPacking(TestPackingCommon): """ Create a simple move in a delivery. Reserve the quantity but set as quantity done only a part. Call Put In Pack button. """ self.productA.tracking = 'lot' - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'product_id': self.productA.id, 'name': '00001', 'company_id': self.warehouse.company_id.id diff --git a/addons/stock/tests/test_packing_neg.py b/addons/stock/tests/test_packing_neg.py index 0fab9dfc09e..0218cc4c815 100644 --- a/addons/stock/tests/test_packing_neg.py +++ b/addons/stock/tests/test_packing_neg.py @@ -58,7 +58,7 @@ class TestPackingNeg(TransactionCase): # Put 120 pieces on Palneg 1 (package), 120 pieces on Palneg 2 with lot A and 60 pieces on Palneg 3 # create lot A - lot_a = self.env['stock.production.lot'].create({'name': 'Lot neg', 'product_id': product_neg.id, 'company_id': self.env.company.id}) + lot_a = self.env['stock.lot'].create({'name': 'Lot neg', 'product_id': product_neg.id, 'company_id': self.env.company.id}) # create package package1 = self.env['stock.quant.package'].create({'name': 'Palneg 1'}) package2 = self.env['stock.quant.package'].create({'name': 'Palneg 2'}) @@ -168,7 +168,7 @@ class TestPackingNeg(TransactionCase): # Receive 20 products with lot neg in stock with a new incoming shipment that should be on pallet 2 delivery_reconcile.action_confirm() - lot = self.env["stock.production.lot"].search([ + lot = self.env["stock.lot"].search([ ('product_id', '=', product_neg.id), ('name', '=', 'Lot neg')], limit=1) pack = self.env["stock.quant.package"].search([('name', '=', 'Palneg 2')], limit=1) diff --git a/addons/stock/tests/test_quant.py b/addons/stock/tests/test_quant.py index cb7b8b5679e..7840ef95186 100644 --- a/addons/stock/tests/test_quant.py +++ b/addons/stock/tests/test_quant.py @@ -148,7 +148,7 @@ class StockQuant(TransactionCase): def test_get_available_quantity_7(self): """ Quantity availability with only one tracked quant in a location. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, @@ -457,7 +457,7 @@ class StockQuant(TransactionCase): self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product, pack_location), 2.0) def test_mix_tracked_untracked_1(self): - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -542,7 +542,7 @@ class StockQuant(TransactionCase): """ Check that an incoming date is correctly set when updating the quantity of a tracked quant. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -555,12 +555,12 @@ class StockQuant(TransactionCase): """ Check that the FIFO strategies correctly applies when you have multiple lot received at different times for a tracked product. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -581,12 +581,12 @@ class StockQuant(TransactionCase): """ lifo_strategy = self.env['product.removal'].search([('method', '=', 'lifo')]) self.stock_location.removal_strategy_id = lifo_strategy - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, @@ -605,7 +605,7 @@ class StockQuant(TransactionCase): """ Receive the same lot at different times, once they're in the same location, the quants are merged and only the earliest incoming date is kept. """ - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_lot.id, 'company_id': self.env.company.id, @@ -642,12 +642,12 @@ class StockQuant(TransactionCase): """ closest_strategy = self.env['product.removal'].search([('method', '=', 'closest')]) self.stock_location.removal_strategy_id = closest_strategy - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': self.product_serial.id, 'company_id': self.env.company.id, diff --git a/addons/stock/tests/test_quant_inventory_mode.py b/addons/stock/tests/test_quant_inventory_mode.py index 115a35803a4..602317c53ef 100644 --- a/addons/stock/tests/test_quant_inventory_mode.py +++ b/addons/stock/tests/test_quant_inventory_mode.py @@ -231,7 +231,7 @@ class TestEditableQuant(TransactionCase): in inventory mode. """ - sn1 = self.env['stock.production.lot'].create({ + sn1 = self.env['stock.lot'].create({ 'name': 'serial1', 'product_id': self.product_tracked_sn.id, 'company_id': self.env.company.id, diff --git a/addons/stock/tests/test_report.py b/addons/stock/tests/test_report.py index 33a5c31f640..86f1af9b17a 100644 --- a/addons/stock/tests/test_report.py +++ b/addons/stock/tests/test_report.py @@ -48,7 +48,7 @@ class TestReports(TestReportsCommon): 'tracking': 'lot', 'barcode': 'scan_me' }) - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'Volume-Beta', 'product_id': product1.id, 'company_id': self.env.company.id, diff --git a/addons/stock/tests/test_robustness.py b/addons/stock/tests/test_robustness.py index 4d67f35434f..26498de19f6 100644 --- a/addons/stock/tests/test_robustness.py +++ b/addons/stock/tests/test_robustness.py @@ -168,13 +168,13 @@ class TestRobustness(TransactionCase): 'tracking': 'lot', }) - lot1 = self.env['stock.production.lot'].create({ + lot1 = self.env['stock.lot'].create({ 'name': 'lot1', 'product_id': product1.id, 'company_id': self.env.company.id, }) - lot2 = self.env['stock.production.lot'].create({ + lot2 = self.env['stock.lot'].create({ 'name': 'lot2', 'product_id': product2.id, 'company_id': self.env.company.id, diff --git a/addons/stock/tests/test_stock_flow.py b/addons/stock/tests/test_stock_flow.py index 6cb2b1dd852..73e982c51e2 100644 --- a/addons/stock/tests/test_stock_flow.py +++ b/addons/stock/tests/test_stock_flow.py @@ -27,7 +27,7 @@ class TestStockFlow(TestStockCommon): @mute_logger('odoo.addons.base.models.ir_model', 'odoo.models') def test_00_picking_create_and_transfer_quantity(self): """ Basic stock operation on incoming and outgoing shipment. """ - LotObj = self.env['stock.production.lot'] + LotObj = self.env['stock.lot'] # ---------------------------------------------------------------------- # Create incoming shipment of product A, B, C, D # ---------------------------------------------------------------------- @@ -1075,7 +1075,7 @@ class TestStockFlow(TestStockCommon): lotproduct = self.ProductObj.create({'name': 'Lot Product', 'uom_id': self.uom_unit.id, 'uom_po_id': self.uom_unit.id, 'type': 'product'}) quant_obj = self.env['stock.quant'].with_context(inventory_mode=True) pack_obj = self.env['stock.quant.package'] - lot_obj = self.env['stock.production.lot'] + lot_obj = self.env['stock.lot'] pack1 = pack_obj.create({'name': 'PACK00TEST1'}) pack_obj.create({'name': 'PACK00TEST2'}) lot1 = lot_obj.create({'name': 'Lot001', 'product_id': lotproduct.id, 'company_id': self.env.company.id}) @@ -1968,7 +1968,7 @@ class TestStockFlow(TestStockCommon): # Validates the two receipts and checks the move lines' lot. (receipt_1 | receipt_2).button_validate() - lots = self.env['stock.production.lot'].search([('product_id', '=', product_lot.id)], order='name asc') + lots = self.env['stock.lot'].search([('product_id', '=', product_lot.id)], order='name asc') self.assertEqual(len(lots), 5) lot1, lot2, lot3, lot4, lot5 = lots self.assertEqual(lot1.name, 'lot-001') diff --git a/addons/stock/views/stock_production_lot_views.xml b/addons/stock/views/stock_lot_views.xml similarity index 96% rename from addons/stock/views/stock_production_lot_views.xml rename to addons/stock/views/stock_lot_views.xml index 5023491431e..623d79743ab 100644 --- a/addons/stock/views/stock_production_lot_views.xml +++ b/addons/stock/views/stock_lot_views.xml @@ -2,7 +2,7 @@ stock.production.lot.form - stock.production.lot + stock.lot 10
@@ -59,7 +59,7 @@ stock.production.lot.tree - stock.production.lot + stock.lot @@ -73,7 +73,7 @@ Production Lots Filter - stock.production.lot + stock.lot @@ -88,7 +88,7 @@ Lots/Serial Numbers ir.actions.act_window - stock.production.lot + stock.lot