Skip to content

Commit

Permalink
[MIG] stock_barcodes: continue migration
Browse files Browse the repository at this point in the history
- Drop scan read logs feature, which use was deprecated already in the
  previous versions.
- Pass bootstrap migration scripts.
- Fix views issues.
- Other code fixes.
  • Loading branch information
chienandalu committed May 15, 2024
1 parent 030fd4e commit 11c42f5
Show file tree
Hide file tree
Showing 25 changed files with 477 additions and 619 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:f6453112d1afcb3f171e5f468a06e4927c98ed93493c10c8af4e4aef077de7fd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
14 changes: 6 additions & 8 deletions stock_barcodes/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@
],
"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/**/*.esm.js",
(
"after",
"/web_widget_numeric_step/static/src/numeric_step.xml",
"/stock_barcodes/static/src/widgets/numeric_step.xml",
),
"/stock_barcodes/static/src/widgets/view_button.xml",
"/stock_barcodes/static/src/css/stock.scss",
],
Expand Down
1 change: 0 additions & 1 deletion stock_barcodes/data/stock_barcodes_option.xml
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@
<field name="name">Inventory options</field>
<field name="code">INV</field>
<field name="barcode_guided_mode" />
<field name="show_scan_log">False</field>
</record>
<record
id="stock_barcodes_option_location_id_inventory"
Expand Down
4 changes: 2 additions & 2 deletions stock_barcodes/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ msgstr "Aceptar"
#. module: stock_barcodes
#: model_terms:ir.ui.view,arch_db:stock_barcodes.view_stock_barcodes_read_picking_form
msgid "Open"
msgstr "Abierto"
msgstr "Abrir"

#. module: stock_barcodes
#: model:ir.model.fields.selection,name:stock_barcodes.selection__stock_barcodes_option_group__source_pending_moves__move_lines
Expand Down Expand Up @@ -1249,7 +1249,7 @@ msgstr "Grupo de opciones para el interfaz de códigos de barras"
#. module: stock_barcodes
#: model:ir.model.fields.selection,name:stock_barcodes.selection__stock_barcodes_option_group__location_field_to_sort__location_id
msgid "Origin Location"
msgstr ""
msgstr "Ubicación de origen"

#. module: stock_barcodes
#: model:ir.model.fields,help:stock_barcodes.field_stock_barcodes_option_group__source_pending_moves
Expand Down
1 change: 0 additions & 1 deletion stock_barcodes/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from . import stock_barcodes_action
from . import stock_barcodes_option
from . import stock_barcodes_read_log
from . import stock_move_line
from . import stock_picking
from . import stock_picking_type
Expand Down
7 changes: 0 additions & 7 deletions stock_barcodes/models/stock_barcodes_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class StockBarcodesOptionGroup(models.Model):
default="move_line_ids",
help="Origin of the data to generate the movements to process",
)
show_scan_log = fields.Boolean(
string="Show scan log", help="Displays a log of the scans processed"
)
ignore_filled_fields = fields.Boolean(
string="Ignore filled fields",
)
Expand Down Expand Up @@ -103,10 +100,6 @@ 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"
)

def get_option_value(self, field_name, attribute):
option = self.option_ids.filtered(lambda op: op.field_name == field_name)[:1]
Expand Down
51 changes: 0 additions & 51 deletions stock_barcodes/models/stock_barcodes_read_log.py

This file was deleted.

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_uom_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: 0 additions & 2 deletions stock_barcodes/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_stock_barcodes_read_log,access_stock_barcodes_read_log,model_stock_barcodes_read_log,base.group_user,1,1,1,1
access_stock_barcodes_read_log_line,access_stock_barcodes_read_log_line,model_stock_barcodes_read_log_line,base.group_user,1,1,1,1
access_wiz_stock_barcodes_read_picking,access_wiz_stock_barcodes_read_picking,model_wiz_stock_barcodes_read_picking,base.group_user,1,1,1,1
access_wiz_candidate_picking,access_wiz_candidate_picking,model_wiz_candidate_picking,base.group_user,1,1,1,1
access_wiz_stock_barcodes_new_lot,access_wiz_stock_barcodes_new_lot,model_wiz_stock_barcodes_new_lot,base.group_user,1,1,1,1
Expand Down
2 changes: 1 addition & 1 deletion stock_barcodes/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,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:f6453112d1afcb3f171e5f468a06e4927c98ed93493c10c8af4e4aef077de7fd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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
9 changes: 7 additions & 2 deletions stock_barcodes/static/src/css/stock.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@
border: 0 !important;
}

// In Odoo 16 the flat input styling lacks proper usability
.o_field_widget {
margin-bottom: 0 !important;
margin-bottom: 3 !important;
.o_input {
border-radius: 3px;
border-width: 1px;
background-color: white;
}
}

.o_kanban_record {
padding: 0.3em;
flex-basis: 100%;

.btn-full-width {
Expand Down
2 changes: 1 addition & 1 deletion stock_barcodes/static/src/widgets/numeric_step.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<template>
<t
t-name="barcode_web_widget_numeric_step"
t-inherit="barcode_web_widget_numeric_step"
t-inherit="web_widget_numeric_step.web_widget_numeric_step"
t-inherit-mode="extension"
owl="1"
>
Expand Down
1 change: 0 additions & 1 deletion stock_barcodes/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def _create_barcode_option_group(cls):
return cls.env["stock.barcodes.option.group"].create(
{
"name": "option group for tests",
"show_scan_log": True,
"create_lot": True,
"option_ids": [
(
Expand Down
3 changes: 0 additions & 3 deletions stock_barcodes/tests/test_stock_barcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ def test_wizard_scan_not_found(self):
"84118xxx22568 (Barcode not found with this screen values)",
)

def test_wizard_remove_last_scan(self):
self.assertTrue(self.wiz_scan.action_undo_last_scan())

def test_wiz_clean_lot(self):
self.wiz_scan.location_id = self.location_1.id
self.wiz_scan.action_show_step()
Expand Down
6 changes: 2 additions & 4 deletions stock_barcodes/tests/test_stock_barcodes_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ def setUpClass(cls):
cls.barcode_option_group_out = cls._create_barcode_option_group_outgoing()
cls.barcode_option_group_in = cls._create_barcode_option_group_incoming()

cls.barcode_option_group_out.show_scan_log = True
cls.barcode_option_group_in.show_scan_log = True
cls.barcode_option_group_out.barcode_guided_mode = False
cls.barcode_option_group_in.barcode_guided_mode = False
cls.partner_agrolite = cls.env.ref("base.res_partner_2")
Expand Down Expand Up @@ -97,7 +95,7 @@ def setUpClass(cls):
0,
0,
{
"name": cls.product_wo_tracking.name,
"name": cls.product_tracking.name,
"product_id": cls.product_tracking.id,
"product_uom_qty": 3,
"product_uom": cls.product_tracking.uom_id.id,
Expand All @@ -109,7 +107,7 @@ def setUpClass(cls):
0,
0,
{
"name": cls.product_wo_tracking.name,
"name": cls.product_tracking.name,
"product_id": cls.product_tracking.id,
"product_uom_qty": 5,
"product_uom": cls.product_tracking.uom_id.id,
Expand Down
2 changes: 0 additions & 2 deletions stock_barcodes/views/stock_barcodes_option_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
/>
<field name="group_key_for_todo_records" />
<field name="location_field_to_sort" />
<field name="show_scan_log" />
<field name="show_detailed_operations" />
<field name="auto_put_in_pack" />
</group>
Expand All @@ -47,7 +46,6 @@
<field name="auto_lot" />
<field name="create_lot" />
<field name="use_location_dest_putaway" />
<field name="scan_product_one_by_one" />
</group>
</group>
<separator string="Steps to scan" />
Expand Down
6 changes: 3 additions & 3 deletions stock_barcodes/views/stock_picking_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
<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"/>
<field name="barcode_option_group_id" invisible="1" />
<div
class="mt8"
t-if="['incoming', 'outgoing', 'internal'].indexOf(record.code.raw_value) > -1"
t-if="['incoming', 'outgoing', 'internal'].indexOf(record.code.raw_value) &gt; -1"
attrs="{'invisible': [('barcode_option_group_id', '=', False)]}"
>
<button
Expand All @@ -66,7 +66,7 @@
</xpath>
<xpath expr="//div[hasclass('o_kanban_primary_right')]" position="inside">
<div
class="mt8 float-right"
class="float-end mt8"
t-if="record.default_location_src_id.raw_value and record.default_location_dest_id.raw_value"
>
<button
Expand Down
44 changes: 1 addition & 43 deletions stock_barcodes/wizard/stock_barcodes_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ class WizStockBarcodesRead(models.AbstractModel):
confirmed_moves = fields.Boolean(
string="Confirmed moves", related="option_group_id.confirmed_moves"
)
# Computed field for display all scanning logs from res_model and res_id
# when change product_id
scan_log_ids = fields.Many2many(
comodel_name="stock.barcodes.read.log", compute="_compute_scan_log_ids"
)
message_type = fields.Selection(
[
("info", "Barcode read with additional info"),
Expand All @@ -73,7 +68,6 @@ class WizStockBarcodesRead(models.AbstractModel):
step = fields.Integer()
is_manual_qty = fields.Boolean(compute="_compute_is_manual_qty")
is_manual_confirm = fields.Boolean(compute="_compute_is_manual_qty")
show_scan_log = fields.Boolean(compute="_compute_is_manual_qty")
# Technical field to allow use in attrs
display_menu = fields.Boolean()
qty_available = fields.Float(compute="_compute_qty_available")
Expand Down Expand Up @@ -110,7 +104,6 @@ def _compute_is_manual_qty(self):
rec.is_manual_qty = rec.option_group_id.is_manual_qty
rec.is_manual_confirm = rec.option_group_id.is_manual_confirm
rec.auto_lot = rec.option_group_id.auto_lot
rec.show_scan_log = rec.option_group_id.show_scan_log

@api.depends("option_group_id")
def _compute_auto_lot(self):
Expand Down Expand Up @@ -208,11 +201,6 @@ def process_barcode_product_id(self):
)
return False

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

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read.py#L202

Added line #L202 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

if (
self.option_group_id.fill_fields_from_lot
and self.location_id
Expand Down Expand Up @@ -558,9 +546,6 @@ def action_done(self):
return False

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

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read.py#L545-L546

Added lines #L545 - L546 were not covered by tests
if not self.check_done_conditions():
return False
if not self.env.context.get("_stock_barcodes_skip_read_log"):
_logger.info("Add scanned log barcode:{}".format(self.barcode))
self._add_read_log()
self.process_lot_before_done()
return True

Expand Down Expand Up @@ -653,35 +638,11 @@ def _prepare_scan_log_values(self, log_detail=False):
"res_id": self.res_id,
}

def _add_read_log(self, log_detail=False):
if self.product_qty and not self.env.context.get("force_create_move", False):
vals = self._prepare_scan_log_values(log_detail)
self.env["stock.barcodes.read.log"].create(vals)

@api.depends("product_id", "lot_id")
def _compute_scan_log_ids(self):
if self.option_group_id.show_scan_log:
logs = self.env["stock.barcodes.read.log"].search(
[
("res_model_id", "=", self.res_model_id.id),
("res_id", "=", self.res_id),
# ("location_id", "=", self.location_id.id),
# ("product_id", "=", self.product_id.id),
],
limit=10,
)
self.scan_log_ids = logs
else:
self.scan_log_ids = False

# TODO: To remove when stock_move_location uses action_clean_values
def reset_qty(self):
self.product_qty = 0
self.packaging_qty = 0

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

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read.py#L643-L644

Added lines #L643 - L644 were not covered by tests

def action_undo_last_scan(self):
return True

def open_actions(self):
self.display_menu = True

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

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read.py#L647

Added line #L647 was not covered by tests

Expand Down Expand Up @@ -749,9 +710,6 @@ def onchange_package_id(self):
def action_confirm(self):
if not self.check_option_required():
return False

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

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read.py#L712

Added line #L712 was not covered by tests
record = self.browse(self.ids)
record.write(self._convert_to_write(self._cache))
self = record
res = self.action_done()
self.invalidate_recordset()
self.play_sounds(res)
Expand Down Expand Up @@ -811,7 +769,7 @@ def _prepare_lot_vals(self):
}

def _create_new_lot(self):
StockProductionLot = self.env["stock.production.lot"]
StockProductionLot = self.env["stock.lot"]
lot_domain = [

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

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read.py#L772-L773

Added lines #L772 - L773 were not covered by tests
("name", "=", self.lot_name),
("product_id", "=", self.product_id.id),
Expand Down
5 changes: 1 addition & 4 deletions stock_barcodes/wizard/stock_barcodes_read_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ def _serial_tracking_message_fail(self):
)

def action_done(self):
result = super(
WizStockBarcodesReadInventory,
self.with_context(_stock_barcodes_skip_read_log=True),
).action_done()
result = super().action_done()

Check warning on line 101 in stock_barcodes/wizard/stock_barcodes_read_inventory.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read_inventory.py#L101

Added line #L101 was not covered by tests
if result:
result = self._add_inventory_quant()

Check warning on line 103 in stock_barcodes/wizard/stock_barcodes_read_inventory.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read_inventory.py#L103

Added line #L103 was not covered by tests
if result:
Expand Down
Loading

0 comments on commit 11c42f5

Please sign in to comment.