Skip to content

Commit

Permalink
[ADD] product_multi_barcode_constraint_per_company
Browse files Browse the repository at this point in the history
  • Loading branch information
dessanhemrayev committed Oct 29, 2023
1 parent ea2cf9d commit 4951551
Show file tree
Hide file tree
Showing 14 changed files with 645 additions and 0 deletions.
1 change: 1 addition & 0 deletions oca_dependencies.txt
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
90 changes: 90 additions & 0 deletions product_multi_barcode_constraint_per_company/README.rst
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.
14 changes: 14 additions & 0 deletions product_multi_barcode_constraint_per_company/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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
19 changes: 19 additions & 0 deletions product_multi_barcode_constraint_per_company/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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",
"license": "AGPL-3",
"depends": [
"product_multi_barcode",
"product_barcode_constraint_per_company",
],
"installable": True,
"auto_install": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_barcode
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)]
)
if (
barcodes
and barcodes[0].sudo().product_tmpl_id.company_id.id
== record.product_tmpl_id.company_id.id
):
super()._check_duplicates()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Cetmix <@cetmix.com>
* Dessan Hemrayev <dessanhemrayev@gmail.com>
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"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4951551

Please sign in to comment.