[MIG] stock_removal_location_by_priority: Migration to 17.0

This commit is contained in:
JasminSForgeFlow
2024-06-07 17:36:29 +05:30
parent ca3d954990
commit bb585c91d1
9 changed files with 30 additions and 30 deletions

View File

@@ -1,10 +1,10 @@
# Copyright 2017 ForgeFlow S.L.
# Copyright 2024 ForgeFlow S.L.
# (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Stock Removal Location by Priority",
"summary": "Establish a removal priority on stock locations.",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"author": "ForgeFlow, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"category": "Warehouse",

View File

@@ -1,4 +1,4 @@
# Copyright 2017 ForgeFlow, S.L.
# Copyright 2024 ForgeFlow, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
@@ -6,7 +6,7 @@ import logging
logger = logging.getLogger(__name__)
def pre_init_hook(cr):
def pre_init_hook(env):
"""
The objective of this hook is to speed up the installation
of the module on an existing Odoo instance.
@@ -14,8 +14,8 @@ def pre_init_hook(cr):
Without this script, big databases can take a long time to install this
module.
"""
set_stock_location_removal_priority_default(cr)
set_stock_quant_removal_priority_default(cr)
set_stock_location_removal_priority_default(env.cr)
set_stock_quant_removal_priority_default(env.cr)
def set_stock_location_removal_priority_default(cr):

View File

@@ -1,4 +1,4 @@
# Copyright 2017-18 ForgeFlow S.L.
# Copyright 2017-24 ForgeFlow S.L.
# (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

View File

@@ -1,4 +1,4 @@
# Copyright 2017 ForgeFlow S.L.
# Copyright 2024 ForgeFlow S.L.
# (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

View File

@@ -1,4 +1,4 @@
# Copyright 2017-18 ForgeFlow S.L.
# Copyright 2017-24 ForgeFlow S.L.
# (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
@@ -14,15 +14,21 @@ class StockQuant(models.Model):
)
@api.model
def _get_removal_strategy_order(self, removal_strategy):
def _get_removal_strategy_domain_order(self, domain, removal_strategy, qty):
if self.user_has_groups(
"stock_removal_location_by_priority.group_removal_priority"
):
if removal_strategy == "fifo":
return "in_date ASC, removal_priority ASC, id"
return domain, "in_date ASC, removal_priority ASC, id"
elif removal_strategy == "lifo":
return "in_date DESC, removal_priority ASC, id desc"
return domain, "in_date DESC, removal_priority ASC, id desc"
raise UserError(
_("Removal strategy %s not implemented.") % (removal_strategy,)
)
return super(StockQuant, self)._get_removal_strategy_order(removal_strategy)
return super()._get_removal_strategy_domain_order(domain, removal_strategy, qty)
def _get_removal_strategy_sort_key(self, removal_strategy):
key, reverse = super()._get_removal_strategy_sort_key(removal_strategy)
if removal_strategy == "fifo":
key = lambda q: (q.removal_priority, q.in_date, q.id) # noqa: E731
return key, reverse

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017-18 ForgeFlow S.L.
<!-- Copyright 2017-24 ForgeFlow S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="group_removal_priority" model="res.groups">

View File

@@ -1,4 +1,4 @@
# Copyright 2017-18 ForgeFlow S.L.
# Copyright 2017-24 ForgeFlow S.L.
# (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
@@ -10,7 +10,7 @@ from odoo.tests.common import TransactionCase
class TestStockRemovalLocationByPriority(TransactionCase):
def setUp(self):
super(TestStockRemovalLocationByPriority, self).setUp()
super().setUp()
self.res_users_model = self.env["res.users"]
self.stock_location_model = self.env["stock.location"]
self.stock_warehouse_model = self.env["stock.warehouse"]

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017-18 ForgeFlow S.L.
<!-- Copyright 2017-24 ForgeFlow S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="view_stock_config_settings" model="ir.ui.view">
@@ -7,18 +7,12 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="stock.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='warning_info']" position="after">
<div class="col-12 col-lg-6 o_setting_box" id="removal_priority">
<div class="o_setting_left_pane">
<field name="group_removal_priority" />
</div>
<div class="o_setting_right_pane">
<label for="group_removal_priority" />
<div class="text-muted">
Use <i>Removal Priority</i> in Locations
</div>
</div>
</div>
<xpath expr="//setting[@id='warning_info']" position="after">
<setting id="group_removal_priority" string="Removal Priority">
<field name="group_removal_priority" />
<div class="text-muted"> Use <i
>Removal Priority</i> in Locations </div>
</setting>
</xpath>
</field>
</record>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 ForgeFlow S.L.
<!-- Copyright 2024 ForgeFlow S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="view_location_form" model="ir.ui.view">