Skip to content

Commit 91cce2a

Browse files
author
Michael Michot
committed
[ADD] New module to allow picking based on multi_barcode
1 parent 2ac1c41 commit 91cce2a

File tree

9 files changed

+137
-0
lines changed

9 files changed

+137
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../shopfloor_mobile_multi_barcode
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import actions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2020 Pharmasimple (https://www.pharmasimple.be)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
{
4+
"name": "Shopfloor multi barcode",
5+
"category": "Warehouse Management",
6+
"summary": "Batch picking with multi barcode on products",
7+
"version": "14.0.1.0.0",
8+
"author": "Pharmasimple",
9+
"license": "AGPL-3",
10+
"website": "https://github.com/akretion/phs-addons",
11+
"depends": [
12+
"shopfloor_mobile",
13+
"product_multi_barcode",
14+
],
15+
"data": ["templates/assets.xml"],
16+
"installable": True,
17+
"application": False,
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import data
2+
from . import schema
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2020 Camptocamp SA (http://www.pharmasimple.com)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
from odoo.addons.component.core import Component
4+
from odoo.addons.shopfloor_base.utils import ensure_model
5+
6+
7+
class DataAction(Component):
8+
_inherit = "shopfloor.data.action"
9+
10+
@ensure_model("product.barcodes")
11+
def barcodes(self, record, **kw):
12+
return self._jsonify(record, self._barcodes_parser, **kw)
13+
14+
def barcodes_list(self, record, **kw):
15+
return self.barcodes(record, multi=True)
16+
17+
@property
18+
def _barcodes_parser(self):
19+
return [
20+
"id",
21+
"name",
22+
]
23+
24+
@property
25+
def _product_parser(self):
26+
pp = super(DataAction, self)._product_parser
27+
pp.append(("barcode_ids:barcodes", self._product_barcodes))
28+
return pp
29+
30+
def _product_barcodes(self, rec, field):
31+
return self._jsonify(
32+
rec.barcode_ids,
33+
self._barcodes_parser,
34+
multi=True,
35+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2020 Camptocamp SA (http://www.pharmasimple.com)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
from odoo.addons.component.core import Component
4+
5+
6+
class ShopfloorSchemaAction(Component):
7+
_inherit = "shopfloor.schema.action"
8+
9+
def product(self):
10+
p = super(ShopfloorSchemaAction, self).product()
11+
p.update(
12+
{
13+
"barcodes": self._schema_list_of(self.barcodes()),
14+
}
15+
)
16+
return p
17+
18+
def barcodes(self):
19+
return {
20+
"name": {"type": "string", "nullable": False, "required": True},
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright 2020 Pharmasimple (http://www.pharmasimple.com)
3+
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
*/
5+
6+
import {process_registry} from "/shopfloor_mobile_base/static/wms/src/services/process_registry.js";
7+
8+
// Clone the original component
9+
const MultiBarcodeClusterBatchPicking = process_registry.extend(
10+
"cluster_batch_picking",
11+
{
12+
// `extend` accepts a path to the final key
13+
"methods.find_move_line": function (move_lines, barcode, filter = () => true) {
14+
let move_line;
15+
16+
move_lines.filter(filter).forEach((line) => {
17+
if (
18+
line.product.barcode === barcode ||
19+
line.product.barcodes.map(({name}) => name).includes(barcode)
20+
) {
21+
move_line = move_line !== undefined ? move_line : line;
22+
}
23+
});
24+
25+
return move_line || {};
26+
},
27+
}
28+
);
29+
30+
// Replace process component
31+
process_registry.replace("cluster_batch_picking", MultiBarcodeClusterBatchPicking);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!--
3+
Copyright 2020 Camptocamp SA (http://www.camptocamp.com)
4+
@author Simone Orsi <simahawk@gmail.com>
5+
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
6+
-->
7+
<odoo>
8+
<template
9+
id="shopfloor_app_assets"
10+
inherit_id="shopfloor_mobile.shopfloor_app_assets"
11+
>
12+
<script id="script_scenario_cluster_batch_picking" position="after">
13+
<t t-set="mod_name" t-value="'shopfloor_mobile_multi_barcode'" />
14+
<script
15+
id="script_scenario_cluster_batch_picking_multi_barcode"
16+
t-attf-src="/#{mod_name}/static/wms/src/scenario/cluster_batch_picking_multi_barcode.js?v=#{get_version(mod_name)}"
17+
type="module"
18+
/>
19+
</script>
20+
</template>
21+
22+
</odoo>

0 commit comments

Comments
 (0)