From 9bf51c3a0853abf72c0d97c3d997403cf33780a9 Mon Sep 17 00:00:00 2001 From: Ajay Javiya Date: Tue, 17 Dec 2024 10:11:00 +0530 Subject: [PATCH] [MIG] sale_sourced_by_line: Migration to 18.0 [FIX] pylint error --- sale_sourced_by_line/README.rst | 1 + sale_sourced_by_line/__manifest__.py | 2 +- sale_sourced_by_line/model/sale.py | 18 ++++++++---------- .../tests/test_sale_sourced_by_line.py | 4 ++-- sale_sourced_by_line/view/sale_view.xml | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/sale_sourced_by_line/README.rst b/sale_sourced_by_line/README.rst index e4a8c3cb0bc..71d5c24dc70 100644 --- a/sale_sourced_by_line/README.rst +++ b/sale_sourced_by_line/README.rst @@ -47,6 +47,7 @@ Contributors * Eficent Business and IT Consulting Services S.L. * Serpent Consulting Services Pvt. Ltd. * Info A Tout Prix +* Ajay Javiya Do not contact contributors directly about support or help with technical issues. diff --git a/sale_sourced_by_line/__manifest__.py b/sale_sourced_by_line/__manifest__.py index fbb30988faa..484b72b3845 100644 --- a/sale_sourced_by_line/__manifest__.py +++ b/sale_sourced_by_line/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Sale Sourced by Line", "summary": "Multiple warehouse source locations for Sale order", - "version": "17.0.1.0.0", + "version": "18.0.1.0.0", "author": "Camptocamp," "Eficent," "SerpentCS," diff --git a/sale_sourced_by_line/model/sale.py b/sale_sourced_by_line/model/sale.py index 1609ade7351..b27b34d31dd 100644 --- a/sale_sourced_by_line/model/sale.py +++ b/sale_sourced_by_line/model/sale.py @@ -4,7 +4,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import fields, models +from odoo import api, fields, models class SaleOrder(models.Model): @@ -22,16 +22,14 @@ class SaleOrder(models.Model): class SaleOrderLine(models.Model): _inherit = "sale.order.line" - warehouse_id = fields.Many2one( - "stock.warehouse", - "Source Warehouse", - readonly=True, - related="", - help="If a source warehouse is selected, " - "it will be used to define the route. " - "Otherwise, it will get the warehouse of " - "the sale order", + @api.depends( + "route_id", "order_id.warehouse_id", "product_packaging_id", "product_id" ) + def _compute_warehouse_id(self): + """compute the warehouse for the lines only + if it has not already been set.""" + lines = self.filtered(lambda rec: not rec.warehouse_id) + return super(SaleOrderLine, lines)._compute_warehouse_id() def _prepare_procurement_group_vals(self): vals = super()._prepare_procurement_group_vals() diff --git a/sale_sourced_by_line/tests/test_sale_sourced_by_line.py b/sale_sourced_by_line/tests/test_sale_sourced_by_line.py index 9e66cd97037..fcfc516647c 100644 --- a/sale_sourced_by_line/tests/test_sale_sourced_by_line.py +++ b/sale_sourced_by_line/tests/test_sale_sourced_by_line.py @@ -51,7 +51,7 @@ def test_sales_order_multi_source(self): self.assertEqual( len(so.picking_ids), 2, - "2 delivery orders expected. Got %s instead" % len(so.picking_ids), + f"2 delivery orders expected. Got {len(so.picking_ids)} instead", ) for line in so.order_line: self.assertEqual( @@ -96,7 +96,7 @@ def test_sales_order_no_source(self): self.assertEqual( len(so.picking_ids), 1, - "1 delivery order expected. Got %s instead" % len(so.picking_ids), + f"1 delivery order expected. Got {len(so.picking_ids)} instead", ) def test_sale_order_source(self): diff --git a/sale_sourced_by_line/view/sale_view.xml b/sale_sourced_by_line/view/sale_view.xml index db10e85645e..389d301a42b 100644 --- a/sale_sourced_by_line/view/sale_view.xml +++ b/sale_sourced_by_line/view/sale_view.xml @@ -6,7 +6,7 @@