-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TA#57380 [ADD] stock_picking_barcode
- Loading branch information
Showing
13 changed files
with
328 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
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
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,98 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_picking_barcode | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-04-22 04:07+0000\n" | ||
"PO-Revision-Date: 2024-04-22 04:07+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_picking_barcode | ||
#: model_terms:ir.ui.view,arch_db:stock_picking_barcode.stock_picking_type_view_form_inherit | ||
msgid "Barcode" | ||
msgstr "Code-barres" | ||
|
||
#. module: stock_picking_barcode | ||
#: model:ir.model.fields,field_description:stock_picking_barcode.field_stock_picking___barcode_scanned | ||
msgid "Barcode Scanned" | ||
msgstr "Code-barres numérisé" | ||
|
||
#. module: stock_picking_barcode | ||
#: model:ir.model.fields,field_description:stock_picking_barcode.field_stock_picking__display_name | ||
#: model:ir.model.fields,field_description:stock_picking_barcode.field_stock_picking_type__display_name | ||
msgid "Display Name" | ||
msgstr "Nom d'affichage" | ||
|
||
#. module: stock_picking_barcode | ||
#: model:ir.model.fields,field_description:stock_picking_barcode.field_stock_picking__id | ||
#: model:ir.model.fields,field_description:stock_picking_barcode.field_stock_picking_type__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: stock_picking_barcode | ||
#: model:ir.model.fields,field_description:stock_picking_barcode.field_stock_picking____last_update | ||
#: model:ir.model.fields,field_description:stock_picking_barcode.field_stock_picking_type____last_update | ||
msgid "Last Modified on" | ||
msgstr "Dernière modification le" | ||
|
||
#. module: stock_picking_barcode | ||
#: model:ir.model.fields,field_description:stock_picking_barcode.field_stock_picking_type__nomenclature_id | ||
msgid "Nomenclature" | ||
msgstr "Nomenclature" | ||
|
||
#. module: stock_picking_barcode | ||
#: model:ir.model,name:stock_picking_barcode.model_stock_picking_type | ||
msgid "Picking Type" | ||
msgstr "Type de préparation" | ||
|
||
#. module: stock_picking_barcode | ||
#: model:ir.model.fields,field_description:stock_picking_barcode.field_stock_picking__scan_barcode | ||
#: model:ir.model.fields,field_description:stock_picking_barcode.field_stock_picking_type__scan_barcode | ||
msgid "Scan from this Operation Type" | ||
msgstr "Numériser depuis ce type d'opération" | ||
|
||
#. module: stock_picking_barcode | ||
#: code:addons/stock_picking_barcode/models/stock_picking.py:0 | ||
#, python-format | ||
msgid "The barcode \"%(barcode)s\" doesn't correspond to a proper product." | ||
msgstr "" | ||
|
||
#. module: stock_picking_barcode | ||
#: model:ir.model.fields,help:stock_picking_barcode.field_stock_picking_type__nomenclature_id | ||
msgid "" | ||
"This field allows you to choose the Barcodes Nomenclature\n" | ||
" to apply when scanning." | ||
msgstr "" | ||
"Ce champ vous permet de choisir la nomenclature des code-barres à appliquer lors de la numérisation." | ||
|
||
#. module: stock_picking_barcode | ||
#: model:ir.model,name:stock_picking_barcode.model_stock_picking | ||
msgid "Transfer" | ||
msgstr "Transfert" | ||
|
||
#. module: stock_picking_barcode | ||
#: model:ir.model.fields,help:stock_picking_barcode.field_stock_picking___barcode_scanned | ||
msgid "Value of the last barcode scanned." | ||
msgstr "Valeur du dernier code-barres scanné." | ||
|
||
#. module: stock_picking_barcode | ||
#: model:ir.model.fields,help:stock_picking_barcode.field_stock_picking__scan_barcode | ||
#: model:ir.model.fields,help:stock_picking_barcode.field_stock_picking_type__scan_barcode | ||
msgid "" | ||
"When this box is checked, a new “Scan” field is displayed on\n" | ||
" transfers of this type of operation to allow scanning of a barcode." | ||
msgstr "Lorsque cette case est cochée, un nouveau champ “Numériser” est affiché sur les transferts de ce type d’opération afin de permettre de numériser un code-barres." | ||
|
||
#. module: stock_picking_barcode | ||
#: code:addons/stock_picking_barcode/models/stock_picking.py:0 | ||
#, python-format | ||
msgid "Wrong barcode" | ||
msgstr "Mauvais code-barres." |
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,18 @@ | ||
Stock Picking Barcode | ||
===================== | ||
|
||
Context | ||
------- | ||
The module allows scanning a barcode by type of operation. | ||
|
||
Description | ||
----------- | ||
|
||
This module allows, when the user scans a product, to find a candidate movement line (or create one if necessary) | ||
and process it by incrementing its 'Done' field. | ||
In this case, we will use a nomenclature with a rule of type 'Weighed Item' | ||
and the barcode model should look like this: `.......{NNDDD}` | ||
|
||
Contributors | ||
------------ | ||
* Numigi (tm) and all its contributors (https://bit.ly/numigiens) |
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,4 @@ | ||
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
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,21 @@ | ||
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
{ | ||
"name": "Stock Picking Barcode", | ||
"version": "14.0.1.0.0", | ||
"author": "Numigi", | ||
"maintainer": "Numigi", | ||
"website": "https://bit.ly/numigi-com", | ||
"license": "LGPL-3", | ||
"category": "Product", | ||
"summary": "Scan a barcode by picking", | ||
"depends": ["stock", "barcodes"], | ||
"data": [ | ||
"data/picking_barcodes_data.xml", | ||
"views/stock_picking_view.xml", | ||
"views/stock_picking_type_view.xml", | ||
], | ||
"installable": True, | ||
"application": 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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo noupdate="1"> | ||
<record id="picking_barcode_nomenclature" model="barcode.nomenclature"> | ||
<field name="name">Operations/ Detailed Operations</field> | ||
</record> | ||
|
||
<record id="barcode_rule_picking_product_weight" model="barcode.rule"> | ||
<field name="name">Product Weight</field> | ||
<field name="barcode_nomenclature_id" ref="picking_barcode_nomenclature"/> | ||
<field name="sequence">10</field> | ||
<field name="type">weight</field> | ||
<field name="encoding">any</field> | ||
<field name="pattern">.....{NNNDD}</field> | ||
</record> | ||
</odoo> |
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,5 @@ | ||
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import stock_picking | ||
from . import stock_picking_type | ||
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,96 @@ | ||
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
from odoo import models, fields, _ | ||
|
||
|
||
class StockPicking(models.Model): | ||
_name = "stock.picking" | ||
_inherit = ["stock.picking", "barcodes.barcode_events_mixin"] | ||
|
||
scan_barcode = fields.Boolean( | ||
string="Scan from this Operation Type", | ||
related="picking_type_id.scan_barcode" | ||
) | ||
|
||
def on_barcode_scanned(self, barcode): | ||
if not self.scan_barcode or not self.picking_type_id.nomenclature_id: | ||
return | ||
else: | ||
parsed_result = self.picking_type_id.nomenclature_id.parse_barcode(barcode) | ||
if parsed_result["type"] in ["weight", "product"]: | ||
if parsed_result["type"] == "weight": | ||
product_barcode = parsed_result["base_code"] | ||
qty = parsed_result["value"] | ||
else: # product | ||
product_barcode = parsed_result["code"] | ||
qty = 1.0 | ||
product = self.env["product.product"].search( | ||
[ | ||
"|", | ||
("barcode", "=", product_barcode), | ||
("default_code", "=", product_barcode), | ||
], | ||
limit=1, | ||
) | ||
if product: | ||
if self._check_product(product, qty): | ||
return | ||
return { | ||
"warning": { | ||
"title": _("Wrong barcode"), | ||
"message": _( | ||
'The barcode "%(barcode)s" doesn\'t correspond to a proper product.' | ||
) | ||
% {"barcode": barcode}, | ||
} | ||
} | ||
|
||
def _check_product(self, product, qty=1.0): | ||
""" This method is called when the user scans a product. Its goal | ||
is to find a candidate move line (or create one, if necessary) | ||
and process it by incrementing its `qty_done` field with the | ||
`qty` parameter. | ||
""" | ||
# Get back the move line to increase. If multiple are found, chose | ||
# arbitrary the first one that doesn't have qty_done set. | ||
# Filter out the ones processed by `_check_location` and the ones already | ||
# having a # destination package. | ||
picking_move_lines = self.move_line_ids_without_package | ||
if not self.show_reserved: | ||
picking_move_lines = self.move_line_nosuggest_ids | ||
|
||
corresponding_ml = picking_move_lines.filtered( | ||
lambda ml: ml.product_id.id == product.id | ||
and not ml.result_package_id | ||
and not ml.lots_visible | ||
and not ml.qty_done | ||
)[:1] | ||
if corresponding_ml: | ||
corresponding_ml.qty_done += qty | ||
else: | ||
# If a candidate is not found, we create one here. If the move | ||
# line we add here is linked to a tracked product, we don't | ||
# set a `qty_done`: a next scan of this product will open the | ||
# lots wizard. | ||
picking_type_lots = ( | ||
self.picking_type_id.use_create_lots | ||
or self.picking_type_id.use_existing_lots | ||
) | ||
new_move_line = self.move_line_ids.new( | ||
{ | ||
"product_id": product.id, | ||
"product_uom_id": product.uom_id.id, | ||
"location_id": self.location_id.id, | ||
"location_dest_id": self.location_dest_id.id, | ||
"qty_done": (product.tracking == "none" and picking_type_lots) | ||
and qty | ||
or 0.0, | ||
"product_uom_qty": 0.0, | ||
"date": fields.datetime.now(), | ||
} | ||
) | ||
if self.show_reserved: | ||
self.move_line_ids_without_package += new_move_line | ||
else: | ||
self.move_line_nosuggest_ids += new_move_line | ||
return True |
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,26 @@ | ||
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
from odoo import models, fields | ||
|
||
|
||
class StockPickingType(models.Model): | ||
_inherit = "stock.picking.type" | ||
|
||
def _get_default_nomenclature(self): | ||
return self.env.ref( | ||
"stock_picking_barcode.picking_barcode_nomenclature", | ||
raise_if_not_found=False | ||
) | ||
|
||
scan_barcode = fields.Boolean( | ||
string="Scan from this Operation Type", | ||
help="""When this box is checked, a new “Scan” field is displayed on | ||
transfers of this type of operation to allow scanning of a barcode.""", | ||
) | ||
nomenclature_id = fields.Many2one( | ||
"barcode.nomenclature", | ||
string="Nomenclature", | ||
default=_get_default_nomenclature, | ||
help="""This field allows you to choose the Barcodes Nomenclature | ||
to apply when scanning.""", | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
|
||
<record id="stock_picking_type_view_form_inherit" model="ir.ui.view"> | ||
<field name="name">Stock Picking Type Form: Scan Barcode</field> | ||
<field name="model">stock.picking.type</field> | ||
<field name="inherit_id" ref="stock.view_picking_type_form"/> | ||
<field name="arch" type="xml"> | ||
<sheet position="inside"> | ||
<group> | ||
<group name="barcode" string="Barcode"> | ||
<field name="scan_barcode"/> | ||
<field | ||
name="nomenclature_id" | ||
attrs="{'invisible': [('scan_barcode', '!=', True)], 'required': [('scan_barcode', '=', True)]}" | ||
/> | ||
</group> | ||
</group> | ||
</sheet> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
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,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
|
||
<record id="stock_picking_view_form_inherit_stock_barcode" model="ir.ui.view"> | ||
<field name="name">Stock Picking Form: Barcode</field> | ||
<field name="model">stock.picking</field> | ||
<field name="inherit_id" ref="stock.view_picking_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="owner_id" position="after"> | ||
<field name="scan_barcode" invisible="1"/> | ||
<field | ||
name="_barcode_scanned" | ||
widget="picking_barcode_handler" | ||
attrs="{'invisible': [('scan_barcode', '!=', True)]}" | ||
/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |