diff --git a/stock_barcodes_unique_field/README.rst b/stock_barcodes_unique_field/README.rst new file mode 100644 index 000000000..92dbe0c10 --- /dev/null +++ b/stock_barcodes_unique_field/README.rst @@ -0,0 +1,65 @@ +=========================== +Stock Barcodes Unique Field +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:fec39528a9ef877a33812cfef94e75014b7708a9fefd88d93baaa8ba3ebfa5c0 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-NuoBiT%2Fodoo--addons-lightgray.png?logo=github + :target: https://github.com/NuoBiT/odoo-addons/tree/18.0/stock_barcodes_unique_field + :alt: NuoBiT/odoo-addons + +|badge1| |badge2| |badge3| + +- This module extends the barcode options in inventory, allowing items + to be marked as unique and specifying the copy of these + characteristics to the picking header + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* NuoBiT Solutions SL + +Contributors +------------ + +- `NuoBiT `__: + + - Frank Cespedes fcespedes@nuobit.com + - Deniz Gallo dgallo@nuobit.com + +Maintainers +----------- + +This module is part of the `NuoBiT/odoo-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/stock_barcodes_unique_field/__init__.py b/stock_barcodes_unique_field/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/stock_barcodes_unique_field/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_barcodes_unique_field/__manifest__.py b/stock_barcodes_unique_field/__manifest__.py new file mode 100644 index 000000000..ea6c74a84 --- /dev/null +++ b/stock_barcodes_unique_field/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright NuoBiT Solutions - Frank Cespedes +# Copyright 2026 NuoBiT Solutions - Deniz Gallo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +{ + "name": "Stock Barcodes Unique Field", + "summary": "This module extends the barcode options in inventory," + " allowing items to be marked as unique and specifying the copy " + "of these characteristics to the picking header", + "version": "18.0.1.0.0", + "author": "NuoBiT Solutions SL", + "website": "https://github.com/NuoBiT/odoo-addons", + "category": "Stock", + "depends": ["stock_barcodes"], + "license": "AGPL-3", + "data": [ + "views/stock_barcodes_option_view.xml", + ], +} diff --git a/stock_barcodes_unique_field/i18n/es.po b/stock_barcodes_unique_field/i18n/es.po new file mode 100644 index 000000000..a1b897f87 --- /dev/null +++ b/stock_barcodes_unique_field/i18n/es.po @@ -0,0 +1,68 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_barcodes_unique +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-12-22 15:20+0000\n" +"PO-Revision-Date: 2023-12-22 15:20+0000\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: stock_barcodes_unique +#: model:ir.model.fields,field_description:stock_barcodes_unique.field_stock_barcodes_option__copy_to_header +msgid "Copy To Header" +msgstr "Copiar al Encabezado" + +#. module: stock_barcodes_unique +#: model:ir.model.fields,field_description:stock_barcodes_unique.field_stock_barcodes_option__display_name +#: model:ir.model.fields,field_description:stock_barcodes_unique.field_wiz_stock_barcodes_read_picking__display_name +msgid "Display Name" +msgstr "Nombre a mostrar" + +#. module: stock_barcodes_unique +#: model:ir.model.fields,field_description:stock_barcodes_unique.field_stock_barcodes_option____last_update +#: model:ir.model.fields,field_description:stock_barcodes_unique.field_wiz_stock_barcodes_read_picking____last_update +msgid "Last Modified on" +msgstr "Última modificación en" + +#. module: stock_barcodes_unique +#: model:ir.model,name:stock_barcodes_unique.model_stock_barcodes_option +msgid "Options for barcode interface" +msgstr "Opciones para la interfaz de código de barras" + +#. module: stock_barcodes_unique +#: code:addons/stock_barcodes_unique/models/stock_barcodes_read_picking.py:0 +#, python-format +msgid "" +"The field %s must have the same value in all the lines of the picking " +"because you have selected it as a static field in the barcode options." +msgstr "" +"El campo %s debe tener el mismo valor en todas las líneas del albarán porque " +"lo ha seleccionado como campo estático en las opciones de código de barras." + +#. module: stock_barcodes_unique +#: code:addons/stock_barcodes_unique/models/stock_barcodes_option.py:0 +#, python-format +msgid "" +"The field 'Copy to Header' can only be checked if the field 'Unique' is also" +" checked." +msgstr "" +"El campo 'Copiar al Encabezado' solo puede marcarse si el campo 'Único' " +"también está marcado." + +#. module: stock_barcodes_unique +#: model:ir.model.fields,field_description:stock_barcodes_unique.field_stock_barcodes_option__unique +msgid "Unique" +msgstr "Único" + +#. module: stock_barcodes_unique +#: model:ir.model,name:stock_barcodes_unique.model_wiz_stock_barcodes_read_picking +msgid "Wizard to read barcode on picking" +msgstr "Asistente para leer códigos de barras desde los albaranes" diff --git a/stock_barcodes_unique_field/models/__init__.py b/stock_barcodes_unique_field/models/__init__.py new file mode 100644 index 000000000..9f23d343d --- /dev/null +++ b/stock_barcodes_unique_field/models/__init__.py @@ -0,0 +1,2 @@ +from . import stock_barcodes_option +from . import stock_barcodes_read_picking diff --git a/stock_barcodes_unique_field/models/stock_barcodes_option.py b/stock_barcodes_unique_field/models/stock_barcodes_option.py new file mode 100644 index 000000000..f6851eb1e --- /dev/null +++ b/stock_barcodes_unique_field/models/stock_barcodes_option.py @@ -0,0 +1,23 @@ +# Copyright NuoBiT Solutions - Frank Cespedes +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class StockBarcodesOption(models.Model): + _inherit = "stock.barcodes.option" + + unique = fields.Boolean() + copy_to_header = fields.Boolean() + + @api.constrains("unique", "copy_to_header") + def _check_copy_to_header(self): + for rec in self: + if not rec.unique and rec.copy_to_header: + raise ValidationError( + _( + "The field 'Copy to Header' can only be checked if the " + "field 'Unique' is also checked." + ) + ) diff --git a/stock_barcodes_unique_field/models/stock_barcodes_read_picking.py b/stock_barcodes_unique_field/models/stock_barcodes_read_picking.py new file mode 100644 index 000000000..4ded8f950 --- /dev/null +++ b/stock_barcodes_unique_field/models/stock_barcodes_read_picking.py @@ -0,0 +1,33 @@ +# Copyright NuoBiT Solutions - Frank Cespedes +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import _, models +from odoo.exceptions import UserError + + +class WizStockBarcodesReadPicking(models.TransientModel): + _inherit = "wiz.stock.barcodes.read.picking" + + def action_confirm(self): + res = super().action_confirm() + option_fields = self.option_group_id.option_ids.filtered(lambda x: x.unique) + for option in option_fields: + field = option.field_name + move_line_field = self.move_line_ids[field] + if len(move_line_field) > 1: + field_label = self.fields_get([field])[field]["string"] + raise UserError( + _( + "The field %s must have the same value in all the " + "lines of the picking because you have selected it as " + "a static field in the barcode options." + ) + % field_label + ) + if move_line_field and option.copy_to_header: + if ( + field in self.picking_id + and move_line_field != self.picking_id[field] + ): + self.picking_id[field] = move_line_field + return res diff --git a/stock_barcodes_unique_field/pyproject.toml b/stock_barcodes_unique_field/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/stock_barcodes_unique_field/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/stock_barcodes_unique_field/readme/CONTRIBUTORS.md b/stock_barcodes_unique_field/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..5c653a8c2 --- /dev/null +++ b/stock_barcodes_unique_field/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [NuoBiT](https://www.nuobit.com): + - Frank Cespedes + - Deniz Gallo diff --git a/stock_barcodes_unique_field/readme/DESCRIPTION.md b/stock_barcodes_unique_field/readme/DESCRIPTION.md new file mode 100644 index 000000000..304bd8a54 --- /dev/null +++ b/stock_barcodes_unique_field/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +- This module extends the barcode options in inventory, allowing items + to be marked as unique and specifying the copy of these + characteristics to the picking header diff --git a/stock_barcodes_unique_field/static/description/icon.png b/stock_barcodes_unique_field/static/description/icon.png new file mode 100644 index 000000000..1cd641e79 Binary files /dev/null and b/stock_barcodes_unique_field/static/description/icon.png differ diff --git a/stock_barcodes_unique_field/static/description/index.html b/stock_barcodes_unique_field/static/description/index.html new file mode 100644 index 000000000..24edf01fa --- /dev/null +++ b/stock_barcodes_unique_field/static/description/index.html @@ -0,0 +1,424 @@ + + + + + +Stock Barcodes Unique Field + + + +
+

Stock Barcodes Unique Field

+ + +

Beta License: AGPL-3 NuoBiT/odoo-addons

+
    +
  • This module extends the barcode options in inventory, allowing items +to be marked as unique and specifying the copy of these +characteristics to the picking header
  • +
+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • NuoBiT Solutions SL
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the NuoBiT/odoo-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/stock_barcodes_unique_field/views/stock_barcodes_option_view.xml b/stock_barcodes_unique_field/views/stock_barcodes_option_view.xml new file mode 100644 index 000000000..f1b593f7c --- /dev/null +++ b/stock_barcodes_unique_field/views/stock_barcodes_option_view.xml @@ -0,0 +1,19 @@ + + + + + stock.barcodes.option.group.form.inherit + stock.barcodes.option.group + + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..1ca304aa6 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-stock_barcodes@git+https://github.com/OCA/stock-logistics-barcode.git@refs/pull/725/head#subdirectory=stock_barcodes