Skip to content

Commit

Permalink
[MIG] stock_product_pack: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-zanotti authored and natuan9 committed Oct 30, 2024
1 parent 9132c70 commit e370b79
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 23 deletions.
14 changes: 9 additions & 5 deletions stock_product_pack/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,16 @@ Authors
Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:
- `Tecnativa <https://www.tecnativa.com>`__:

- Ernesto Tejeda
- Pedro M. Baeza
- Sergio Teruel
- João Marques
- Ernesto Tejeda
- Pedro M. Baeza
- Sergio Teruel
- João Marques

- `ADHOC SA <https://www.adhoc.com.ar>`__:

- Bruno Zanotti

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion stock_product_pack/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Stock product Pack",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Warehouse",
"summary": "This module allows you to get the right available quantities "
"of the packs",
Expand Down
23 changes: 20 additions & 3 deletions stock_product_pack/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import math

from odoo import models
from odoo import api, models


class ProductProduct(models.Model):
Expand All @@ -13,10 +13,10 @@ class ProductProduct(models.Model):
def _compute_quantities_dict(
self, lot_id, owner_id, package_id, from_date=False, to_date=False
):
res = super()._compute_quantities_dict(
packs = self.filtered("pack_ok")
res = super(ProductProduct, self - packs)._compute_quantities_dict(
lot_id, owner_id, package_id, from_date=from_date, to_date=to_date
)
packs = self.filtered("pack_ok")
for product in packs.with_context(prefetch_fields=False):
pack_qty_available = []
pack_virtual_available = []
Expand Down Expand Up @@ -48,6 +48,23 @@ def _compute_quantities_dict(
}
return res

@api.depends(
"stock_move_ids.product_qty",
"pack_line_ids.product_id.stock_move_ids.product_qty",
"stock_move_ids.state",
"pack_line_ids.product_id.stock_move_ids.state",
"stock_move_ids.quantity",
"pack_line_ids.product_id.stock_move_ids.quantity",
)
@api.depends_context(
"lot_id",
"owner_id",
"package_id",
"from_date",
"to_date",
"location",
"warehouse",
)
def _compute_quantities(self):
"""In v13 Odoo introduces a filter for products not services.
To keep how it was working on v12 we try to get stock for
Expand Down
2 changes: 2 additions & 0 deletions stock_product_pack/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
- Pedro M. Baeza
- Sergio Teruel
- João Marques
- [ADHOC SA](https://www.adhoc.com.ar):
- Bruno Zanotti
16 changes: 11 additions & 5 deletions stock_product_pack/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -429,12 +429,18 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>João Marques</li>
</ul>
</li>
<li><a class="reference external" href="https://www.adhoc.com.ar">ADHOC SA</a>:<ul>
<li>Bruno Zanotti</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">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>
<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>
Expand Down
18 changes: 10 additions & 8 deletions stock_product_pack/tests/test_stock_product_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

import logging

from odoo.tests import Form, TransactionCase
from odoo.tests import Form, TransactionCase, tagged

_logger = logging.getLogger(__name__)


class TestSaleProductPack(TransactionCase):
@tagged("post_install", "-at_install")
class TestStockProductPack(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down Expand Up @@ -167,12 +168,13 @@ def test_compute_quantities_dict(self):
self.assertEqual(self.pack_dc.virtual_available, 5)
self.assertEqual(self.pack_dc.qty_available, 0)
wizard_dict = picking.button_validate()
wizard = Form(
self.env[(wizard_dict.get("res_model"))].with_context(
**wizard_dict["context"]
)
).save()
wizard.process()
if wizard_dict is not True:
wizard = Form(

Check warning on line 172 in stock_product_pack/tests/test_stock_product_pack.py

View check run for this annotation

Codecov / codecov/patch

stock_product_pack/tests/test_stock_product_pack.py#L172

Added line #L172 was not covered by tests
self.env[(wizard_dict.get("res_model"))].with_context(
**wizard_dict["context"]
)
).save()
wizard.process()

Check warning on line 177 in stock_product_pack/tests/test_stock_product_pack.py

View check run for this annotation

Codecov / codecov/patch

stock_product_pack/tests/test_stock_product_pack.py#L177

Added line #L177 was not covered by tests
self.assertEqual(self.pack_dc.virtual_available, 5)
self.assertEqual(self.pack_dc.qty_available, 5)

Expand Down
2 changes: 1 addition & 1 deletion stock_product_pack/views/product_template_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<field name="pack_modifiable" position="after">
<field
name="dont_create_move"
attrs="{'invisible':['|', ('pack_ok', '=', False), ('detailed_type', '=', 'service')]}"
invisible="not pack_ok or detailed_type == 'service'"
/>
</field>
</field>
Expand Down

0 comments on commit e370b79

Please sign in to comment.