Skip to content

Commit

Permalink
Merge PR #425 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by dreispt
  • Loading branch information
OCA-git-bot committed Jun 30, 2023
2 parents 1653682 + 346c8bd commit 094f9b7
Show file tree
Hide file tree
Showing 16 changed files with 685 additions and 0 deletions.
87 changes: 87 additions & 0 deletions product_barcode_constraint_per_company/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
======================================
Product Barcode Constraint per Company
======================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/12.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-12-0/stock-logistics-barcode-12-0-product_barcode_constraint_per_company
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/150/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extend Odoo functionnalities 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 smashing 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:%2012.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/12.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.
1 change: 1 addition & 0 deletions product_barcode_constraint_per_company/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions product_barcode_constraint_per_company/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (C) 2020-Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Product Barcode Constraint per Company",
"version": "14.0.1.0.1",
"category": "Product",
"summary": "Change the product barcode constraint"
", allowing the same barcode for differents companies",
"author": "GRAP, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-barcode",
"license": "AGPL-3",
"depends": [
"product",
],
"installable": True,
}
34 changes: 34 additions & 0 deletions product_barcode_constraint_per_company/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_barcode_constraint_per_company
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-18 14:34+0000\n"
"PO-Revision-Date: 2020-05-18 14:34+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: product_barcode_constraint_per_company
#: code:addons/product_barcode_constraint_per_company/models/product_product.py:22
#, python-format
msgid "A barcode can only be assigned to one product per company !"
msgstr ""
"Un code barre ne peut pas être assigné à deux articles de la même société !"

#. module: product_barcode_constraint_per_company
#: model:ir.model.fields,field_description:product_barcode_constraint_per_company.field_product_product__tmpl_company_id
msgid "Company of the related Template"
msgstr "Société de l'article"

#. module: product_barcode_constraint_per_company
#: model:ir.model,name:product_barcode_constraint_per_company.model_product_product
msgid "Product"
msgstr "Article"
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_barcode_constraint_per_company
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: product_barcode_constraint_per_company
#: code:addons/product_barcode_constraint_per_company/models/product_product.py:22
#, python-format
msgid "A barcode can only be assigned to one product per company !"
msgstr ""

#. module: product_barcode_constraint_per_company
#: model:ir.model.fields,field_description:product_barcode_constraint_per_company.field_product_product__tmpl_company_id
msgid "Company of the related Template"
msgstr ""

#. module: product_barcode_constraint_per_company
#: model:ir.model,name:product_barcode_constraint_per_company.model_product_product
msgid "Product"
msgstr ""

1 change: 1 addition & 0 deletions product_barcode_constraint_per_company/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_product
25 changes: 25 additions & 0 deletions product_barcode_constraint_per_company/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2020-Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import _, fields, models


class ProductProduct(models.Model):
_inherit = "product.product"

tmpl_company_id = fields.Many2one(
related="product_tmpl_id.company_id",
string="Company of the related Template",
store=True,
)

def _auto_init(self):
for i, constraint in enumerate(self._sql_constraints):
if constraint[0] == "barcode_uniq":
self._sql_constraints[i] = (
"barcode_uniq",
"unique(barcode, tmpl_company_id)",
_("A barcode can only be assigned to one product per company !"),
)
return super(ProductProduct, self)._auto_init()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Sylvain LE GAL <https://twitter.com/legalsylvain>
* Sulivan Lominchar <slominchar@archeti.com>
7 changes: 7 additions & 0 deletions product_barcode_constraint_per_company/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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.
3 changes: 3 additions & 0 deletions product_barcode_constraint_per_company/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
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``.
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 094f9b7

Please sign in to comment.