mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_location_product_restriction: pre-commit stuff
This commit is contained in:
@@ -0,0 +1 @@
|
||||
__import__('pkg_resources').declare_namespace(__name__)
|
||||
@@ -0,0 +1 @@
|
||||
__import__('pkg_resources').declare_namespace(__name__)
|
||||
@@ -0,0 +1 @@
|
||||
../../../../stock_location_product_restriction
|
||||
6
setup/stock_location_product_restriction/setup.py
Normal file
6
setup/stock_location_product_restriction/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
@@ -9,7 +8,7 @@
|
||||
"version": "10.0.1.0.2",
|
||||
"license": "AGPL-3",
|
||||
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
|
||||
"website": "https://acsone.eu/",
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
"depends": ["stock"],
|
||||
"data": ["views/stock_location.xml"],
|
||||
"demo": [],
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
@@ -8,7 +7,7 @@ _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def column_exists(cr, tablename, columnname):
|
||||
""" Return whether the given column exists. """
|
||||
"""Return whether the given column exists."""
|
||||
query = """ SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name=%s AND column_name=%s """
|
||||
cr.execute(query, (tablename, columnname))
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.osv.expression import NEGATIVE_TERM_OPERATORS
|
||||
|
||||
|
||||
@@ -107,9 +106,7 @@ class StockLocation(models.Model):
|
||||
"product but it contains items of products %s"
|
||||
) % " | ".join(products.mapped("name"))
|
||||
record.has_restriction_violation = has_restriction_violation
|
||||
record.restriction_violation_message = (
|
||||
restriction_violation_message
|
||||
)
|
||||
record.restriction_violation_message = restriction_violation_message
|
||||
|
||||
def _search_has_restriction_violation(self, operator, value):
|
||||
search_has_violation = (
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
from odoo import api, models, _
|
||||
from odoo import _, api, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
@@ -69,17 +68,11 @@ class StockMove(models.Model):
|
||||
location_dest_id,
|
||||
existing_product_ids,
|
||||
) in existing_product_ids_by_location_id.items():
|
||||
product_ids_to_move = product_ids_location_dest_id[
|
||||
location_dest_id
|
||||
]
|
||||
if set(existing_product_ids).symmetric_difference(
|
||||
product_ids_to_move
|
||||
):
|
||||
product_ids_to_move = product_ids_location_dest_id[location_dest_id]
|
||||
if set(existing_product_ids).symmetric_difference(product_ids_to_move):
|
||||
location = StockLocation.browse(location_dest_id)
|
||||
existing_products = ProductProduct.browse(existing_product_ids)
|
||||
to_move_products = ProductProduct.browse(
|
||||
list(product_ids_to_move)
|
||||
)
|
||||
to_move_products = ProductProduct.browse(list(product_ids_to_move))
|
||||
error_msgs.append(
|
||||
_(
|
||||
"You plan to move the product %s to the location %s "
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
@@ -30,12 +29,8 @@ class TestStockLocation(SavepointCase):
|
||||
# products
|
||||
Product = cls.env["product.product"]
|
||||
cls.uom_unit = cls.env.ref("product.product_uom_unit")
|
||||
cls.product_1 = Product.create(
|
||||
{"name": "Wood", "uom_id": cls.uom_unit.id}
|
||||
)
|
||||
cls.product_2 = Product.create(
|
||||
{"name": "Stone", "uom_id": cls.uom_unit.id}
|
||||
)
|
||||
cls.product_1 = Product.create({"name": "Wood", "uom_id": cls.uom_unit.id})
|
||||
cls.product_2 = Product.create({"name": "Stone", "uom_id": cls.uom_unit.id})
|
||||
|
||||
# quants
|
||||
StockQuant = cls.env["stock.quant"]
|
||||
@@ -109,7 +104,8 @@ class TestStockLocation(SavepointCase):
|
||||
"""
|
||||
self.loc_lvl_1_1.specific_product_restriction = "same"
|
||||
self.assertEqual(
|
||||
self.default_product_restriction, self.loc_lvl.product_restriction,
|
||||
self.default_product_restriction,
|
||||
self.loc_lvl.product_restriction,
|
||||
)
|
||||
self.assertEqual(
|
||||
self.default_product_restriction,
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
from odoo.tests.common import SavepointCase
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests.common import SavepointCase
|
||||
|
||||
ShortMoveInfo = namedtuple(
|
||||
"ShortMoveInfo", ["product", "location_dest", "qty"]
|
||||
)
|
||||
ShortMoveInfo = namedtuple("ShortMoveInfo", ["product", "location_dest", "qty"])
|
||||
|
||||
|
||||
class TestStockMove(SavepointCase):
|
||||
@@ -29,12 +26,8 @@ class TestStockMove(SavepointCase):
|
||||
super(TestStockMove, cls).setUpClass()
|
||||
cls.uom_unit = cls.env.ref("product.product_uom_unit")
|
||||
Product = cls.env["product.product"]
|
||||
cls.product_1 = Product.create(
|
||||
{"name": "Wood", "uom_id": cls.uom_unit.id}
|
||||
)
|
||||
cls.product_2 = Product.create(
|
||||
{"name": "Stone", "uom_id": cls.uom_unit.id}
|
||||
)
|
||||
cls.product_1 = Product.create({"name": "Wood", "uom_id": cls.uom_unit.id})
|
||||
cls.product_2 = Product.create({"name": "Stone", "uom_id": cls.uom_unit.id})
|
||||
|
||||
# Warehouses
|
||||
cls.warehouse_1 = cls.env["stock.warehouse"].create(
|
||||
@@ -236,7 +229,8 @@ class TestStockMove(SavepointCase):
|
||||
We now have two product into the same location
|
||||
"""
|
||||
self.assertEqual(
|
||||
self.product_1, self._get_products_in_location(self.location_1),
|
||||
self.product_1,
|
||||
self._get_products_in_location(self.location_1),
|
||||
)
|
||||
self.location_1.specific_product_restriction = "any"
|
||||
picking = self._create_and_assign_picking(
|
||||
@@ -272,7 +266,8 @@ class TestStockMove(SavepointCase):
|
||||
"""
|
||||
|
||||
self.assertEqual(
|
||||
self.product_1, self._get_products_in_location(self.location_1),
|
||||
self.product_1,
|
||||
self._get_products_in_location(self.location_1),
|
||||
)
|
||||
self.location_1.specific_product_restriction = "same"
|
||||
picking = self._create_and_assign_picking(
|
||||
|
||||
@@ -1,49 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2020 ACSONE SA/NV
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record model="ir.ui.view" id="stock_location_form_view">
|
||||
<field name="name">stock.location.form (in stock_location_unique_product)</field>
|
||||
<field
|
||||
name="name"
|
||||
>stock.location.form (in stock_location_unique_product)</field>
|
||||
<field name="model">stock.location</field>
|
||||
<field name="inherit_id" ref="stock.view_location_form"/>
|
||||
<field name="inherit_id" ref="stock.view_location_form" />
|
||||
<field name="arch" type="xml">
|
||||
<div name="button_box" position="after">
|
||||
<div
|
||||
class="alert alert-danger"
|
||||
role="alert"
|
||||
attrs="{'invisible': [('restriction_violation_message','=',False)]}"
|
||||
class="alert alert-danger"
|
||||
role="alert"
|
||||
attrs="{'invisible': [('restriction_violation_message','=',False)]}"
|
||||
><field name="restriction_violation_message" />
|
||||
</div>
|
||||
</div>
|
||||
<xpath expr="//group[last()]">
|
||||
<group name="restrictions" string="Restrictions">
|
||||
<field name="product_restriction"/>
|
||||
<field name="specific_product_restriction" class="oe_edit_only"/>
|
||||
<field name="product_restriction" />
|
||||
<field name="specific_product_restriction" class="oe_edit_only" />
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="stock_location_search_view">
|
||||
<field name="name">stock.location.search (in stock_location_unique_product)</field>
|
||||
<field
|
||||
name="name"
|
||||
>stock.location.search (in stock_location_unique_product)</field>
|
||||
<field name="model">stock.location</field>
|
||||
<field name="inherit_id" ref="stock.view_location_search"/>
|
||||
<field name="inherit_id" ref="stock.view_location_search" />
|
||||
<field name="arch" type="xml">
|
||||
<filter name="inactive" position="after">
|
||||
<filter string="With restriction violation" name="has_restriction_violation" domain="[('has_restriction_violation','=',True)]"/>
|
||||
<filter
|
||||
string="With restriction violation"
|
||||
name="has_restriction_violation"
|
||||
domain="[('has_restriction_violation','=',True)]"
|
||||
/>
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="stock_location_tree_view">
|
||||
<field name="name">stock.location.tree (in stock_location_unique_product)</field>
|
||||
<field
|
||||
name="name"
|
||||
>stock.location.tree (in stock_location_unique_product)</field>
|
||||
<field name="model">stock.location</field>
|
||||
<field name="inherit_id" ref="stock.view_location_tree2"/>
|
||||
<field name="inherit_id" ref="stock.view_location_tree2" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="company_id" position="before">
|
||||
<field name="has_restriction_violation"/>
|
||||
<field name="has_restriction_violation" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user