Skip to content

Commit

Permalink
[MIG] stock_barcodes: more migrating
Browse files Browse the repository at this point in the history
  • Loading branch information
FranzPoize committed May 8, 2024
1 parent 52aa7ce commit 3828828
Show file tree
Hide file tree
Showing 14 changed files with 207 additions and 132 deletions.
2 changes: 1 addition & 1 deletion stock_barcodes/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Stock Barcodes
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9d6c1f593b8fd9742b10d5eb279604dc97496ef1505c5673b29182fba1846342
!! source digest: sha256:a37c70e8ee5fdc272f67d2b22656d3ba8338a556c2997169a90f3c6fd0afde36
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
9 changes: 1 addition & 8 deletions stock_barcodes/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@
],
"assets": {
"web.assets_backend": [
"/stock_barcodes/static/src/utils/barcodes_models_utils.esm.js",
"/stock_barcodes/static/src/views/kanban_renderer.esm.js",
"/stock_barcodes/static/src/views/views.esm.js",
"/stock_barcodes/static/src/views/form_view.esm.js",
"/stock_barcodes/static/src/views/view_compiler.esm.js",
"/stock_barcodes/static/src/widgets/boolean_toggle.esm.js",
"/stock_barcodes/static/src/widgets/numeric_step.esm.js",
"/stock_barcodes/static/src/widgets/view_button.esm.js",
"stock_barcodes/static/src/**/*.js",
"/stock_barcodes/static/src/widgets/view_button.xml",
"/stock_barcodes/static/src/css/stock.scss",
],
Expand Down
2 changes: 1 addition & 1 deletion stock_barcodes/data/stock_barcodes_option.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<field name="barcode_guided_mode">guided</field>
<field name="show_pending_moves">True</field>
<field name="confirmed_moves">True</field>
<field name="source_pending_moves">move_lines</field>
<field name="source_pending_moves">move_ids</field>
<field name="fill_fields_from_lot">True</field>
</record>
<record
Expand Down
18 changes: 17 additions & 1 deletion stock_barcodes/models/stock_barcodes_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class StockBarcodesOptionGroup(models.Model):
string="Show pending moves", help="Shows a list of movements to process"
)
source_pending_moves = fields.Selection(
[("move_line_ids", "Detailed operations"), ("move_lines", "Operations")],
[("move_line_ids", "Detailed operations"), ("move_ids", "Operations")],
default="move_line_ids",
help="Origin of the data to generate the movements to process",
)
Expand Down Expand Up @@ -103,6 +103,22 @@ class StockBarcodesOptionGroup(models.Model):
("location_dest_id", "Destination Location"),
]
)
scan_product_one_by_one = fields.Boolean(
help="Will set the product quantity to one and complete the line",
string="Scan product one by one",
)
forbid_same_source_and_dest = fields.Boolean(
help="Won't allow picking validation if source and dest is the same",
string="Forbid same source and dest",
)
do_not_check_demand = fields.Boolean(
help="Will not warn if the quantity done is higher than demand",
string="Do not check demand",
)
update_all_dest_on_dest_update = fields.Boolean(
help="Update all destination of pending move and move_lines on destination update",
string="Update destination on all operation",
)

def get_option_value(self, field_name, attribute):
option = self.option_ids.filtered(lambda op: op.field_name == field_name)[:1]
Expand Down
2 changes: 1 addition & 1 deletion stock_barcodes/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _barcodes_process_line_to_unlink(self):

def action_barcode_detailed_operation_unlink(self):
for sml in self:
if sml.product_uom_qty:
if sml.reserved_qty:
sml._barcodes_process_line_to_unlink()

Check warning on line 32 in stock_barcodes/models/stock_move_line.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/models/stock_move_line.py#L32

Added line #L32 was not covered by tests
else:
sml.unlink()

Check warning on line 34 in stock_barcodes/models/stock_move_line.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/models/stock_move_line.py#L34

Added line #L34 was not covered by tests
Expand Down
2 changes: 1 addition & 1 deletion stock_barcodes/models/stock_picking_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def action_barcode_scan(self):
wiz.determine_todo_action()
wiz.fill_pending_moves()
action = self.env["ir.actions.actions"]._for_xml_id(
"stock_barcodes.action_stock_barcodes_read_picking"
"stock_barcodes.action_stock_barcodes_read_picking_type"
)
action["res_id"] = wiz.id
return action
Expand Down
13 changes: 8 additions & 5 deletions stock_barcodes/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +276,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +302,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -367,7 +368,7 @@ <h1 class="title">Stock Barcodes</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9d6c1f593b8fd9742b10d5eb279604dc97496ef1505c5673b29182fba1846342
!! source digest: sha256:a37c70e8ee5fdc272f67d2b22656d3ba8338a556c2997169a90f3c6fd0afde36
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/stock-logistics-barcode/tree/16.0/stock_barcodes"><img alt="OCA/stock-logistics-barcode" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--barcode-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-barcode-16-0/stock-logistics-barcode-16-0-stock_barcodes"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-barcode&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module provides a barcode reader interface for stock module.</p>
Expand Down Expand Up @@ -557,7 +558,9 @@ <h2><a class="toc-backref" href="#toc-entry-15">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-16">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down
16 changes: 16 additions & 0 deletions stock_barcodes/static/src/model/basic_model.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
odoo.define("stock_barcodes.BasicModel", function (require) {
var BasicModel = require("web.BasicModel");

BasicModel.include({
_readMissingFields: function (list, resIDs, fieldNames) {
// This allows for "static list" (x2many fields) to always update there
// fields
if (list.getContext().always_reload) {
for (const key in list._cache) {
delete list._cache[key];
}
}
return this._super.apply(this, [list, resIDs, fieldNames]);
},
});
});
4 changes: 4 additions & 0 deletions stock_barcodes/views/stock_barcodes_option_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
<field name="show_scan_log" />
<field name="show_detailed_operations" />
<field name="auto_put_in_pack" />
<field name="forbid_same_source_and_dest" />
<field name="update_all_dest_on_dest_update" />
</group>
<group>
<field name="ignore_filled_fields" />
Expand All @@ -47,6 +49,8 @@
<field name="auto_lot" />
<field name="create_lot" />
<field name="use_location_dest_putaway" />
<field name="scan_product_one_by_one" />
<field name="do_not_check_demand" />
</group>
</group>
<separator string="Steps to scan" />
Expand Down
2 changes: 2 additions & 0 deletions stock_barcodes/views/stock_picking_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@
<field name="default_location_dest_id" invisible="1" />
</field>
<xpath expr="//div[hasclass('o_kanban_primary_left')]" position="inside">
<field name="barcode_option_group_id" invisible="1" />
<div
class="mt8"
t-if="['incoming', 'outgoing', 'internal'].indexOf(record.code.raw_value) > -1"
attrs="{'invisible': [('barcode_option_group_id', '=', False)]}"
>
<button
name="action_barcode_scan"
Expand Down
14 changes: 13 additions & 1 deletion stock_barcodes/wizard/stock_barcodes_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ def process_barcode_location_dest_id(self):
location = self.env["stock.location"].search(self._barcode_domain(self.barcode))

Check warning on line 192 in stock_barcodes/wizard/stock_barcodes_read.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read.py#L192

Added line #L192 was not covered by tests
if location:
self.location_dest_id = location

Check warning on line 194 in stock_barcodes/wizard/stock_barcodes_read.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read.py#L194

Added line #L194 was not covered by tests
if (
self.picking_id.picking_type_id.barcode_option_group_id.forbid_same_source_and_dest
):
for sml in self.move_line_ids:
sml.location_dest_id = location
return True
return False

Check warning on line 201 in stock_barcodes/wizard/stock_barcodes_read.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read.py#L199-L201

Added lines #L199 - L201 were not covered by tests

Expand All @@ -208,6 +213,11 @@ def process_barcode_product_id(self):
)
return False

Check warning on line 214 in stock_barcodes/wizard/stock_barcodes_read.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read.py#L214

Added line #L214 was not covered by tests
self.action_product_scaned_post(product)

if self.option_group_id.scan_product_one_by_one:
self.action_done()
return True

Check warning on line 219 in stock_barcodes/wizard/stock_barcodes_read.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read.py#L218-L219

Added lines #L218 - L219 were not covered by tests

if (
self.option_group_id.fill_fields_from_lot
and self.location_id
Expand Down Expand Up @@ -394,6 +404,9 @@ def process_barcode(self, barcode):
option_func = getattr(self, "process_barcode_%s" % option.field_name, False)
if option_func:
res = option_func()
self.env["bus.bus"]._sendone(
"barcode_scan", "stock_barcodes_scanned", {}
)
if option.required:
self.play_sounds(res)
if res:
Expand Down Expand Up @@ -716,7 +729,6 @@ def action_manual_quantity(self):
def action_reopen_wizard(self):
return self.get_formview_action()

Check warning on line 730 in stock_barcodes/wizard/stock_barcodes_read.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read.py#L730

Added line #L730 was not covered by tests

@api.onchange("step")
def action_show_step(self):
options_required = self.option_group_id.option_ids.filtered("required")
self.step = 0
Expand Down
21 changes: 17 additions & 4 deletions stock_barcodes/wizard/stock_barcodes_read_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _compute_pending_move_ids(self):
else:
self.pending_move_ids = False

Check warning on line 90 in stock_barcodes/wizard/stock_barcodes_read_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read_picking.py#L90

Added line #L90 was not covered by tests

@api.depends("todo_line_ids")
@api.depends("todo_line_ids", "_barcode_scanned")
def _compute_move_line_ids(self):
self.move_line_ids = self.picking_id.move_line_ids.filtered("qty_done").sorted(
key=lambda sml: (sml.write_date, sml.create_date), reverse=True
Expand Down Expand Up @@ -133,8 +133,6 @@ def create(self, vals):
wiz = super().create(vals)
if wiz.picking_id:
wiz._set_candidate_pickings(wiz.picking_id)
else:
wiz._search_candidate_picking()
return wiz

@api.onchange("picking_id")
Expand Down Expand Up @@ -215,6 +213,9 @@ def determine_todo_action(self, forced_todo_line=False):
return False
if not self.todo_line_ids:
self.fill_todo_records()

Check warning on line 215 in stock_barcodes/wizard/stock_barcodes_read_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read_picking.py#L215

Added line #L215 was not covered by tests

if not self.todo_line_ids:
return False

Check warning on line 218 in stock_barcodes/wizard/stock_barcodes_read_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read_picking.py#L218

Added line #L218 was not covered by tests
# When scanning all information in one step (e.g. using GS-1), the
# status and qty processed might have not been update, we ensure it
# invalidating the cache.
Expand Down Expand Up @@ -518,6 +519,7 @@ def _process_stock_move_line(self): # noqa: C901
not self.option_group_id.code == "REL"
and not self.env.context.get("force_create_move", False)
and not self.env.context.get("manual_picking", False)
and not self.picking_id.picking_type_id.barcode_option_group_id.do_not_check_demand
and float_compare(
available_qty,
max_quantity,
Expand Down Expand Up @@ -916,7 +918,18 @@ def _get_picking_to_validate(self):

def action_validate_picking(self):
picking = self._get_picking_to_validate()

Check warning on line 920 in stock_barcodes/wizard/stock_barcodes_read_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read_picking.py#L920

Added line #L920 was not covered by tests
return picking.button_validate()
if picking.picking_type_id.barcode_option_group_id.forbid_same_source_and_dest:
for sml in picking.move_line_ids:
if sml.location_dest_id.id == sml.location_id.id:
self.wiz_barcode_id._set_messagge_info(

Check warning on line 924 in stock_barcodes/wizard/stock_barcodes_read_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read_picking.py#L924

Added line #L924 was not covered by tests
"more_match", _("Destination and source can't be the same")
)
return False

Check warning on line 927 in stock_barcodes/wizard/stock_barcodes_read_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read_picking.py#L927

Added line #L927 was not covered by tests

result = picking.button_validate()

Check warning on line 929 in stock_barcodes/wizard/stock_barcodes_read_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read_picking.py#L929

Added line #L929 was not covered by tests
if result and self.env.context.get("scanning_picking_type", False):
return picking.picking_type_id.action_barcode_scan()
return result

Check warning on line 932 in stock_barcodes/wizard/stock_barcodes_read_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read_picking.py#L931-L932

Added lines #L931 - L932 were not covered by tests

def action_open_picking(self):
picking = self.env["stock.picking"].browse(

Check warning on line 935 in stock_barcodes/wizard/stock_barcodes_read_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read_picking.py#L935

Added line #L935 was not covered by tests
Expand Down
Loading

0 comments on commit 3828828

Please sign in to comment.