Skip to content

Commit 3c6ee19

Browse files
author
Michael Michot
committed
[IMP] picking sans limit du nombre de so par bac
1 parent 2b97dff commit 3c6ee19

File tree

9 files changed

+77
-1
lines changed

9 files changed

+77
-1
lines changed

email_template/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"version": "14.0.1.0.0",
99
"author": "Pharmasimple",
1010
"license": "AGPL-3",
11-
"website": "https://www.pharmasimple.com",
11+
"website": "https://github.com/akretion/phs-addons",
1212
"depends": [
1313
"mail",
1414
],

phs_stock/__manifest__.py

+2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
"website": "https://github.com/akretion/phs-addons",
1111
"depends": [
1212
# "stock",
13+
"product",
1314
"stock_picking_batch",
1415
"shopfloor",
1516
],
1617
"data": [
1718
"wizard/batch_force_create_view.xml",
1819
"views/res_partner_views.xml",
20+
"views/product_category.xml",
1921
"views/stock_picking_batch.xml",
2022
"views/stock_picking_views.xml",
2123
"security/ir.model.access.csv",

phs_stock/models/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from . import product_category
12
from . import stock_picking_batch
23
from . import res_partner
34
from . import product_template

phs_stock/models/product_category.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from odoo import fields, models
2+
3+
4+
class ProductCategory(models.Model):
5+
_inherit = "product.category"
6+
7+
no_order_box_limit = fields.Boolean(
8+
help="""This falg determine if during the picking process,
9+
products ca be put in the same box,
10+
no matter the number of order limit of the batch rule"""
11+
)

phs_stock/models/stock_picking_batch.py

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ def write(self, values):
183183
if (
184184
len(self) == 1
185185
and "location_dest_id" in values
186+
and not self.product_id.categ_id.no_order_box_limit
186187
and not self._check_if_so_allready_in_box(values["location_dest_id"])
187188
):
188189
last_scanned_box = self._check_if_so_in_other_box(

phs_stock/tests/test_stock_picking_batch.py

+40
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from odoo.exceptions import UserError
12
from odoo.tests.common import TransactionCase
23
from odoo.tools.safe_eval import safe_eval
34

@@ -31,6 +32,13 @@ def setUp(self):
3132
"picking_type_id": self.type_pick_out_id.id,
3233
}
3334
)
35+
self.output_loc = self.env.ref("stock.stock_location_output")
36+
self.bac1 = self.env["stock.location"].create(
37+
{"name": "BAC-0001", "location_id": self.output_loc.id}
38+
)
39+
self.bac2 = self.env["stock.location"].create(
40+
{"name": "BAC-0002", "location_id": self.output_loc.id}
41+
)
3442

3543
def test_no_rule_no_batch(self):
3644
# No batch creation without rules
@@ -92,3 +100,35 @@ def test_cancel_batch(self):
92100
batch_ids[0].action_cancel()
93101
for move_line in move_lines:
94102
self.assertFalse(move_line.picking_id.batch_id)
103+
104+
def test_category_no_limit(self):
105+
"""Product from catagory with "no order limit in box" settings
106+
can be put all in the same box,
107+
no matter the box attributed to the others products from the same order
108+
and no matter the number of order already in the destination box"""
109+
110+
self.picking_batch.search([]).mapped(lambda r: r.action_cancel())
111+
batch = self.rule.batch_creation(True)[0]
112+
batch[0].picking_ids.move_line_ids.mapped("product_id.categ_id").write(
113+
{"no_order_box_limit": True}
114+
)
115+
try:
116+
for line in batch[0].picking_ids.move_line_ids:
117+
line.write({"location_dest_id": self.bac1.id})
118+
except Exception as e:
119+
self.fail("test_category_no_limit raise unwanted error:{}".format(e))
120+
121+
def test_category_with_limit(self):
122+
"""Product from catagory with "no order limit in box" settings
123+
can be put all in the same box,
124+
no matter the box attributed to the others products from the same order
125+
and no matter the number of order already in the destination box"""
126+
127+
self.picking_batch.search([]).mapped(lambda r: r.action_cancel())
128+
batch = self.rule.batch_creation(True)[0]
129+
batch[0].picking_ids.move_line_ids.mapped("product_id.categ_id").write(
130+
{"no_order_box_limit": False}
131+
)
132+
with self.assertRaises(UserError):
133+
for line in batch[0].picking_ids.move_line_ids:
134+
line.write({"location_dest_id": self.bac1.id})

phs_stock/views/product_category.xml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<!-- product.category inherit form view -->
4+
<record id="product_category_form_view" model="ir.ui.view">
5+
<field name="name">product.category.inherit.view.form</field>
6+
<field name="model">product.category</field>
7+
<field name="inherit_id" ref="product.product_category_form_view" />
8+
<field name="arch" type="xml">
9+
<field name="parent_id" position="after">
10+
<field name="no_order_box_limit" />
11+
</field>
12+
</field>
13+
</record>
14+
</odoo>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../email_template

setup/email_template/setup.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

0 commit comments

Comments
 (0)