diff --git a/addons/mrp/models/stock_rule.py b/addons/mrp/models/stock_rule.py index 999bd61e178..caae0906ec8 100644 --- a/addons/mrp/models/stock_rule.py +++ b/addons/mrp/models/stock_rule.py @@ -90,7 +90,7 @@ class StockRule(models.Model): return values['bom_id'] return self.env['mrp.bom']._bom_find(product_id, picking_type=self.picking_type_id, bom_type='normal', company_id=company_id.id)[product_id] - def _prepare_mo_vals(self, product_id, product_qty, product_uom, location_id, name, origin, company_id, values, bom): + def _prepare_mo_vals(self, product_id, product_qty, product_uom, location_dest_id, name, origin, company_id, values, bom): date_planned = self._get_date_planned(product_id, company_id, values) date_deadline = values.get('date_deadline') or date_planned + relativedelta(days=company_id.manufacturing_lead) + relativedelta(days=product_id.produce_delay) return { @@ -99,8 +99,8 @@ class StockRule(models.Model): 'product_description_variants': values.get('product_description_variants'), 'product_qty': product_qty, 'product_uom_id': product_uom.id, - 'location_src_id': self.location_src_id.id or self.picking_type_id.default_location_src_id.id or location_id.id, - 'location_dest_id': location_id.id, + 'location_src_id': self.location_src_id.id or self.picking_type_id.default_location_src_id.id or location_dest_id.id, + 'location_dest_id': location_dest_id.id, 'bom_id': bom.id, 'date_deadline': date_deadline, 'date_planned_start': date_planned, diff --git a/addons/mrp/models/stock_warehouse.py b/addons/mrp/models/stock_warehouse.py index d641afeaad7..d7515fb748b 100644 --- a/addons/mrp/models/stock_warehouse.py +++ b/addons/mrp/models/stock_warehouse.py @@ -107,7 +107,7 @@ class StockWarehouse(models.Model): rules = super(StockWarehouse, self)._get_global_route_rules_values() location_src = self.manufacture_steps == 'mrp_one_step' and self.lot_stock_id or self.pbm_loc_id production_location = self._get_production_location() - location_id = self.manufacture_steps == 'pbm_sam' and self.sam_loc_id or self.lot_stock_id + location_dest_id = self.manufacture_steps == 'pbm_sam' and self.sam_loc_id or self.lot_stock_id rules.update({ 'manufacture_pull_id': { 'depends': ['manufacture_steps', 'manufacture_to_resupply'], @@ -120,8 +120,8 @@ class StockWarehouse(models.Model): }, 'update_values': { 'active': self.manufacture_to_resupply, - 'name': self._format_rulename(location_id, False, 'Production'), - 'location_id': location_id.id, + 'name': self._format_rulename(location_dest_id, False, 'Production'), + 'location_dest_id': location_dest_id.id, 'propagate_cancel': self.manufacture_steps == 'pbm_sam' }, }, @@ -133,7 +133,7 @@ class StockWarehouse(models.Model): 'action': 'pull', 'auto': 'manual', 'route_id': self._find_global_route('stock.route_warehouse0_mto', _('Make To Order')).id, - 'location_id': production_location.id, + 'location_dest_id': production_location.id, 'location_src_id': location_src.id, 'picking_type_id': self.manu_type_id.id }, @@ -151,7 +151,7 @@ class StockWarehouse(models.Model): 'auto': 'manual', 'route_id': self._find_global_route('stock.route_warehouse0_mto', _('Make To Order')).id, 'name': self._format_rulename(self.lot_stock_id, self.pbm_loc_id, 'MTO'), - 'location_id': self.pbm_loc_id.id, + 'location_dest_id': self.pbm_loc_id.id, 'location_src_id': self.lot_stock_id.id, 'picking_type_id': self.pbm_type_id.id }, @@ -174,7 +174,7 @@ class StockWarehouse(models.Model): 'auto': 'manual', 'route_id': self._find_global_route('mrp.route_warehouse0_manufacture', _('Manufacture')).id, 'name': self._format_rulename(self.sam_loc_id, self.lot_stock_id, False), - 'location_id': self.lot_stock_id.id, + 'location_dest_id': self.lot_stock_id.id, 'location_src_id': self.sam_loc_id.id, 'picking_type_id': self.sam_type_id.id }, diff --git a/addons/mrp/tests/test_procurement.py b/addons/mrp/tests/test_procurement.py index b4d205b37d5..e18e03b841c 100644 --- a/addons/mrp/tests/test_procurement.py +++ b/addons/mrp/tests/test_procurement.py @@ -135,7 +135,7 @@ class TestProcurement(TestMrpCommon): self.env['stock.location']._parent_store_compute() warehouse.reception_route_id.rule_ids.filtered( lambda p: p.location_src_id == warehouse.wh_input_stock_loc_id and - p.location_id == warehouse.wh_qc_stock_loc_id).write({ + p.location_dest_id == warehouse.wh_qc_stock_loc_id).write({ 'procure_method': 'make_to_stock' }) diff --git a/addons/mrp/tests/test_unbuild.py b/addons/mrp/tests/test_unbuild.py index 83bc9295f13..27bfb8c25b5 100644 --- a/addons/mrp/tests/test_unbuild.py +++ b/addons/mrp/tests/test_unbuild.py @@ -507,7 +507,7 @@ class TestUnbuild(TestMrpCommon): 'action': 'push', 'picking_type_id': self.ref('stock.picking_type_internal'), 'location_src_id': unbuild_location.id, - 'location_id': self.stock_location.id, + 'location_dest_id': self.stock_location.id, })], }) diff --git a/addons/mrp/tests/test_warehouse_multistep_manufacturing.py b/addons/mrp/tests/test_warehouse_multistep_manufacturing.py index 1053701864c..a7ea55dc1b8 100644 --- a/addons/mrp/tests/test_warehouse_multistep_manufacturing.py +++ b/addons/mrp/tests/test_warehouse_multistep_manufacturing.py @@ -70,7 +70,7 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon): self._check_location_and_routes() # Check locations of existing pull rule self.assertFalse(self.warehouse.pbm_route_id.rule_ids, 'only the update of global manufacture route should happen.') - self.assertEqual(self.warehouse.manufacture_pull_id.location_id.id, self.warehouse.lot_stock_id.id) + self.assertEqual(self.warehouse.manufacture_pull_id.location_dest_id.id, self.warehouse.lot_stock_id.id) def test_01_warehouse_twostep_manufacturing(self): """ Warehouse testing for picking before manufacturing """ @@ -78,7 +78,7 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon): warehouse.manufacture_steps = 'pbm' self._check_location_and_routes() self.assertEqual(len(self.warehouse.pbm_route_id.rule_ids), 2) - self.assertEqual(self.warehouse.manufacture_pull_id.location_id.id, self.warehouse.lot_stock_id.id) + self.assertEqual(self.warehouse.manufacture_pull_id.location_dest_id.id, self.warehouse.lot_stock_id.id) def test_02_warehouse_twostep_manufacturing(self): """ Warehouse testing for picking ans store after manufacturing """ @@ -86,7 +86,7 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon): warehouse.manufacture_steps = 'pbm_sam' self._check_location_and_routes() self.assertEqual(len(self.warehouse.pbm_route_id.rule_ids), 3) - self.assertEqual(self.warehouse.manufacture_pull_id.location_id.id, self.warehouse.sam_loc_id.id) + self.assertEqual(self.warehouse.manufacture_pull_id.location_dest_id.id, self.warehouse.sam_loc_id.id) def test_manufacturing_3_steps(self): """ Test MO/picking before manufacturing/picking after manufacturing diff --git a/addons/mrp_subcontracting/models/stock_warehouse.py b/addons/mrp_subcontracting/models/stock_warehouse.py index be3ba44c109..9c9d9b5c5eb 100644 --- a/addons/mrp_subcontracting/models/stock_warehouse.py +++ b/addons/mrp_subcontracting/models/stock_warehouse.py @@ -75,7 +75,7 @@ class StockWarehouse(models.Model): 'auto': 'manual', 'route_id': self._find_global_route('stock.route_warehouse0_mto', _('Make To Order')).id, 'name': self._format_rulename(self.lot_stock_id, subcontract_location_id, 'MTO'), - 'location_id': subcontract_location_id.id, + 'location_dest_id': subcontract_location_id.id, 'location_src_id': self.lot_stock_id.id, 'picking_type_id': self.subcontracting_resupply_type_id.id }, @@ -93,7 +93,7 @@ class StockWarehouse(models.Model): 'route_id': self._find_global_route('mrp_subcontracting.route_resupply_subcontractor_mto', _('Resupply Subcontractor on Order')).id, 'name': self._format_rulename(self.lot_stock_id, subcontract_location_id, False), - 'location_id': production_location_id.id, + 'location_dest_id': production_location_id.id, 'location_src_id': subcontract_location_id.id, 'picking_type_id': self.subcontracting_resupply_type_id.id }, diff --git a/addons/mrp_subcontracting/tests/test_subcontracting.py b/addons/mrp_subcontracting/tests/test_subcontracting.py index 035e77b6d3b..3ebbf60405c 100644 --- a/addons/mrp_subcontracting/tests/test_subcontracting.py +++ b/addons/mrp_subcontracting/tests/test_subcontracting.py @@ -105,14 +105,14 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon): 'company_id': self.env.company.id, }) self.subcontractor_partner1.property_stock_subcontractor = partner_subcontract_location.id - resupply_rule = resupply_sub_on_order_route.rule_ids.filtered(lambda l: - l.location_id == self.comp1.property_stock_production and - l.location_src_id == self.env.company.subcontracting_location_id) + resupply_rule = resupply_sub_on_order_route.rule_ids.filtered(lambda r: + r.location_dest_id == self.comp1.property_stock_production and + r.location_src_id == self.env.company.subcontracting_location_id) resupply_rule.copy({'location_src_id': partner_subcontract_location.id}) - resupply_warehouse_rule = self.warehouse.route_ids.rule_ids.filtered(lambda l: - l.location_id == self.env.company.subcontracting_location_id and - l.location_src_id == self.warehouse.lot_stock_id) - resupply_warehouse_rule.copy({'location_id': partner_subcontract_location.id}) + resupply_warehouse_rule = self.warehouse.route_ids.rule_ids.filtered(lambda r: + r.location_dest_id == self.env.company.subcontracting_location_id and + r.location_src_id == self.warehouse.lot_stock_id) + resupply_warehouse_rule.copy({'location_dest_id': partner_subcontract_location.id}) # Add a manufacturing lead time to check that the resupply delivery is correctly planned 2 days # before the subcontracting receipt self.finished.produce_delay = 2 diff --git a/addons/mrp_subcontracting_dropshipping/models/res_company.py b/addons/mrp_subcontracting_dropshipping/models/res_company.py index b1cddbd7975..9f863526066 100644 --- a/addons/mrp_subcontracting_dropshipping/models/res_company.py +++ b/addons/mrp_subcontracting_dropshipping/models/res_company.py @@ -22,7 +22,7 @@ class ResCompany(models.Model): vals.append({ 'name': '%s → %s' % (supplier_location.name, subcontracting_location.name), 'action': 'buy', - 'location_id': subcontracting_location.id, + 'location_dest_id': subcontracting_location.id, 'location_src_id': supplier_location.id, 'procure_method': 'make_to_stock', 'route_id': route.id, diff --git a/addons/mrp_subcontracting_dropshipping/models/stock_rule.py b/addons/mrp_subcontracting_dropshipping/models/stock_rule.py index 505930317c9..44bf11fb9fd 100644 --- a/addons/mrp_subcontracting_dropshipping/models/stock_rule.py +++ b/addons/mrp_subcontracting_dropshipping/models/stock_rule.py @@ -8,6 +8,6 @@ class StockRule(models.Model): _inherit = 'stock.rule' def _prepare_purchase_order(self, company_id, origins, values): - if 'partner_id' not in values[0] and self.location_id.id == company_id.subcontracting_location_id.id: + if 'partner_id' not in values[0] and self.location_dest_id.id == company_id.subcontracting_location_id.id: values[0]['partner_id'] = values[0]['group_id'].partner_id.id return super()._prepare_purchase_order(company_id, origins, values) diff --git a/addons/mrp_subcontracting_dropshipping/models/stock_warehouse.py b/addons/mrp_subcontracting_dropshipping/models/stock_warehouse.py index c85e5dd3ca7..8b193aa5eea 100644 --- a/addons/mrp_subcontracting_dropshipping/models/stock_warehouse.py +++ b/addons/mrp_subcontracting_dropshipping/models/stock_warehouse.py @@ -30,7 +30,7 @@ class StockWarehouse(models.Model): 'route_id': self._find_global_route('mrp_subcontracting_dropshipping.route_subcontracting_dropshipping', _('Dropship Subcontractor on Order')).id, 'name': self._format_rulename(subcontract_location_id, production_location_id, False), - 'location_id': production_location_id.id, + 'location_dest_id': production_location_id.id, 'location_src_id': subcontract_location_id.id, 'picking_type_id': self.subcontracting_type_id.id }, diff --git a/addons/purchase_stock/models/stock.py b/addons/purchase_stock/models/stock.py index 4ab6461def9..4a75d32fe7d 100644 --- a/addons/purchase_stock/models/stock.py +++ b/addons/purchase_stock/models/stock.py @@ -135,7 +135,7 @@ class StockWarehouse(models.Model): 'update_values': { 'active': self.buy_to_resupply, 'name': self._format_rulename(location_id, False, 'Buy'), - 'location_id': location_id.id, + 'location_dest_id': location_id.id, 'propagate_cancel': self.reception_steps != 'one_step', } } diff --git a/addons/purchase_stock/tests/test_reordering_rule.py b/addons/purchase_stock/tests/test_reordering_rule.py index e73ffe441c4..4af764055b0 100644 --- a/addons/purchase_stock/tests/test_reordering_rule.py +++ b/addons/purchase_stock/tests/test_reordering_rule.py @@ -184,7 +184,7 @@ class TestReorderingRule(TransactionCase): 'rule_ids': [ (0, False, { 'name': 'Buy', - 'location_id': warehouse_1.lot_stock_id.id, + 'location_dest_id': warehouse_1.lot_stock_id.id, 'company_id': self.env.company.id, 'action': 'buy', 'sequence': 2, @@ -194,7 +194,7 @@ class TestReorderingRule(TransactionCase): (0, False, { 'name': 'ressuply from stock', 'location_src_id': warehouse_1.lot_stock_id.id, - 'location_id': outside_loc.id, + 'location_dest_id': outside_loc.id, 'company_id': self.env.company.id, 'action': 'pull', 'procure_method': 'mts_else_mto', @@ -547,7 +547,7 @@ class TestReorderingRule(TransactionCase): mto_rule = self.env['stock.rule'].search( [('warehouse_id', '=', warehouse.id), ('procure_method', '=', 'mts_else_mto'), - ('location_id', '=', customer_loc.id) + ('location_dest_id', '=', customer_loc.id) ] ) route_mto = self.env["stock.route"].create({ diff --git a/addons/sale_mrp/tests/test_sale_mrp_flow.py b/addons/sale_mrp/tests/test_sale_mrp_flow.py index 727d9ba9b61..75821e33512 100644 --- a/addons/sale_mrp/tests/test_sale_mrp_flow.py +++ b/addons/sale_mrp/tests/test_sale_mrp_flow.py @@ -1372,7 +1372,7 @@ class TestSaleMrpFlow(ValuationReconciliationTestCommon): 'action': 'pull', 'picking_type_id': self.company_data['default_warehouse'].in_type_id.id, 'location_src_id': stock_location_components.id, - 'location_id': self.ref('stock.stock_location_customers'), + 'location_dest_id': self.ref('stock.stock_location_customers'), })], }) @@ -1384,7 +1384,7 @@ class TestSaleMrpFlow(ValuationReconciliationTestCommon): 'action': 'pull', 'picking_type_id': self.company_data['default_warehouse'].in_type_id.id, 'location_src_id': stock_location_14.id, - 'location_id': self.ref('stock.stock_location_customers'), + 'location_dest_id': self.ref('stock.stock_location_customers'), })], }) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 688cc0db2b3..69280fbee88 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -787,7 +787,7 @@ class StockMove(models.Model): else: rule = self.sudo().env['procurement.group']._search_rule(move.route_ids, move.product_packaging_id, move.product_id, warehouse_id, domain) # Make sure it is not returning the return - if rule and (not move.origin_returned_move_id or move.origin_returned_move_id.location_dest_id.id != rule.location_id.id): + if rule and (not move.origin_returned_move_id or move.origin_returned_move_id.location_dest_id.id != rule.location_dest_id.id): new_move = rule._run_push(move) if new_move: new_moves.append(new_move) @@ -1867,7 +1867,7 @@ class StockMove(models.Model): product_id = move.product_id domain = [ ('location_src_id', '=', move.location_id.id), - ('location_id', '=', move.location_dest_id.id), + ('location_dest_id', '=', move.location_dest_id.id), ('action', '!=', 'push') ] rules = self.env['procurement.group']._search_rule(False, move.product_packaging_id, product_id, move.warehouse_id, domain) diff --git a/addons/stock/models/stock_orderpoint.py b/addons/stock/models/stock_orderpoint.py index e973a4504f8..68debf702dc 100644 --- a/addons/stock/models/stock_orderpoint.py +++ b/addons/stock/models/stock_orderpoint.py @@ -279,13 +279,13 @@ class StockWarehouseOrderpoint(models.Model): self = self.filtered(lambda o: not o.route_id) rules_groups = self.env['stock.rule'].read_group([ ('route_id.product_selectable', '!=', False), - ('location_id', 'in', self.location_id.ids), + ('location_dest_id', 'in', self.location_id.ids), ('action', 'in', ['pull_push', 'pull']) - ], ['location_id', 'route_id'], ['location_id', 'route_id'], lazy=False) + ], ['location_dest_id', 'route_id'], ['location_dest_id', 'route_id'], lazy=False) for g in rules_groups: if not g.get('route_id'): continue - orderpoints = self.filtered(lambda o: o.location_id.id == g['location_id'][0]) + orderpoints = self.filtered(lambda o: o.location_id.id == g['location_dest_id'][0]) orderpoints.route_id = g['route_id'] def _get_lead_days_values(self): diff --git a/addons/stock/models/stock_rule.py b/addons/stock/models/stock_rule.py index 83195e056fa..a58e4b6c9c3 100644 --- a/addons/stock/models/stock_rule.py +++ b/addons/stock/models/stock_rule.py @@ -59,7 +59,7 @@ class StockRule(models.Model): company_id = fields.Many2one('res.company', 'Company', default=lambda self: self.env.company, domain="[('id', '=?', route_company_id)]") - location_id = fields.Many2one('stock.location', 'Destination Location', required=True, check_company=True) + location_dest_id = fields.Many2one('stock.location', 'Destination Location', required=True, check_company=True) location_src_id = fields.Many2one('stock.location', 'Source Location', check_company=True) route_id = fields.Many2one('stock.route', 'Route', required=True, ondelete='cascade') route_company_id = fields.Many2one(related='route_id.company_id', string='Route Company') @@ -107,7 +107,7 @@ class StockRule(models.Model): Enable the delay alert if the picking type is a delivery """ self.location_src_id = self.picking_type_id.default_location_src_id.id - self.location_id = self.picking_type_id.default_location_dest_id.id + self.location_dest_id = self.picking_type_id.default_location_dest_id.id @api.onchange('route_id', 'company_id') def _onchange_route(self): @@ -123,7 +123,7 @@ class StockRule(models.Model): _get_message_dict functions since it often requires those data. """ source = self.location_src_id and self.location_src_id.display_name or _('Source Location') - destination = self.location_id and self.location_id.display_name or _('Destination Location') + destination = self.location_dest_id and self.location_dest_id.display_name or _('Destination Location') operation = self.picking_type_id and self.picking_type_id.name or _('Operation Type') return source, destination, operation @@ -147,7 +147,7 @@ class StockRule(models.Model): } return message_dict - @api.depends('action', 'location_id', 'location_src_id', 'picking_type_id', 'procure_method') + @api.depends('action', 'location_dest_id', 'location_src_id', 'picking_type_id', 'procure_method') def _compute_action_message(self): """ Generate dynamicaly a message that describe the rule purpose to the end user. @@ -178,13 +178,13 @@ class StockRule(models.Model): new_date = fields.Datetime.to_string(move.date + relativedelta(days=self.delay)) if self.auto == 'transparent': old_dest_location = move.location_dest_id - move.write({'date': new_date, 'location_dest_id': self.location_id.id}) + move.write({'date': new_date, 'location_dest_id': self.location_dest_id.id}) # make sure the location_dest_id is consistent with the move line location dest if move.move_line_ids: move.move_line_ids.location_dest_id = move.location_dest_id._get_putaway_strategy(move.product_id) or move.location_dest_id # avoid looping if a push rule is not well configured; otherwise call again push_apply to see if a next step is defined - if self.location_id != old_dest_location: + if self.location_dest_id != old_dest_location: # TDE FIXME: should probably be done in the move model IMO return move._push_apply()[:1] else: @@ -203,7 +203,7 @@ class StockRule(models.Model): new_move_vals = { 'origin': move_to_copy.origin or move_to_copy.picking_id.name or "/", 'location_id': move_to_copy.location_dest_id.id, - 'location_dest_id': self.location_id.id, + 'location_dest_id': self.location_dest_id.id, 'date': new_date, 'company_id': company_id, 'picking_id': False, @@ -270,7 +270,7 @@ class StockRule(models.Model): """ return [] - def _get_stock_move_values(self, product_id, product_qty, product_uom, location_id, name, origin, company_id, values): + def _get_stock_move_values(self, product_id, product_qty, product_uom, location_dest_id, name, origin, company_id, values): ''' Returns a dictionary of values that will be used to create a stock move from a procurement. This function assumes that the given procurement has a rule (action == 'pull' or 'pull_push') set on it. @@ -298,13 +298,13 @@ class StockRule(models.Model): qty_left = product_qty move_dest_ids = [] - if not self.location_id.should_bypass_reservation(): + if not self.location_dest_id.should_bypass_reservation(): move_dest_ids = values.get('move_dest_ids', False) and [(4, x.id) for x in values['move_dest_ids']] or [] # when create chained moves for inter-warehouse transfers, set the warehouses as partners if not partner and move_dest_ids: move_dest = values['move_dest_ids'] - if location_id == company_id.internal_transit_location_id: + if location_dest_id == company_id.internal_transit_location_id: partners = move_dest.location_dest_id.warehouse_id.partner_id if len(partners) == 1: partner = partners @@ -312,13 +312,13 @@ class StockRule(models.Model): move_values = { 'name': name[:2000], - 'company_id': self.company_id.id or self.location_src_id.company_id.id or self.location_id.company_id.id or company_id.id, + 'company_id': self.company_id.id or self.location_src_id.company_id.id or self.location_dest_id.company_id.id or company_id.id, 'product_id': product_id.id, 'product_uom': product_uom.id, 'product_uom_qty': qty_left, 'partner_id': partner.id if partner else False, 'location_id': self.location_src_id.id, - 'location_dest_id': location_id.id, + 'location_dest_id': location_dest_id.id, 'move_dest_ids': move_dest_ids, 'rule_id': self.id, 'procure_method': self.procure_method, @@ -502,7 +502,7 @@ class ProcurementGroup(models.Model): @api.model def _get_rule_domain(self, location, values): - domain = ['&', ('location_id', '=', location.id), ('action', '!=', 'push')] + domain = ['&', ('location_dest_id', '=', location.id), ('action', '!=', 'push')] # In case the method is called by the superuser, we need to restrict the rules to the # ones of the company. This is not useful as a regular user since there is a record # rule to filter out the rules based on the company. diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py index b35cc866967..206dd34271e 100644 --- a/addons/stock/models/stock_warehouse.py +++ b/addons/stock/models/stock_warehouse.py @@ -395,7 +395,7 @@ class Warehouse(models.Model): }, 'update_values': { 'name': self._format_rulename(location_id, location_dest_id, 'MTO'), - 'location_id': location_dest_id.id, + 'location_dest_id': location_dest_id.id, 'location_src_id': location_id.id, 'picking_type_id': picking_type_id.id, } @@ -571,7 +571,7 @@ class Warehouse(models.Model): existing_rule = self.env['stock.rule'].search([ ('picking_type_id', '=', rule_vals['picking_type_id']), ('location_src_id', '=', rule_vals['location_src_id']), - ('location_id', '=', rule_vals['location_id']), + ('location_dest_id', '=', rule_vals['location_dest_id']), ('route_id', '=', rule_vals['route_id']), ('action', '=', rule_vals['action']), ('active', '=', False), @@ -774,7 +774,7 @@ class Warehouse(models.Model): route_rule_values = { 'name': self._format_rulename(routing.from_loc, routing.dest_loc, name_suffix), 'location_src_id': routing.from_loc.id, - 'location_id': routing.dest_loc.id, + 'location_dest_id': routing.dest_loc.id, 'action': routing.action, 'auto': 'manual', 'picking_type_id': routing.picking_type.id, @@ -822,13 +822,13 @@ class Warehouse(models.Model): Check routes being delivery bu this warehouse and change the rule going to transit location """ Rule = self.env["stock.rule"] routes = self.env['stock.route'].search([('supplier_wh_id', '=', self.id)]) - rules = Rule.search(['&', '&', ('route_id', 'in', routes.ids), ('action', '!=', 'push'), ('location_id.usage', '=', 'transit')]) + rules = Rule.search(['&', '&', ('route_id', 'in', routes.ids), ('action', '!=', 'push'), ('location_dest_id.usage', '=', 'transit')]) rules.write({ 'location_src_id': new_location.id, 'procure_method': change_to_multiple and "make_to_order" or "make_to_stock"}) if not change_to_multiple: # If single delivery we should create the necessary MTO rules for the resupply - routings = [self.Routing(self.lot_stock_id, location, self.out_type_id, 'pull') for location in rules.mapped('location_id')] + routings = [self.Routing(self.lot_stock_id, location, self.out_type_id, 'pull') for location in rules.location_dest_id] mto_vals = self._get_global_route_rules_values().get('mto_pull_id') values = mto_vals['create_values'] mto_rule_vals = self._get_rule_values(routings, values, name_suffix='MTO') @@ -839,7 +839,7 @@ class Warehouse(models.Model): # We need to delete all the MTO stock rules, otherwise they risk to be used in the system Rule.search([ '&', ('route_id', '=', self._find_global_route('stock.route_warehouse0_mto', _('Make To Order')).id), - ('location_id.usage', '=', 'transit'), + ('location_dest_id.usage', '=', 'transit'), ('action', '!=', 'push'), ('location_src_id', '=', self.lot_stock_id.id)]).write({'active': False}) @@ -853,7 +853,7 @@ class Warehouse(models.Model): '&', ('action', '!=', 'push'), ('location_src_id.usage', '=', 'transit') - ]).write({'location_id': new_location.id}) + ]).write({'location_dest_id': new_location.id}) def _update_name_and_code(self, new_name=False, new_code=False): if new_code: diff --git a/addons/stock/report/report_stock_rule.py b/addons/stock/report/report_stock_rule.py index 76b73f16999..283b8fcad81 100644 --- a/addons/stock/report/report_stock_rule.py +++ b/addons/stock/report/report_stock_rule.py @@ -86,7 +86,7 @@ class ReportStockRule(models.AbstractModel): @api.model def _get_rule_loc(self, rule, product): rule.ensure_one() - return {'rule': rule, 'source': rule.location_src_id, 'destination': rule.location_id} + return {'rule': rule, 'source': rule.location_src_id, 'destination': rule.location_dest_id} @api.model def _sort_locations(self, rules_and_loc, warehouses): diff --git a/addons/stock/tests/test_move2.py b/addons/stock/tests/test_move2.py index 83667ec7bc1..0a313824726 100644 --- a/addons/stock/tests/test_move2.py +++ b/addons/stock/tests/test_move2.py @@ -2433,8 +2433,8 @@ class TestRoutes(TestStockCommon): 'group_id': procurement_group0.id, }) - ship_location = pick_rule.location_id - customer_location = push_rule.location_id + ship_location = pick_rule.location_dest_id + customer_location = push_rule.location_dest_id partners = self.env['res.partner'].search([], limit=2) partner0 = partners[0] partner1 = partners[1] @@ -2530,7 +2530,7 @@ class TestRoutes(TestStockCommon): 'rule_ids': [(0, False, { 'name': 'create a move to push location', 'location_src_id': stock_location.id, - 'location_id': push_location.id, + 'location_dest_id': push_location.id, 'company_id': self.env.company.id, 'action': 'push', 'auto': 'manual', @@ -2575,7 +2575,7 @@ class TestRoutes(TestStockCommon): 'rule_ids': [(0, False, { 'name': 'create a move to push location', 'location_src_id': self.env.ref('stock.stock_location_stock').id, - 'location_id': new_loc.id, + 'location_dest_id': new_loc.id, 'company_id': self.env.company.id, 'action': 'push', 'auto': 'transparent', @@ -3075,7 +3075,7 @@ class TestRoutes(TestStockCommon): 'rule_ids': [(0, False, { 'name': 'create a move to push location 1', 'location_src_id': stock_location.id, - 'location_id': push_location_1.id, + 'location_dest_id': push_location_1.id, 'company_id': self.env.company.id, 'action': 'push', 'auto': 'manual', @@ -3089,7 +3089,7 @@ class TestRoutes(TestStockCommon): 'rule_ids': [(0, False, { 'name': 'create a move to push location 2', 'location_src_id': stock_location.id, - 'location_id': push_location_2.id, + 'location_dest_id': push_location_2.id, 'company_id': self.env.company.id, 'action': 'push', 'auto': 'manual', diff --git a/addons/stock/tests/test_multicompany.py b/addons/stock/tests/test_multicompany.py index 79dcd376dd9..5caa29e28b1 100644 --- a/addons/stock/tests/test_multicompany.py +++ b/addons/stock/tests/test_multicompany.py @@ -410,7 +410,7 @@ class TestMultiCompany(TransactionCase): 'name': 'create a move to company b', 'company_id': self.company_b.id, 'location_src_id': intercom_location.id, - 'location_id': self.stock_location_b.id, + 'location_dest_id': self.stock_location_b.id, 'action': 'push', 'auto': 'manual', 'picking_type_id': self.warehouse_b.in_type_id.id, diff --git a/addons/stock/tests/test_proc_rule.py b/addons/stock/tests/test_proc_rule.py index 685265d48be..506e8bdddc4 100644 --- a/addons/stock/tests/test_proc_rule.py +++ b/addons/stock/tests/test_proc_rule.py @@ -31,7 +31,7 @@ class TestProcRule(TransactionCase): 'action': 'pull', 'picking_type_id': self.ref('stock.picking_type_internal'), 'location_src_id': self.ref('stock.stock_location_stock'), - 'location_id': self.ref('stock.stock_location_output'), + 'location_dest_id': self.ref('stock.stock_location_output'), })], }) @@ -121,7 +121,7 @@ class TestProcRule(TransactionCase): # get auto-created pull rule from when warehouse is created rule = self.env['stock.rule'].search([ ('route_id', '=', warehouse.reception_route_id.id), - ('location_id', '=', warehouse.lot_stock_id.id), + ('location_dest_id', '=', warehouse.lot_stock_id.id), ('location_src_id', '=', self.env.ref('stock.stock_location_suppliers').id), ('action', '=', 'pull'), ('procure_method', '=', 'make_to_stock'), @@ -185,7 +185,7 @@ class TestProcRule(TransactionCase): self.env['stock.rule'].create({ 'name': 'Rule Supplier', 'route_id': warehouse.reception_route_id.id, - 'location_id': warehouse.lot_stock_id.id, + 'location_dest_id': warehouse.lot_stock_id.id, 'location_src_id': self.env.ref('stock.stock_location_suppliers').id, 'action': 'pull', 'delay': 9.0, @@ -266,7 +266,7 @@ class TestProcRule(TransactionCase): 'action': 'pull', 'picking_type_id': self.ref('stock.picking_type_internal'), 'location_src_id': self.ref('stock.stock_location_stock'), - 'location_id': self.ref('stock.stock_location_output'), + 'location_dest_id': self.ref('stock.stock_location_output'), 'group_propagation_option': 'fixed', 'group_id': wave_pg.id, })], @@ -364,7 +364,7 @@ class TestProcRuleLoad(TransactionCase): self.env['stock.rule'].create({ 'name': 'Rule Shelf1', 'route_id': warehouse.reception_route_id.id, - 'location_id': shelf1.id, + 'location_dest_id': shelf1.id, 'location_src_id': stock_loc.id, 'action': 'pull', 'procure_method': 'make_to_order', @@ -373,7 +373,7 @@ class TestProcRuleLoad(TransactionCase): self.env['stock.rule'].create({ 'name': 'Rule Shelf2', 'route_id': warehouse.reception_route_id.id, - 'location_id': shelf2.id, + 'location_dest_id': shelf2.id, 'location_src_id': stock_loc.id, 'action': 'pull', 'procure_method': 'make_to_order', @@ -382,7 +382,7 @@ class TestProcRuleLoad(TransactionCase): self.env['stock.rule'].create({ 'name': 'Rule Supplier', 'route_id': warehouse.reception_route_id.id, - 'location_id': warehouse.wh_input_stock_loc_id.id, + 'location_dest_id': warehouse.wh_input_stock_loc_id.id, 'location_src_id': supplier_loc.id, 'action': 'pull', 'procure_method': 'make_to_stock', @@ -395,7 +395,7 @@ class TestProcRuleLoad(TransactionCase): self.env['stock.rule'].create({ 'name': 'Trap Rule', 'route_id': wrong_route.id, - 'location_id': warehouse.wh_input_stock_loc_id.id, + 'location_dest_id': warehouse.wh_input_stock_loc_id.id, 'location_src_id': supplier_loc.id, 'action': 'pull', 'procure_method': 'make_to_order', diff --git a/addons/stock/tests/test_report_stock_quantity.py b/addons/stock/tests/test_report_stock_quantity.py index 4fd0a0bf513..b3d78e734bf 100644 --- a/addons/stock/tests/test_report_stock_quantity.py +++ b/addons/stock/tests/test_report_stock_quantity.py @@ -129,7 +129,7 @@ class TestReportStockQuantity(tests.TransactionCase): self.env['stock.rule'].create({ 'name': 'Rule Supplier', 'route_id': self.wh.reception_route_id.id, - 'location_id': self.wh.lot_stock_id.id, + 'location_dest_id': self.wh.lot_stock_id.id, 'location_src_id': self.env.ref('stock.stock_location_suppliers').id, 'action': 'pull', 'delay': 1.0, diff --git a/addons/stock/tests/test_stock_flow.py b/addons/stock/tests/test_stock_flow.py index 6aa0f826f57..9c82675783d 100644 --- a/addons/stock/tests/test_stock_flow.py +++ b/addons/stock/tests/test_stock_flow.py @@ -1723,7 +1723,7 @@ class TestStockFlow(TestStockCommon): rule.name = 'From InterCompany to Company 2' rule.action = 'pull' rule.picking_type_id = warehouse_company_2.out_type_id - rule.location_id = self.env.ref('stock.stock_location_inter_wh') + rule.location_dest_id = self.env.ref('stock.stock_location_inter_wh') rule.procure_method = 'make_to_stock' route_b = f.save() @@ -1788,7 +1788,7 @@ class TestStockFlow(TestStockCommon): rule.name = 'From InterCompany to Company 2' rule.action = 'pull' rule.picking_type_id = warehouse_company_2.out_type_id - rule.location_id = self.env.ref('stock.stock_location_inter_wh') + rule.location_dest_id = self.env.ref('stock.stock_location_inter_wh') rule.procure_method = 'make_to_stock' route_b = f.save() @@ -1804,7 +1804,7 @@ class TestStockFlow(TestStockCommon): rule.name = 'From InterCompany to Company 3' rule.action = 'pull' rule.picking_type_id = warehouse_company_3.out_type_id - rule.location_id = self.env.ref('stock.stock_location_inter_wh') + rule.location_dest_id = self.env.ref('stock.stock_location_inter_wh') rule.procure_method = 'make_to_stock' route_c = f.save() diff --git a/addons/stock/views/stock_location_views.xml b/addons/stock/views/stock_location_views.xml index 275b230d9b6..9aca420fe38 100644 --- a/addons/stock/views/stock_location_views.xml +++ b/addons/stock/views/stock_location_views.xml @@ -222,7 +222,7 @@ - + diff --git a/addons/stock/views/stock_rule_views.xml b/addons/stock/views/stock_rule_views.xml index 0c52ef8daed..4bd53ad38ea 100644 --- a/addons/stock/views/stock_rule_views.xml +++ b/addons/stock/views/stock_rule_views.xml @@ -48,7 +48,7 @@ - + @@ -73,7 +73,7 @@ - + diff --git a/addons/stock_dropshipping/models/res_company.py b/addons/stock_dropshipping/models/res_company.py index 5e6e3e092d6..aaafae71fa3 100644 --- a/addons/stock_dropshipping/models/res_company.py +++ b/addons/stock_dropshipping/models/res_company.py @@ -94,7 +94,7 @@ class ResCompany(models.Model): dropship_vals.append({ 'name': '%s → %s' % (supplier_location.name, customer_location.name), 'action': 'buy', - 'location_id': customer_location.id, + 'location_dest_id': customer_location.id, 'location_src_id': supplier_location.id, 'procure_method': 'make_to_stock', 'route_id': dropship_route.id, diff --git a/addons/stock_dropshipping/models/stock.py b/addons/stock_dropshipping/models/stock.py index 3bd0622aff8..951289b436f 100644 --- a/addons/stock_dropshipping/models/stock.py +++ b/addons/stock_dropshipping/models/stock.py @@ -21,7 +21,7 @@ class ProcurementGroup(models.Model): @api.model def _get_rule_domain(self, location, values): if 'sale_line_id' in values and values.get('company_id'): - return [('location_id', '=', location.id), ('action', '!=', 'push'), ('company_id', '=', values['company_id'].id)] + return [('location_dest_id', '=', location.id), ('action', '!=', 'push'), ('company_id', '=', values['company_id'].id)] else: return super(ProcurementGroup, self)._get_rule_domain(location, values)