-
-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MOV] product_packaging_type_required becomes product_packaging_level…
…_required
- Loading branch information
Showing
26 changed files
with
170 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
=============================== | ||
Product Packaging Type Required | ||
=============================== | ||
================================ | ||
Product Packaging Level Required | ||
================================ | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
@@ -17,21 +17,21 @@ Product Packaging Type Required | |
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github | ||
:target: https://github.com/OCA/product-attribute/tree/18.0/product_packaging_type_required | ||
:target: https://github.com/OCA/product-attribute/tree/18.0/product_packaging_level_required | ||
:alt: OCA/product-attribute | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/product-attribute-18-0/product-attribute-18-0-product_packaging_type_required | ||
:target: https://translation.odoo-community.org/projects/product-attribute-18-0/product-attribute-18-0-product_packaging_level_required | ||
: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/product-attribute&target_branch=18.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows to mark a product packaging type as required. | ||
This module allows to mark a product packaging level as required. | ||
|
||
A cron creates the missing product packages if the related packaging | ||
type is required. | ||
level is required. | ||
|
||
**Table of contents** | ||
|
||
|
@@ -41,18 +41,18 @@ type is required. | |
Usage | ||
===== | ||
|
||
To set a packaging type as required: | ||
To set a packaging level as required: | ||
|
||
1. Go to *Sales > Configuration > Products > Product Packaging Type*. | ||
2. You can make a type required | ||
1. Go to *Inventory > Configuration > Product Packaging Level*. | ||
2. You can make a level required | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/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/product-attribute/issues/new?body=module:%20product_packaging_type_required%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
`feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_packaging_level_required%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. | ||
|
||
|
@@ -71,13 +71,14 @@ Contributors | |
|
||
- Damien Crier <[email protected]> | ||
- Simone Orsi <[email protected]> | ||
|
||
- Phuc Tran Thanh <phuc@trobz.com> | ||
- Phuc Tran Thanh <[email protected]> | ||
- Tris Doan <tridm@trobz.com> | ||
|
||
Other credits | ||
------------- | ||
|
||
The development of this module has been financially supported by: | ||
The development and migration of this module has been financially | ||
supported by: | ||
|
||
- Camptocamp | ||
|
||
|
@@ -105,6 +106,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__: | |
|
||
|maintainer-simahawk| |maintainer-dcrier| | ||
|
||
This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/18.0/product_packaging_type_required>`_ project on GitHub. | ||
This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/18.0/product_packaging_level_required>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import product_packaging_level |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
3 changes: 2 additions & 1 deletion
3
...ging_type_required/readme/CONTRIBUTORS.md → ...ing_level_required/readme/CONTRIBUTORS.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
- [Camptocamp](https://www.camptocamp.com) | ||
- Damien Crier \<<[email protected]>\> | ||
- Simone Orsi \<<[email protected]>\> | ||
- Phuc Tran Thanh \<<[email protected]>\> | ||
- Phuc Tran Thanh \<<[email protected]>\> | ||
- Tris Doan \<<[email protected]>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The development and migration of this module has been financially supported by: | ||
|
||
- Camptocamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This module allows to mark a product packaging level as required. | ||
|
||
A cron creates the missing product packages if the related packaging | ||
level is required. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
To set a packaging level as required: | ||
1. Go to *Inventory \> Configuration \> Product Packaging | ||
Level*. | ||
2. You can make a level required |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
74 changes: 74 additions & 0 deletions
74
product_packaging_level_required/tests/test_packaging_required.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Copyright 2021 Camptocamp SA | ||
# @author Simone Orsi <[email protected]> | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl) | ||
from odoo.tests import common | ||
from odoo.tools.misc import mute_logger | ||
|
||
|
||
class TestPackagingLevelRequired(common.TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.product = cls.env["product.template"].create( | ||
{"name": "Product Test", "type": "consu"} | ||
) | ||
cls.default_level = cls.env.ref( | ||
"product_packaging_level.product_packaging_level_default" | ||
) | ||
cls.default_level.write({"required": True}) | ||
cls.test_level = cls.env["product.packaging.level"].create( | ||
{ | ||
"name": "Packaging Level Test", | ||
"code": "TEST2", | ||
"sequence": 2, | ||
"required": True, | ||
} | ||
) | ||
# Create packaging only for one of them | ||
cls.pkg_box = cls.env["product.packaging"].create( | ||
{ | ||
"name": "Box", | ||
"product_id": cls.product.product_variant_ids.id, | ||
"qty": 50, | ||
"packaging_level_id": cls.default_level.id, | ||
"barcode": "BOX", | ||
} | ||
) | ||
|
||
@mute_logger( | ||
"odoo.addons.product_packing_level_required.models.product_packaging_level" | ||
) | ||
def test_cron_create(self): | ||
products_count = self.env["product.product"].search_count( | ||
[("type", "=", "consu")] | ||
) | ||
count_packaging = self.env["product.packaging"].search_count | ||
domain1 = [("packaging_level_id", "=", self.test_level.id)] | ||
self.assertEqual(count_packaging(domain1), 0) | ||
|
||
domain2 = [("packaging_level_id", "=", self.default_level.id)] | ||
self.assertEqual(count_packaging(domain2), 1) | ||
|
||
res = self.env[ | ||
"product.packaging.level" | ||
].cron_check_create_required_packaging_level() | ||
# We get one required packaging per level per product | ||
self.assertEqual(count_packaging(domain1), products_count) | ||
self.assertEqual(count_packaging(domain2), products_count) | ||
# 1 was already created at the setup | ||
created_count = (products_count * 2) - 1 | ||
self.assertEqual(res, f"CREATED {created_count} required packaging") | ||
|
||
# Let's add another one | ||
self.env["product.packaging.level"].create( | ||
{ | ||
"name": "Packaging Level Test 3", | ||
"code": "TEST3", | ||
"sequence": 3, | ||
"required": True, | ||
} | ||
) | ||
res = self.env[ | ||
"product.packaging.level" | ||
].cron_check_create_required_packaging_level() | ||
self.assertEqual(res, f"CREATED {products_count} required packaging") |
Oops, something went wrong.