From 4f386b0deca6d751458a93f74994873f4fd0d0dd Mon Sep 17 00:00:00 2001 From: "Touati Djamel (otd)" Date: Thu, 18 Nov 2021 10:48:28 +0000 Subject: [PATCH] [FIX] stock: add correctly a product in storage categories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce the bug: - Connect as Admin and select “My Company (San Francisco)” - Create a storable product “P1” and select “My Company (San Francisco)” in the `”company”` field - Go to inventory settings and enable the “Storage Categories” option - Create a new “Storage Categorie” > select “My Company (San Francisco)” in the `”company”` field > save BUG1: Edit and try to add the product “P1” > Edit and try to add the product “P1” > "P1" is not filtered correctly with domain, because the `”company”` field of the `"stock.storage.category.capacity"` model is not set. As it's a related field, the “default_company_id” should be in the context so that the “company_id” field will be correctly set with this value BUG2: Add a new line > create and edit a new product > the product type is “consumable” instead of storable, so we should add the type in the context BUG3: Add multi-company security rule opw-2689426 closes odoo/odoo#80061 X-original-commit: f5554fa94d41d7eae62c4a1271e41012178c4d8f Signed-off-by: Arnold Moyaux Signed-off-by: Djamel Touati (otd) --- addons/stock/models/stock_location.py | 2 +- addons/stock/security/stock_security.xml | 6 ++++++ addons/stock/views/stock_storage_category_views.xml | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/addons/stock/models/stock_location.py b/addons/stock/models/stock_location.py index 5cb1083d950..8437f1b7e68 100644 --- a/addons/stock/models/stock_location.py +++ b/addons/stock/models/stock_location.py @@ -78,7 +78,7 @@ class Location(models.Model): next_inventory_date = fields.Date("Next Expected Inventory", compute="_compute_next_inventory_date", store=True, help="Date for next planned inventory based on cyclic schedule.") warehouse_view_ids = fields.One2many('stock.warehouse', 'view_location_id', readonly=True) warehouse_id = fields.Many2one('stock.warehouse', compute='_compute_warehouse_id') - storage_category_id = fields.Many2one('stock.storage.category', string='Storage Category') + storage_category_id = fields.Many2one('stock.storage.category', string='Storage Category', check_company=True) outgoing_move_line_ids = fields.One2many('stock.move.line', 'location_id', help='Technical: used to compute weight.') incoming_move_line_ids = fields.One2many('stock.move.line', 'location_dest_id', help='Technical: used to compute weight.') net_weight = fields.Float('Net Weight', compute="_compute_weight") diff --git a/addons/stock/security/stock_security.xml b/addons/stock/security/stock_security.xml index 4aaf7d14416..3ac7aed0c3e 100644 --- a/addons/stock/security/stock_security.xml +++ b/addons/stock/security/stock_security.xml @@ -175,5 +175,11 @@ ['|',('company_id','=',False),('company_id', 'in', company_ids)] + + stock_storage_category multi-company + + ['|',('company_id','=',False),('company_id', 'in', company_ids)] + + diff --git a/addons/stock/views/stock_storage_category_views.xml b/addons/stock/views/stock_storage_category_views.xml index 1ddb4c4c580..481dc1f3348 100644 --- a/addons/stock/views/stock_storage_category_views.xml +++ b/addons/stock/views/stock_storage_category_views.xml @@ -25,7 +25,7 @@ - + @@ -34,9 +34,9 @@ - + - +