-
-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
davidpalanca
committed
Aug 30, 2024
1 parent
10e79af
commit e036f3a
Showing
18 changed files
with
853 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,117 @@ | ||
====================== | ||
Delivery Input Barcode | ||
====================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:71fd994c29909371d4b04dc883a6b534d8d7fea84c08e3df2e631bbb4585f0f3 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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 | ||
: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 | ||
: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| | ||
|
||
Create a stock move line, finding the product using a barcode scanner | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
No specific configuration necessary | ||
|
||
Usage | ||
===== | ||
|
||
#. Navigate to a Stock Picking. | ||
#. Press the button in the header with the QR Code icon | ||
#. Use a barcode scanner to scan a barcode. | ||
|
||
If a product is found using the barcode, | ||
a new line with that product will be added to the Stock Picking. | ||
|
||
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%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 Isonor | ||
|
||
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> | ||
|
||
* Cetmix <https://cetmix.com> | ||
|
||
- Dessan Hemrayev <dessanhemrayev@mail.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>`_ 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,23 @@ | ||
# 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", | ||
"version": "15.0.1.0.0", | ||
"category": "Tools", | ||
"website": "https://github.com/OCA/stock-logistics-barcode", | ||
"author": "Grupo Isonor, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"summary": "Add Move line with barcode", | ||
"maintainers": ["neitherkx"], | ||
"depends": [ | ||
"stock", | ||
"barcode_action", | ||
], | ||
"data": [ | ||
"views/stock.xml", | ||
], | ||
"demo": [], | ||
} |
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,55 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * delivery_input_barcode | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 15.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-08-30 07:39+0000\n" | ||
"PO-Revision-Date: 2024-08-30 07:39+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 | ||
#: model:ir.actions.act_window,name:delivery_input_barcode.action_move_barcode | ||
msgid "Input Product" | ||
msgstr "" | ||
|
||
#. module: delivery_input_barcode | ||
#: model_terms:ir.ui.view,arch_db:delivery_input_barcode.view_picking_form | ||
msgid "Input product lines scanning barcodes" | ||
msgstr "" | ||
|
||
#. module: delivery_input_barcode | ||
#: code:addons/delivery_input_barcode/models/product_barcode_line_mixin.py:0 | ||
#, python-format | ||
msgid "No product found matching this barcode %s" | ||
msgstr "" | ||
|
||
#. module: delivery_input_barcode | ||
#: model:ir.model,name:delivery_input_barcode.model_stock_move | ||
msgid "Stock Move" | ||
msgstr "" | ||
|
||
#. module: delivery_input_barcode | ||
#: code:addons/delivery_input_barcode/models/product_barcode_line_mixin.py:0 | ||
#, python-format | ||
msgid "" | ||
"These products %s share the same barcode.\n" | ||
"Impossible to guess which one to choose." | ||
msgstr "" | ||
|
||
#. module: delivery_input_barcode | ||
#: model:ir.model,name:delivery_input_barcode.model_stock_picking | ||
msgid "Transfer" | ||
msgstr "" | ||
|
||
#. module: delivery_input_barcode | ||
#: model:ir.model,name:delivery_input_barcode.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,2 @@ | ||
from . import product_barcode_line_mixin | ||
from . import stock_picking |
59 changes: 59 additions & 0 deletions
59
delivery_input_barcode/models/product_barcode_line_mixin.py
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,59 @@ | ||
# copyright 2022 David BEAL @ Akretion | ||
# copyright 2024 David Palanca @ Grupo Isonor | ||
|
||
from odoo import _, api, models | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class ProductLineMixin(models.AbstractModel): | ||
"""This mixin may be moved in another module to be used in mixed use cases""" | ||
|
||
_name = "product.barcode.line.mixin" | ||
_description = "Utilities for any model to deal with product_id field" | ||
|
||
@api.model | ||
def _decode_barcode(self, raw_barcode): | ||
""" | ||
Return the barcode as a simple string, | ||
and optionally a dictionary containing more info | ||
deduced from the barcode itself. | ||
Hook for customizations, see delivery_input_barcode_gs1 | ||
""" | ||
return raw_barcode, None | ||
|
||
def _populate_vals(self, product, barcode_dict): | ||
""" | ||
Builds a dictionary to use in the `create` function | ||
Hook for customizations | ||
""" | ||
vals = {"product_id": product.id, "name": product.name, "product_uom":product.uom_id.id} | ||
if "picking_id" in self._fields: | ||
vals["picking_id"] = self.env.context.get("picking_id") | ||
if "company_id" in self._fields: | ||
vals["company_id"] = self.env.context.get("company_id") | ||
if "location_id" in self._fields: | ||
vals["location_id"] = self.env.context.get("location_id") | ||
if "location_dest_id" in self._fields: | ||
vals["location_dest_id"] = self.env.context.get("location_dest_id") | ||
return vals | ||
|
||
def _process_barcode_on_product_line(self, raw_barcode): | ||
barcode_str, barcode_dict = self._decode_barcode(raw_barcode) | ||
product = self.env["product.product"].search([("barcode", "=", barcode_str)]) | ||
if product: | ||
if len(product) > 1: | ||
raise UserError( | ||
_( | ||
"These products %s share the same barcode.\n" | ||
"Impossible to guess which one to choose." | ||
% [(x.display_name for x in product)] | ||
) | ||
) | ||
else: | ||
raise UserError( | ||
_("No product found matching this barcode %s" % barcode_str) | ||
) | ||
|
||
vals = self._populate_vals(product, barcode_dict) | ||
self.create(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,23 @@ | ||
# copyright 2022 David BEAL @ Akretion | ||
# copyright 2024 David Palanca @ Grupo Isonor | ||
|
||
from odoo import models | ||
|
||
|
||
class StockMoveLine(models.Model): | ||
_name = "stock.move" | ||
_inherit = ["stock.move", "product.barcode.line.mixin"] | ||
|
||
|
||
class StockPicking(models.Model): | ||
_inherit = "stock.picking" | ||
|
||
def action_move_barcode(self, barcode): | ||
"""Create a move line according barcode information""" | ||
self.ensure_one() | ||
self.env["stock.move"].with_context( | ||
picking_id=self.id, | ||
company_id=self.company_id.id, | ||
location_id=self.location_id.id, | ||
location_dest_id=self.location_dest_id.id, | ||
)._process_barcode_on_product_line(barcode) |
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 @@ | ||
No specific configuration necessary |
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,19 @@ | ||
* Akretion | ||
|
||
- David BEAL | ||
|
||
* PyTech SRL <info@pytech.it>: | ||
|
||
- Alessandro Uffreduzzi <alessandro.uffreduzzi@pytech.it> | ||
|
||
* Ooops404 <info@ooops404.com>: | ||
|
||
- Francesco Foresti <francesco.foresti@ooops404.com> | ||
|
||
* Cetmix <https://cetmix.com> | ||
|
||
- Dessan Hemrayev <dessanhemrayev@mail.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 @@ | ||
Create a stock move line, finding the product using a barcode scanner |
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,6 @@ | ||
#. Navigate to a Stock Picking. | ||
#. Press the button in the header with the QR Code icon | ||
#. Use a barcode scanner to scan a barcode. | ||
|
||
If a product is found using the barcode, | ||
a new line with that product will be added to the Stock Picking. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.