-
-
Notifications
You must be signed in to change notification settings - Fork 339
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
[14.0][ADD] product_multi_barcode_constraint_per_company: add module #546
Closed
dessanhemrayev
wants to merge
2
commits into
OCA:14.0
from
cetmix:14.0-t2944-product_multi_barcode_constraint_per_company-bridge_module
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 +1,2 @@ | ||
# See https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#oca_dependencies-txt | ||
product-attribute https://github.com/OCA/product-attribute 14.0 |
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,90 @@ | ||
====================================== | ||
Product Barcode Constraint per Company | ||
====================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:8d6ef2af9f194f45c6e87e8557700e53e2499bf8a1f4100a37a610cd4172153a | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |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/14.0/product_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-14-0/stock-logistics-barcode-14-0-product_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=14.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module extend Odoo functionalities changing the constraint of the barcode | ||
on the ``product.product`` model. | ||
|
||
With this module, two products can have the same barcode, if there don't belong | ||
to the same company. | ||
|
||
This constraint was introduced in Odoo V9.0 in [that commit](https://github.com/odoo/odoo/commit/ede1071a09902e6eeb315cf51325a03f3991b3c3), and doesn't fit with some multi companies implementation where products are not shared. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
Due to some limitation of the framework, this module has to add a new stored field | ||
``tmpl_company_id`` on the ``product.product`` model related to the ``company_id`` | ||
of the related ``product.template``. | ||
|
||
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_barcode_constraint_per_company%0Aversion:%2014.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 | ||
~~~~~~~ | ||
|
||
* GRAP | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Sylvain LE GAL <https://twitter.com/legalsylvain> | ||
* Sulivan Lominchar <slominchar@archeti.com> | ||
|
||
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/14.0/product_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,15 @@ | ||
from . import models | ||
|
||
from odoo.addons.product_barcode_constraint_per_company.tests.test_module import ( | ||
TestModule, | ||
) | ||
import unittest | ||
|
||
|
||
@unittest.skip | ||
def void(self): | ||
return | ||
|
||
|
||
TestModule.test_create_same_company = void | ||
TestModule.test_create_different_company = void |
20 changes: 20 additions & 0 deletions
20
product_multi_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,20 @@ | ||
# Copyright 2023 Cetmix OÜ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Product Multi Barcode Constraint per Company", | ||
"version": "14.0.1.0.0", | ||
"category": "Product", | ||
"summary": """This is a bridge module between "product_multi_barcode" and | ||
"product_barcode_constraint_per_company" """, | ||
"author": "Cetmix, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/stock-logistics-barcode", | ||
"maintainers": ["dessanhemrayev", "CetmixGitDrone"], | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"product_multi_barcode", | ||
"product_barcode_constraint_per_company", | ||
], | ||
"installable": True, | ||
"auto_install": True, | ||
} |
1 change: 1 addition & 0 deletions
1
product_multi_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 @@ | ||
from . import product_barcode |
21 changes: 21 additions & 0 deletions
21
product_multi_barcode_constraint_per_company/models/product_barcode.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,21 @@ | ||
# Copyright 2023 Cetmix OÜ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class ProductBarcode(models.Model): | ||
_inherit = "product.barcode" | ||
|
||
@api.constrains("name") | ||
def _check_duplicates(self): | ||
for record in self: | ||
barcodes = self.search( | ||
[("id", "!=", record.id), ("name", "=", record.name)], limit=1 | ||
) | ||
if ( | ||
barcodes | ||
and barcodes.sudo().product_tmpl_id.company_id.id | ||
== record.product_tmpl_id.company_id.id | ||
): | ||
super()._check_duplicates() |
2 changes: 2 additions & 0 deletions
2
product_multi_barcode_constraint_per_company/readme/CONTRIBUTORS.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,2 @@ | ||
* Cetmix <@cetmix.com> | ||
* Dessan Hemrayev <dessanhemrayev@gmail.com> |
1 change: 1 addition & 0 deletions
1
product_multi_barcode_constraint_per_company/readme/DESCRIPTION.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 @@ | ||
This is a bridge module between "product_barcode_constraint_per_company" and "product_multi_barcode" |
Empty file.
Binary file added
BIN
+9.23 KB
product_multi_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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a limit parameter?
barcodes = self.search([...], limit=1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll fix it now