From feb336a2034acc469fae188eb8e00fcc44503214 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Thu, 11 Oct 2018 13:21:39 +0000 Subject: [PATCH 1/7] [REF] stock: remove unused location usage The stock location usage 'procurement' is not used anymore in stock, and we remove it as it is not used either for the stock and valuation of stock. TASK-ID: 38469 --- addons/stock/data/stock_data.xml | 6 ------ addons/stock/models/product.py | 5 ----- addons/stock/models/stock_location.py | 2 -- 3 files changed, 13 deletions(-) diff --git a/addons/stock/data/stock_data.xml b/addons/stock/data/stock_data.xml index fecb80d8145..d522f76d9c6 100644 --- a/addons/stock/data/stock_data.xml +++ b/addons/stock/data/stock_data.xml @@ -32,12 +32,6 @@ - - Procurements - - procurement - - Vendors diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 2f16867a42c..ed3f845883b 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -338,11 +338,6 @@ class Product(models.Model): res['fields']['virtual_available']['string'] = _('Future P&L') if fields.get('qty_available'): res['fields']['qty_available']['string'] = _('P&L Qty') - elif location.usage == 'procurement': - if fields.get('virtual_available'): - res['fields']['virtual_available']['string'] = _('Future Qty') - if fields.get('qty_available'): - res['fields']['qty_available']['string'] = _('Unplanned Qty') elif location.usage == 'production': if fields.get('virtual_available'): res['fields']['virtual_available']['string'] = _('Future Productions') diff --git a/addons/stock/models/stock_location.py b/addons/stock/models/stock_location.py index 6accdc3b01e..5c661392fd3 100644 --- a/addons/stock/models/stock_location.py +++ b/addons/stock/models/stock_location.py @@ -33,7 +33,6 @@ class Location(models.Model): ('internal', 'Internal Location'), ('customer', 'Customer Location'), ('inventory', 'Inventory Loss'), - ('procurement', 'Procurement'), ('production', 'Production'), ('transit', 'Transit Location')], string='Location Type', default='internal', index=True, required=True, @@ -42,7 +41,6 @@ class Location(models.Model): "\n* Internal Location: Physical locations inside your own warehouses," "\n* Customer Location: Virtual location representing the destination location for products sent to your customers" "\n* Inventory Loss: Virtual location serving as counterpart for inventory operations used to correct stock levels (Physical inventories)" - "\n* Procurement: Virtual location serving as temporary counterpart for procurement operations when the source (vendor or production) is not known yet. This location should be empty when the procurement scheduler has finished running." "\n* Production: Virtual counterpart location for production operations: this location consumes the raw material and produces finished products" "\n* Transit Location: Counterpart location that should be used in inter-company or inter-warehouses operations") location_id = fields.Many2one( From 2062ac6dec37841d23d2b5d8475305546a6f0df9 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Thu, 11 Oct 2018 13:31:16 +0000 Subject: [PATCH 2/7] [REF] stock: remove unsused field partner_id The field partner_id on locations is not used in odoo, and can create some confusion in odoo with the customer/supplier location you can set on your partner and/or the owner_id you can set on your moves ans quants. So we removed it. TASK-ID: 38469 --- addons/stock/models/stock_location.py | 1 - addons/stock/views/stock_location_views.xml | 1 - 2 files changed, 2 deletions(-) diff --git a/addons/stock/models/stock_location.py b/addons/stock/models/stock_location.py index 5c661392fd3..6e48f4283e5 100644 --- a/addons/stock/models/stock_location.py +++ b/addons/stock/models/stock_location.py @@ -47,7 +47,6 @@ class Location(models.Model): 'stock.location', 'Parent Location', index=True, ondelete='cascade', help="The parent location that includes this location. Example : The 'Dispatch Zone' is the 'Gate 1' parent location.") child_ids = fields.One2many('stock.location', 'location_id', 'Contains') - partner_id = fields.Many2one('res.partner', 'Owner', help="Owner of the location if not internal") comment = fields.Text('Additional Information') posx = fields.Integer('Corridor (X)', default=0, help="Optional localization details, for information purpose only") posy = fields.Integer('Shelves (Y)', default=0, help="Optional localization details, for information purpose only") diff --git a/addons/stock/views/stock_location_views.xml b/addons/stock/views/stock_location_views.xml index e7713c97fdf..70fb18ef887 100644 --- a/addons/stock/views/stock_location_views.xml +++ b/addons/stock/views/stock_location_views.xml @@ -34,7 +34,6 @@ - From f3ad1e2bcbca12be0468d6f9f1694542ebfc5b16 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Mon, 22 Oct 2018 09:03:22 +0000 Subject: [PATCH 3/7] [REF] stock: remove confusing demo data As configuring multiple vendor locations is a quite advanced case, that need too change configuration on partners, and eventually routing, we remove those demo data that can lead to misunderstanding the way vendor locations works. We've also adapted a test that was using those demo data TASK-ID: 38469 --- addons/stock/data/stock_demo.xml | 35 ------------------- addons/stock/data/stock_demo_pre.xml | 2 ++ .../stock/tests/test_stock_location_search.py | 2 +- 3 files changed, 3 insertions(+), 36 deletions(-) diff --git a/addons/stock/data/stock_demo.xml b/addons/stock/data/stock_demo.xml index 5ba6b1a3dd6..f274a335fa7 100644 --- a/addons/stock/data/stock_demo.xml +++ b/addons/stock/data/stock_demo.xml @@ -7,41 +7,6 @@ - - - - IT Vendors - - supplier - 2601985 - - - - Big Vendors - - supplier - - - - Generic IT Vendors - - supplier - - - - European Customers - - customer - - - - Non European Customers - - customer - - - - diff --git a/addons/stock/data/stock_demo_pre.xml b/addons/stock/data/stock_demo_pre.xml index f72e84cdfc2..57fac7bc229 100644 --- a/addons/stock/data/stock_demo_pre.xml +++ b/addons/stock/data/stock_demo_pre.xml @@ -4,12 +4,14 @@ Shelf 2 0 + 2601985 Shelf 1 0 + 2601892 diff --git a/addons/stock/tests/test_stock_location_search.py b/addons/stock/tests/test_stock_location_search.py index 014759c7899..d19cfa8d775 100644 --- a/addons/stock/tests/test_stock_location_search.py +++ b/addons/stock/tests/test_stock_location_search.py @@ -7,7 +7,7 @@ class TestStockLocationSearch(common.TransactionCase): def setUp(self): super(TestStockLocationSearch, self).setUp() self.location = self.env['stock.location'] - self.location_barcode = self.env.ref('stock.stock_location_3') + self.location_barcode = self.env.ref('stock.stock_location_14') self.location_barcode_id = self.location_barcode.id self.barcode = self.location_barcode.barcode self.name = self.location_barcode.name From 9775d4cce886ea7d16b85f45dc2060f5596e80d3 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Tue, 30 Oct 2018 19:54:25 +0000 Subject: [PATCH 4/7] [FIX] stock: Don't allow to archive main locations of warehouse When a location is archived, we are checking that it is not used a warehouse stock or view location to avoid bad configration leading to inconsistencies on stock available quantities. TASK-ID: 38469 --- addons/stock/models/stock_location.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/stock/models/stock_location.py b/addons/stock/models/stock_location.py index 6e48f4283e5..4c9f32c3266 100644 --- a/addons/stock/models/stock_location.py +++ b/addons/stock/models/stock_location.py @@ -94,6 +94,13 @@ class Location(models.Model): " Please unreserve the products first." )) if 'active' in values: + if values['active'] == False: + for location in self: + warehouses = self.env['stock.warehouse'].search([('active', '=', True), '|', ('lot_stock_id', '=', location.id), ('view_location_id', '=', location.id)]) + if warehouses: + raise UserError(_("You cannot archive the location %s as it is" + " used by your warehouse %s") % (location.display_name, warehouses[0].display_name)) + if not self.env.context.get('do_not_check_quant'): children_location = self.env['stock.location'].with_context(active_test=False).search([('id', 'child_of', self.ids)]) internal_children_locations = children_location.filtered(lambda l: l.usage == 'internal') From 5e42f46b87f7792411dce61016fb66cb2861cf60 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Tue, 13 Nov 2018 09:00:00 +0000 Subject: [PATCH 5/7] [IMP] stock: warehouse view We add the stock and view location in debug mode for warehouse form to be able to check easily the warehouse configuration. TASK-ID: 38469 --- addons/stock/views/stock_warehouse_views.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/stock/views/stock_warehouse_views.xml b/addons/stock/views/stock_warehouse_views.xml index 388411e285b..62f4212b977 100644 --- a/addons/stock/views/stock_warehouse_views.xml +++ b/addons/stock/views/stock_warehouse_views.xml @@ -45,6 +45,8 @@ + + From e0cac32bdcd8054a7cde8bda08df893211671841 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Tue, 13 Nov 2018 09:08:06 +0000 Subject: [PATCH 6/7] [IMP] stock: orderpoint only on internal and view location We put a domain on location_id on order point to only allow to create orderpoint on location of type 'view' or 'internal'. TASK-ID: 38469 --- addons/stock/views/stock_warehouse_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/views/stock_warehouse_views.xml b/addons/stock/views/stock_warehouse_views.xml index 62f4212b977..aab08987ed4 100644 --- a/addons/stock/views/stock_warehouse_views.xml +++ b/addons/stock/views/stock_warehouse_views.xml @@ -219,7 +219,7 @@ - + From 0d6bcd3918f6f99fcffc49925544c9de39b5f1ac Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Tue, 13 Nov 2018 09:50:00 +0000 Subject: [PATCH 7/7] [IMP] stock: scrap location internal or inventory We restrict the case of locations that can be scrap locations to locations of usage internal or inventory loss, depending on how you want to manage your scrap. Other usage of location shouldn't be scrap locations. TASK-ID: 38469 --- addons/stock/models/stock_location.py | 5 +++++ addons/stock/views/stock_location_views.xml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_location.py b/addons/stock/models/stock_location.py index 4c9f32c3266..118a253398a 100644 --- a/addons/stock/models/stock_location.py +++ b/addons/stock/models/stock_location.py @@ -74,6 +74,11 @@ class Location(models.Model): else: self.complete_name = self.name + @api.onchange('usage') + def _onchange_usage(self): + if self.usage not in ('internal', 'inventory'): + self.scrap_location = False + def write(self, values): if 'usage' in values and values['usage'] == 'view': if self.mapped('quant_ids'): diff --git a/addons/stock/views/stock_location_views.xml b/addons/stock/views/stock_location_views.xml index 70fb18ef887..b726d374970 100644 --- a/addons/stock/views/stock_location_views.xml +++ b/addons/stock/views/stock_location_views.xml @@ -35,7 +35,7 @@ - +