Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][MIG] stock_packaging_calculator #1327

Merged
merged 41 commits into from
Feb 22, 2022
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c5c0a63
Add stock_packaging_calculator
simahawk May 26, 2020
d893e45
stock_packaging_calculator: make product uom the minimal unit
simahawk Jun 8, 2020
97ea806
[UPD] Update stock_packaging_calculator.pot
oca-travis Jun 8, 2020
e0249f9
stock_packaging_calculator: return dict instead of tuple
simahawk Jun 8, 2020
9b48b27
[UPD] README.rst
OCA-git-bot Jun 8, 2020
4dd8a45
[ADD] icon.png
OCA-git-bot Jun 8, 2020
93bf5e3
stock_packaging_calculator: add contained packaging compute
simahawk Jun 8, 2020
7539376
[UPD] README.rst
OCA-git-bot Jun 9, 2020
cb0eb5f
stock_packaging_calculator 13.0.1.1.0
OCA-git-bot Jun 9, 2020
e5d336f
stock_packaging_calculator: make contained mapping computed
simahawk Jun 9, 2020
1cf5fde
[UPD] Update stock_packaging_calculator.pot
oca-travis Jun 22, 2020
a1f94a0
stock_packaging_calculator 13.0.1.2.0
OCA-git-bot Jun 22, 2020
a560a7e
stock_packaging_calculator: add support for packaging filter
simahawk Jun 30, 2020
267a39c
stock_packaging_calculator: add support for custom packaging name
simahawk Jun 30, 2020
25e2fa6
stock_packaging_calculator 13.0.1.3.0
OCA-git-bot Jul 1, 2020
f671228
Re-license stock_packaging_calculator w/ LGPL
simahawk Jul 15, 2020
edcfbaf
stock_packaging_calculator 13.0.1.4.0
OCA-git-bot Jul 16, 2020
6a3bb8d
[IMP][stock_packaging_calculator] Add key is_unit for in the packagin…
Tonow-c2c Jul 6, 2020
0b1eaf9
stock_packaging_calculator: Add hook on packaging values
grindtildeath Jul 16, 2020
c4b0237
stock_packaging_calculator 13.0.1.5.0
simahawk Jul 17, 2020
415fff5
packaging_calculator: fix sorting
simahawk Aug 3, 2020
19092f8
packaging_calculator: allow custom value handler
simahawk Aug 3, 2020
0102fec
stock_packaging_calculator 13.0.1.6.0
OCA-git-bot Aug 11, 2020
b086eb7
[IMP] stock_packaging_calculator: black, isort, prettier
sebastienbeau Jan 6, 2021
77bc739
[MIG] stock_packaging_calculator: Migration to 14.0
sebastienbeau Jan 6, 2021
6591a22
[UPD] Update stock_packaging_calculator.pot
oca-travis Feb 5, 2021
0ec650a
[UPD] README.rst
OCA-git-bot Feb 5, 2021
2eae0e4
stock_packaging_calculator 14.0.1.0.1
OCA-git-bot Feb 5, 2021
11c8f3f
s_packaging_calculator: include barcode
simahawk May 11, 2021
2e6fddc
s_packaging_calculator: ease override of packaging name
simahawk May 28, 2021
2d52fe8
s_packaging_calculator: add product_qty_by_packaging_as_str
simahawk May 28, 2021
dcfe9b9
s_packaging_calculator: add handy mixin
simahawk May 28, 2021
77c2b38
s_packaging_calculator: contained mapping depends on lang
simahawk Jun 3, 2021
ee59672
s_packaging_calculator: include units when units only on demand
simahawk Jun 11, 2021
a30d36e
s_packaging_calculator: improve test util
simahawk Jul 15, 2021
6bfe0ee
[UPD] Update stock_packaging_calculator.pot
oca-travis Jun 7, 2021
b83cb97
[IMP] stock_packaging_calculator: black, isort, prettier
Sep 14, 2021
725307e
[UPD] Update stock_packaging_calculator.pot
oca-travis Sep 21, 2021
57f81a2
stock_packaging_calculator 14.0.1.1.0
OCA-git-bot Sep 21, 2021
9ded9ef
[IMP] stock_packaging_calculator: black, isort, prettier
ChrisOForgeFlow Dec 13, 2021
9c005ae
[15.0][MIG] stock_packaging_calculator
ChrisOForgeFlow Dec 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
packaging_calculator: allow custom value handler
Use _packaging_values_handler ctx key to pass your own handler
for specific on demand overrides.
  • Loading branch information
simahawk authored and ChrisOForgeFlow committed Dec 13, 2021
commit 19092f8f9f3bc6cfbe80c0f90c7dc613b924b17d
5 changes: 4 additions & 1 deletion stock_packaging_calculator/models/product.py
Original file line number Diff line number Diff line change
@@ -102,10 +102,13 @@ def _product_qty_by_packaging(self, pkg_by_qty, qty, with_contained=False):
"""Produce a list of dictionaries of packaging info."""
# TODO: refactor to handle fractional quantities (eg: 0.5 Kg)
res = []
prepare_values = self.env.context.get(
"_packaging_values_handler", self._prepare_qty_by_packaging_values
)
for pkg in pkg_by_qty:
qty_per_pkg, qty = self._qty_by_pkg(pkg.qty, qty)
if qty_per_pkg:
value = self._prepare_qty_by_packaging_values(pkg, qty_per_pkg)
value = prepare_values(pkg, qty_per_pkg)
if with_contained:
contained = None
if not pkg.is_unit:
18 changes: 18 additions & 0 deletions stock_packaging_calculator/tests/test_packaging_calc.py
Original file line number Diff line number Diff line change
@@ -234,6 +234,24 @@ def test_calc_name_get(self):
expected,
)

def test_calc_custom_values(self):
"""Test custom values handler."""
expected = [
{"my_qty": 1, "foo": self.pkg_pallet.name},
{"my_qty": 3, "foo": self.pkg_big_box.name},
{"my_qty": 1, "foo": self.pkg_box.name},
{"my_qty": 5, "foo": self.uom_unit.name},
]
self.assertEqual(
self.product_a.with_context(
_packaging_values_handler=lambda pkg, qty_per_pkg: {
"my_qty": qty_per_pkg,
"foo": pkg.name,
}
).product_qty_by_packaging(2655),
expected,
)

def test_calc_sub1(self):
"""Test contained packaging behavior 1."""
expected = [