Skip to content

Commit

Permalink
[MIG] stock_packaging_calculator: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
QuocDuong1306 authored and thienvh332 committed Oct 10, 2024
1 parent 0fefbf4 commit 8ff7ea8
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 17 deletions.
17 changes: 12 additions & 5 deletions stock_packaging_calculator/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Stock packaging calculator
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-warehouse/tree/17.0/stock_packaging_calculator
:target: https://github.com/OCA/stock-logistics-warehouse/tree/18.0/stock_packaging_calculator
:alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-17-0/stock-logistics-warehouse-17-0-stock_packaging_calculator
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-18-0/stock-logistics-warehouse-18-0-stock_packaging_calculator
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -88,7 +88,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_packaging_calculator%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_packaging_calculator%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -106,6 +106,13 @@ Contributors
- Simone Orsi <simahawk@gmail.com>
- Christopher Ormaza <chris.ormaza@forgeflow.com>
- Nguyen Minh Chien <chien@trobz.com>
- Tran Quoc Duong <duongtq@trobz.com>

Other credits
-------------

The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp.

Maintainers
-----------
Expand All @@ -120,6 +127,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/17.0/stock_packaging_calculator>`_ project on GitHub.
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/18.0/stock_packaging_calculator>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion stock_packaging_calculator/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Stock packaging calculator",
"summary": "Compute product quantity to pick by packaging",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"development_status": "Beta",
"category": "Warehouse Management",
"website": "https://github.com/OCA/stock-logistics-warehouse",
Expand Down
22 changes: 16 additions & 6 deletions stock_packaging_calculator/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,30 @@ def _product_qty_by_packaging(self, pkg_by_qty, qty, with_contained=False):
prepare_values = self.env.context.get(
"_packaging_values_handler", self._prepare_qty_by_packaging_values
)
uom_rounding = self.uom_id.rounding
for pkg in pkg_by_qty:
# Boost perf: no need to deduce the qty_per_pkg if the pkg_qty is 1
if float_compare(pkg.qty, 1, precision_digits=self.uom_id.rounding) == 0:
qty_per_pkg = int(qty)
qty = 0.0
if float_compare(pkg.qty, 1, precision_rounding=uom_rounding) == 0:
# If qty is an integer, use int value, else round it
qty_diff = float_compare(
qty - int(qty), 0.0, precision_rounding=uom_rounding
)
qty_per_pkg = (
int(qty)
if qty_diff == 0
else float_round(qty, precision_rounding=uom_rounding)
)
qty = 0
else:
qty_per_pkg, qty = self._qty_by_pkg(pkg.qty, qty)

# To handle fractional quantities (eg: 0.5 Kg)
if pkg.is_unit and not float_is_zero(
qty, precision_rounding=self.uom_id.rounding
qty, precision_rounding=uom_rounding
):
# `is_unit` package always be the last package by the sorting
# it has the same uom with the product, just sum the quantity
qty_per_pkg += float_round(qty, precision_rounding=self.uom_id.rounding)
qty_per_pkg += float_round(qty, precision_rounding=uom_rounding)
qty = 0

if qty_per_pkg:
Expand All @@ -147,7 +157,7 @@ def _qty_by_pkg(self, pkg_qty, qty):
"""Calculate qty needed for given package qty."""
qty_per_pkg = 0
while (
float_compare(qty - pkg_qty, 0.0, precision_digits=self.uom_id.rounding)
float_compare(qty - pkg_qty, 0.0, precision_rounding=self.uom_id.rounding)
>= 0.0
):
qty -= pkg_qty
Expand Down
1 change: 1 addition & 0 deletions stock_packaging_calculator/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Simone Orsi \<<simahawk@gmail.com>\>
- Christopher Ormaza \<<chris.ormaza@forgeflow.com>\>
- Nguyen Minh Chien \<<chien@trobz.com>\>
- Tran Quoc Duong \<<duongtq@trobz.com>\>
1 change: 1 addition & 0 deletions stock_packaging_calculator/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp.
17 changes: 12 additions & 5 deletions stock_packaging_calculator/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Stock packaging calculator</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:355bc67eed8ca907e517b4a8f46ac6b8a8e685664f2342d6d12fa7fc79a05b38
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/stock-logistics-warehouse/tree/17.0/stock_packaging_calculator"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-17-0/stock-logistics-warehouse-17-0-stock_packaging_calculator"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/stock-logistics-warehouse/tree/18.0/stock_packaging_calculator"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-18-0/stock-logistics-warehouse-18-0-stock_packaging_calculator"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Basic module providing an helper method to calculate the quantity of
product by packaging.</p>
<p><strong>Table of contents</strong></p>
Expand All @@ -381,7 +381,8 @@ <h1 class="title">Stock packaging calculator</h1>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-7">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -433,7 +434,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_packaging_calculator%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_packaging_calculator%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -450,18 +451,24 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simahawk&#64;gmail.com">simahawk&#64;gmail.com</a>&gt;</li>
<li>Christopher Ormaza &lt;<a class="reference external" href="mailto:chris.ormaza&#64;forgeflow.com">chris.ormaza&#64;forgeflow.com</a>&gt;</li>
<li>Nguyen Minh Chien &lt;<a class="reference external" href="mailto:chien&#64;trobz.com">chien&#64;trobz.com</a>&gt;</li>
<li>Tran Quoc Duong &lt;<a class="reference external" href="mailto:duongtq&#64;trobz.com">duongtq&#64;trobz.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-7">Other credits</a></h2>
<p>The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp.</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/17.0/stock_packaging_calculator">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/18.0/stock_packaging_calculator">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down

0 comments on commit 8ff7ea8

Please sign in to comment.