Skip to content

Commit

Permalink
Merge PR #563 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by gurneyalex
  • Loading branch information
OCA-git-bot committed Jul 8, 2024
2 parents dc665de + 650e410 commit 8c444b1
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
2 changes: 1 addition & 1 deletion product_packaging_multi_barcode/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Multiple barcodes on product packagings
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:969fc5bba77714cb1387b4633459551ad5aee94fb1e43e14257f94bfe8671ae6
!! source digest: sha256:3430ba45a525fae02479d830675069016047347d52b5700fd8da37fb9cbcb2b5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
3 changes: 2 additions & 1 deletion product_packaging_multi_barcode/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
"license": "AGPL-3",
"author": "Camptocamp, Odoo Community Association (OCA)",
"category": "Product Management",
"depends": ["product_multi_barcode"],
"depends": ["product_multi_barcode", "product_multi_barcode_stock_menu"],
"website": "https://github.com/OCA/stock-logistics-barcode",
"data": [
"views/product_packaging_view.xml",
"views/product_template_view.xml",
"views/barcode_view.xml",
],
"installable": True,
"post_init_hook": "post_init_hook",
Expand Down
25 changes: 25 additions & 0 deletions product_packaging_multi_barcode/models/product_barcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,31 @@ class ProductBarcode(models.Model):
ondelete="cascade",
)

display_product_id = fields.Many2one(
string="Display Product",
comodel_name="product.product",
compute="_compute_display_product",
store=True,
readonly=False,
ondelete="cascade",
)

@api.depends("product_id", "packaging_id")
def _compute_display_product(self):
for rec in self:
rec.display_product_id = rec.product_id or rec.packaging_id.product_id

@api.constrains("packaging_id", "product_id")
def _check_not_define_product_and_packaging(self):
for record in self:
if record.packaging_id and record.product_id:
raise ValidationError(
_(
"A packaging already uses the barcode or the barcode "
"is already assigned to product(s)"
)
)

@api.constrains("name")
def _check_duplicates(self):
"""Override this method to change the error messages"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Multiple barcodes on product packagings</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:969fc5bba77714cb1387b4633459551ad5aee94fb1e43e14257f94bfe8671ae6
!! source digest: sha256:3430ba45a525fae02479d830675069016047347d52b5700fd8da37fb9cbcb2b5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/stock-logistics-barcode/tree/16.0/product_packaging_multi_barcode"><img alt="OCA/stock-logistics-barcode" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--barcode-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-barcode-16-0/stock-logistics-barcode-16-0-product_packaging_multi_barcode"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-barcode&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows you to define multiple barcodes on product packagings.</p>
Expand Down
34 changes: 34 additions & 0 deletions product_packaging_multi_barcode/views/barcode_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="product_barcode_list_view_inherit" model="ir.ui.view">
<field name="name">product.barcode.list.inherit</field>
<field name="model">product.barcode</field>
<field
name="inherit_id"
ref="product_multi_barcode_stock_menu.product_barcode_list_view"
/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="display_product_id" />
</xpath>
<xpath expr="//field[@name='product_id']" position="attributes">
<attribute name="optional">hide</attribute>
</xpath>
</field>
</record>

<record id="product_barcode_view_search" model="ir.ui.view">
<field name="model">product.barcode</field>
<field name="arch" type="xml">
<search>
<field name="display_product_id" />
<filter
string="display product"
name="display_product_id"
context="{'group_by': 'display_product_id'}"
/>
</search>
</field>
</record>
</odoo>

0 comments on commit 8c444b1

Please sign in to comment.