[IMP/FIX] Removal priority should be independent of company

This commit is contained in:
mreficent
2017-10-30 18:45:42 +01:00
committed by SergiCForgeFlow
parent ee096b3654
commit ed59d9bab1
10 changed files with 35 additions and 40 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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

View File

@@ -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.")

View File

@@ -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.")

View File

@@ -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':

View File

@@ -0,0 +1,8 @@
<odoo>
<data noupdate="0">
<record id="group_removal_priority" model="res.groups">
<field name="name">Removal Priority</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
</data>
</odoo>

View File

@@ -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',

View File

@@ -9,18 +9,8 @@
<field name="inherit_id" ref="stock.view_stock_config_settings"/>
<field name="arch" type="xml">
<field name="group_warning_stock" position="after">
<field name="removal_priority_active"/>
<field name="group_removal_priority" widget="radio"/>
</field>
<header position="after">
<group>
<field name="company_id" invisible="1"/>
</group>
</header>
<form position="inside">
<div>
<span>(*) This configuration is related to the company you're logged into.</span>
</div>
</form>
</field>
</record>

View File

@@ -9,8 +9,8 @@
<field name="model">stock.location</field>
<field name="inherit_id" ref="stock.view_location_form"/>
<field name="arch" type="xml">
<field name="active" position="after">
<field name="removal_priority" group="removal_priority_active"/>
<field name="removal_strategy_id" position="after">
<field name="removal_priority" groups="stock_removal_location_by_priority.group_removal_priority"/>
</field>
</field>
</record>