-
-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[15.0][ADD] delivery_input_barcode_gs1
- Loading branch information
davidpalanca
committed
Aug 30, 2024
1 parent
10e79af
commit cb0514f
Showing
16 changed files
with
759 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
========================== | ||
Delivery Input Barcode GS1 | ||
========================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:3dac8f265bd93db4c2231d7849b5fec1da1f11ecf1f4e91a500d5f71311ff210 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/15.0/delivery_input_barcode_gs1 | ||
: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-15-0/stock-logistics-barcode-15-0-delivery_input_barcode_gs1 | ||
: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=15.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module builds on delivery_input_barcode, making use of the full barcode information given by a barcode/datamatrix device. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
Optionnaly you may prevent to create unknown lot if you add this code in your custom code. | ||
|
||
|
||
.. code-block:: python | ||
class StockMoveLine(models.Model): | ||
_inherit = "stock.move.line" | ||
def _create_unknown_lot(self, barcode): | ||
return False | ||
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:%20delivery_input_barcode_gs1%0Aversion:%2015.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 | ||
~~~~~~~ | ||
|
||
* Grupo | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Akretion | ||
|
||
- David BEAL | ||
|
||
* PyTech SRL <info@pytech.it>: | ||
|
||
- Alessandro Uffreduzzi <alessandro.uffreduzzi@pytech.it> | ||
|
||
* Ooops404 <info@ooops404.com>: | ||
|
||
- Francesco Foresti <francesco.foresti@ooops404.com> | ||
|
||
* Grupo Isonor <https://www.grupoisonor.es> | ||
|
||
- David Palanca | ||
|
||
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. | ||
|
||
.. |maintainer-neitherkx| image:: https://github.com/neitherkx.png?size=40px | ||
:target: https://github.com/neitherkx | ||
:alt: neitherkx | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-neitherkx| | ||
|
||
This module is part of the `OCA/stock-logistics-barcode <https://github.com/OCA/stock-logistics-barcode/tree/15.0/delivery_input_barcode_gs1>`_ 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 @@ | ||
from . import models |
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,22 @@ | ||
# Copyright (C) 2022 Akretion | ||
# Copyright (C) 2024 Grupo Isonor | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
{ | ||
"name": "Delivery Input Barcode GS1", | ||
"version": "15.0.1.0.0", | ||
"category": "Tools", | ||
"website": "https://github.com/OCA/stock-logistics-barcode", | ||
"author": "Grupo, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"summary": "Add Move line with barcode using GS1 barcodes", | ||
"maintainers": ["neitherkx"], | ||
"depends": [ | ||
"base_gs1_barcode", | ||
"delivery_input_barcode", | ||
"product_expiry", | ||
], | ||
"data": [], | ||
"demo": [], | ||
} |
27 changes: 27 additions & 0 deletions
27
delivery_input_barcode_gs1/i18n/delivery_input_barcode_gs1.pot
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,27 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * delivery_input_barcode_gs1 | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 15.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-08-22 09:33+0000\n" | ||
"PO-Revision-Date: 2024-08-22 09:33+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: delivery_input_barcode_gs1 | ||
#: code:addons/delivery_input_barcode_gs1/models/product_barcode_line_mixin.py:0 | ||
#, python-format | ||
msgid "Decoded barcode %s doesn't include a valid segment for GTIN" | ||
msgstr "" | ||
|
||
#. module: delivery_input_barcode_gs1 | ||
#: model:ir.model,name:delivery_input_barcode_gs1.model_product_barcode_line_mixin | ||
msgid "Utilities for any model to deal with product_id field" | ||
msgstr "" |
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 stock_move |
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,58 @@ | ||
# copyright 2022 David BEAL @ Akretion | ||
# copyright 2024 David Palanca @ Grupo Isonor | ||
from odoo import _, api, models | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class StockMove(models.Model): | ||
_inherit = "stock.move" | ||
|
||
@api.model | ||
def _decode_barcode(self, raw_barcode): | ||
""" | ||
res => | ||
{ | ||
"01": "03400933816759", # GTIN | ||
"17": "2014-05-31", # expiry date | ||
"10": "B04059A", # lot number | ||
"310": 0.06385, # weight | ||
"15": "2014-05-01", # delivery date | ||
} | ||
""" | ||
raw_barcode, barcode_dict = super()._decode_barcode(raw_barcode) | ||
barcode_dict = self.env["gs1_barcode"].decode(raw_barcode) | ||
if not barcode_dict.get("01"): | ||
raise UserError( | ||
_("Decoded barcode %s doesn't include a valid segment for GTIN") | ||
% barcode_dict | ||
) | ||
return barcode_dict["01"], barcode_dict | ||
|
||
def _populate_vals(self, product, barcode_dict): | ||
vals = super()._populate_vals(product, barcode_dict) | ||
if barcode_dict.get("10") and "lot_id" in self._fields: | ||
lot = self.env["stock.production.lot"].search( | ||
[("name", "=", barcode_dict["10"]), ("product_id", "=", product.id)] | ||
) | ||
if not lot: | ||
lot = self._create_unknown_lot(barcode_dict, product) | ||
if lot: | ||
# _create_unknown_lot may be overriden to not return lot | ||
vals["lot_id"] = lot.id | ||
return vals | ||
|
||
def _create_unknown_lot(self, barcode_dict, product): | ||
"""Inherit to implement your own scenario creation | ||
i.e. | ||
raise UserError(_("No lot found matching this barcode %s" % barcode)) | ||
or | ||
return False | ||
""" | ||
company_id = self.env.context.get("company_id") or self.env.company.id | ||
lot_vals = { | ||
"name": barcode_dict["10"], | ||
"expiration_date": barcode_dict["17"], | ||
"product_id": product.id, | ||
"company_id": company_id, | ||
} | ||
return self.env["stock.production.lot"].create(lot_vals) |
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,10 @@ | ||
Optionnaly you may prevent to create unknown lot if you add this code in your custom code. | ||
|
||
|
||
.. code-block:: python | ||
class StockMoveLine(models.Model): | ||
_inherit = "stock.move.line" | ||
def _create_unknown_lot(self, barcode): | ||
return False |
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 @@ | ||
* Akretion | ||
|
||
- David BEAL | ||
|
||
* PyTech SRL <info@pytech.it>: | ||
|
||
- Alessandro Uffreduzzi <alessandro.uffreduzzi@pytech.it> | ||
|
||
* Ooops404 <info@ooops404.com>: | ||
|
||
- Francesco Foresti <francesco.foresti@ooops404.com> | ||
|
||
* Grupo Isonor <https://www.grupoisonor.es> | ||
|
||
- David Palanca |
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 module builds on delivery_input_barcode, making use of the full barcode information given by a barcode/datamatrix device. |
Oops, something went wrong.