diff --git a/stock_removal_location_by_priority/README.rst b/stock_removal_location_by_priority/README.rst index c9a8fd763..3077dbd0a 100644 --- a/stock_removal_location_by_priority/README.rst +++ b/stock_removal_location_by_priority/README.rst @@ -16,7 +16,12 @@ Configuration You can configure the removal priority as follows: #. Go to "Inventory > Configuration > Settings" -#. In 'Location & Warehouse' section, mark "Use 'Removal Priority' in Locations *" +#. In 'Location & Warehouse' section, mark the "Removal Priority" option. + +NOTE: To be able to view this option you need to have already marked: + +#. Manage several locations in "Warehouses and Locations usage level" option. +#. Advanced routing of products using rules in "Routing" option. Usage ===== @@ -24,7 +29,7 @@ Usage To use this module, you need to: #. Go to "Inventory > Configuration > Warehouse Management > Locations" -#. In each Location form, put a Removal Priority. +#. In each Location form, in the Logistics section, put a Removal Priority. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot diff --git a/stock_removal_location_by_priority/__manifest__.py b/stock_removal_location_by_priority/__manifest__.py index 95870c0a7..9aa7cce4f 100644 --- a/stock_removal_location_by_priority/__manifest__.py +++ b/stock_removal_location_by_priority/__manifest__.py @@ -12,8 +12,10 @@ "category": "Warehouse Management", "depends": ["stock"], "data": [ + 'security/stock_security.xml', 'views/res_config_settings_views.xml', - 'views/stock_location_view.xml'], + 'views/stock_location_view.xml', + ], "license": "AGPL-3", 'installable': True, 'application': False, diff --git a/stock_removal_location_by_priority/models/__init__.py b/stock_removal_location_by_priority/models/__init__.py index 76a62a061..629e8d9a6 100644 --- a/stock_removal_location_by_priority/models/__init__.py +++ b/stock_removal_location_by_priority/models/__init__.py @@ -3,7 +3,6 @@ # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from . import res_company from . import stock_config_settings from . import stock_location from . import stock_quant diff --git a/stock_removal_location_by_priority/models/res_company.py b/stock_removal_location_by_priority/models/res_company.py deleted file mode 100644 index a920ba57f..000000000 --- a/stock_removal_location_by_priority/models/res_company.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Eficent Business and IT Consulting Services S.L. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import fields, models - - -class ResCompany(models.Model): - _inherit = "res.company" - - removal_priority_active = fields.Boolean( - string="Use 'Removal Priority' in Locations", - help="Adds an extra field in Locations named 'Removal Priority'." - "When removing stock from Locations, this priority will apply" - "whenever the incoming dates of the same stock in several " - "locations are the same.") diff --git a/stock_removal_location_by_priority/models/stock_config_settings.py b/stock_removal_location_by_priority/models/stock_config_settings.py index 6b7e3b835..5da3aa22a 100644 --- a/stock_removal_location_by_priority/models/stock_config_settings.py +++ b/stock_removal_location_by_priority/models/stock_config_settings.py @@ -7,7 +7,11 @@ from odoo import fields, models class StockConfigSettings(models.TransientModel): _inherit = 'stock.config.settings' - removal_priority_active = fields.Boolean( - related='company_id.removal_priority_active', - string="Use 'Removal Priority' in Locations (*)", - help="This configuration is related to the company you're logged into") + group_removal_priority = fields.Selection([ + (0, 'Don\'t use \'Removal Priority\' in Locations'), + (1, 'Use \'Removal Priority\' in Locations'), + ], "Removal Priority", + implied_group='stock_removal_location_by_priority.' + 'group_removal_priority', + help="Removal priority that applies when the incoming dates " + "are equal in both locations.") diff --git a/stock_removal_location_by_priority/models/stock_quant.py b/stock_removal_location_by_priority/models/stock_quant.py index febc26e1c..93cbb9294 100644 --- a/stock_removal_location_by_priority/models/stock_quant.py +++ b/stock_removal_location_by_priority/models/stock_quant.py @@ -16,7 +16,8 @@ class Quant(models.Model): @api.model def _quants_removal_get_order(self, removal_strategy=None): - if self.env.user.company_id.removal_priority_active: + if self.user_has_groups( + 'stock_removal_location_by_priority.group_removal_priority'): if removal_strategy == 'fifo': return 'in_date, removal_priority, id' elif removal_strategy == 'lifo': diff --git a/stock_removal_location_by_priority/security/stock_security.xml b/stock_removal_location_by_priority/security/stock_security.xml new file mode 100644 index 000000000..da6b1aaa2 --- /dev/null +++ b/stock_removal_location_by_priority/security/stock_security.xml @@ -0,0 +1,8 @@ + + + + Removal Priority + + + + diff --git a/stock_removal_location_by_priority/tests/test_stock_removal_location_by_priority.py b/stock_removal_location_by_priority/tests/test_stock_removal_location_by_priority.py index c93bef685..a53e88fdc 100644 --- a/stock_removal_location_by_priority/tests/test_stock_removal_location_by_priority.py +++ b/stock_removal_location_by_priority/tests/test_stock_removal_location_by_priority.py @@ -22,12 +22,14 @@ class TestStockRemovalLocationByPriority(TransactionCase): self.location_supplier = self.env.ref('stock.stock_location_suppliers') self.company = self.env.ref('base.main_company') - self.company.removal_priority_active = True + self.grp_rem_priority = self.env.ref( + 'stock_removal_location_by_priority.group_removal_priority') self.g_stock_user = self.env.ref('stock.group_stock_user') self.user = self._create_user( - 'user_1', [self.g_stock_user], self.company).id + 'user_1', [self.g_stock_user, self.grp_rem_priority], + self.company).id self.wh1 = self.stock_warehouse_model.create({ 'name': 'WH1', diff --git a/stock_removal_location_by_priority/views/res_config_settings_views.xml b/stock_removal_location_by_priority/views/res_config_settings_views.xml index 28b6e25a4..7ee9c871f 100644 --- a/stock_removal_location_by_priority/views/res_config_settings_views.xml +++ b/stock_removal_location_by_priority/views/res_config_settings_views.xml @@ -9,18 +9,8 @@ - + -
- - - -
-
-
- (*) This configuration is related to the company you're logged into. -
-
diff --git a/stock_removal_location_by_priority/views/stock_location_view.xml b/stock_removal_location_by_priority/views/stock_location_view.xml index db4fd46ac..deef32a81 100644 --- a/stock_removal_location_by_priority/views/stock_location_view.xml +++ b/stock_removal_location_by_priority/views/stock_location_view.xml @@ -9,8 +9,8 @@ stock.location - - + +