-
-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[16.0][ADD] product_packaging_barcode_constraint_per_company
Update product_packaging_barcode_constraint_per_company/models/product_product.py Co-authored-by: Denis Roussel (ACSONE) <[email protected]> wip
- Loading branch information
Showing
14 changed files
with
651 additions
and
0 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
product_packaging_barcode_constraint_per_company/README.rst
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,80 @@ | ||
================================================ | ||
Product Packaging Barcode Constraint Per Company | ||
================================================ | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:9db849a6ca54b3de4fdd8666d4d7a95c47bd4fb0eb284d837c7ff713dae5c7a0 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--barcode-lightgray.png?logo=github | ||
:target: https://github.com/OCA/stock-logistics-barcode/tree/16.0/product_packaging_barcode_constraint_per_company | ||
:alt: OCA/stock-logistics-barcode | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/stock-logistics-barcode-16-0/stock-logistics-barcode-16-0-product_packaging_barcode_constraint_per_company | ||
: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-barcode&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module makes the product packaging barcode's unique constraint | ||
local to its company. | ||
|
||
Its behaviour mimics the one found in | ||
product_barcode_constraint_per_company. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-barcode/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-barcode/issues/new?body=module:%20product_packaging_barcode_constraint_per_company%0Aversion:%2016.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. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* Akretion | ||
|
||
Contributors | ||
------------ | ||
|
||
- Kevin Khao [email protected] | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
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-barcode <https://github.com/OCA/stock-logistics-barcode/tree/16.0/product_packaging_barcode_constraint_per_company>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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 models |
16 changes: 16 additions & 0 deletions
16
product_packaging_barcode_constraint_per_company/__manifest__.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,16 @@ | ||
# Copyright 2024 Akretion | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Product Packaging Barcode Constraint Per Company", | ||
"summary": """ | ||
Make packaging barcode constraint per company""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Akretion,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/stock-logistics-barcode", | ||
"depends": ["product"], | ||
"mainainers": ["kevinkhao", "bealdav"], | ||
"data": [], | ||
"demo": [], | ||
} |
2 changes: 2 additions & 0 deletions
2
product_packaging_barcode_constraint_per_company/models/__init__.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,2 @@ | ||
from . import product_packaging | ||
from . import product_product |
24 changes: 24 additions & 0 deletions
24
product_packaging_barcode_constraint_per_company/models/product_packaging.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,24 @@ | ||
# Copyright 2024 Akretion | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class ProductPackaging(models.Model): | ||
_inherit = "product.packaging" | ||
|
||
# replace the unique SQL constraint | ||
_sql_constraints = [ | ||
( | ||
"barcode_uniq", | ||
"unique(barcode, company_id)", | ||
"A barcode can only be assigned to one packaging per company.", | ||
), | ||
] | ||
|
||
@api.constrains("barcode") | ||
def _check_barcode_uniqueness(self): | ||
return super( | ||
ProductPackaging, | ||
self.with_context(search_only_in_pkg_company=self.company_id.ids), | ||
)._check_barcode_uniqueness() |
18 changes: 18 additions & 0 deletions
18
product_packaging_barcode_constraint_per_company/models/product_product.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,18 @@ | ||
# Copyright 2024 Akretion | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class ProductProduct(models.Model): | ||
|
||
_inherit = "product.product" | ||
|
||
@api.model | ||
def _search(self, domain, *args, **kwargs): | ||
company_ids = self.env.context.get("search_only_in_pkg_company") | ||
if company_ids: | ||
if len(company_ids) > 0: # Only filter if the source products have company | ||
company_ids.append(False) # Also include products without company | ||
domain.append(("company_id", "in", company_ids)) | ||
return super()._search(domain, *args, **kwargs) |
1 change: 1 addition & 0 deletions
1
product_packaging_barcode_constraint_per_company/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 |
---|---|---|
@@ -0,0 +1 @@ | ||
* Kevin Khao <[email protected]> |
4 changes: 4 additions & 0 deletions
4
product_packaging_barcode_constraint_per_company/readme/DESCRIPTION.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This module makes the product packaging barcode's unique constraint | ||
local to its company. | ||
|
||
Its behaviour mimics the one found in product_barcode_constraint_per_company. |
Binary file added
BIN
+9.23 KB
product_packaging_barcode_constraint_per_company/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.