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 Apr 26, 2024
1 parent 52aa7ce commit cbe6ee6
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 110 deletions.
6 changes: 5 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,10 @@ 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
1 change: 1 addition & 0 deletions stock_barcodes/views/stock_barcodes_option_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<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
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
6 changes: 5 additions & 1 deletion stock_barcodes/wizard/stock_barcodes_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ def process_barcode_product_id(self):
)
return False
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 @@ -716,7 +721,6 @@ def action_manual_quantity(self):
def action_reopen_wizard(self):
return self.get_formview_action()

@api.onchange("step")
def action_show_step(self):
options_required = self.option_group_id.option_ids.filtered("required")
self.step = 0
Expand Down
5 changes: 3 additions & 2 deletions stock_barcodes/wizard/stock_barcodes_read_picking.py
Original file line number Diff line number Diff line change
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()

if not self.todo_line_ids:
return False
# 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
210 changes: 105 additions & 105 deletions stock_barcodes/wizard/stock_barcodes_read_picking_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
type="object"
title="lock picking"
t-if="record.picking_id.raw_value != record.wiz_picking_id.raw_value"
class="fa fa-thumb-tack fa-2x float-right"
class="fa fa-thumb-tack fa-2x float-end"
context="{'wiz_barcode_id': parent.id, 'picking_id': picking_id}"
/>
<a
name="action_unlock_picking"
type="object"
title="unlock picking"
class="float-right"
class="float-end"
t-if="record.picking_id.raw_value == record.wiz_picking_id.raw_value"
context="{'wiz_barcode_id': parent.id}"
>
Expand Down Expand Up @@ -74,6 +74,7 @@
</t>
<field
name="scan_count"
invisible="1"
force_save="1"
/>
</strong>
Expand Down Expand Up @@ -245,114 +246,113 @@
</field>
</page>
</notebook>
<group
string="Detailed operations"
attrs="{'invisible': ['|', ('move_line_ids', '=', []), ('show_detailed_operations', '=', False)]}"
>
<field
name="move_line_ids"
options="{'no_open': True, 'always_reload': True}"
nolabel="1"
force_save="1"
mode="tree,kanban"
>
<tree>
<field name="picking_code" invisible="1" />
<field name="product_id" options="{'no_open': True}" />
<field
name="location_id"
options="{'no_open': True}"
groups="stock.group_stock_multi_locations"
attrs="{'invisible': [('picking_code', '=', 'incoming')]}"
optional="show"
/>
<field
name="location_dest_id"
options="{'no_open': True}"
groups="stock.group_stock_multi_locations"
attrs="{'invisible': [('picking_code', '=', 'outgoing')]}"
optional="show"
/>
<field
name="lot_id"
groups="stock.group_production_lot"
options="{'no_open': True}"
optional="show"
/>
<field
name="result_package_id"
groups="stock.group_tracking_lot"
options="{'no_open': True}"
optional="show"
/>
<field name="qty_done" />
<field
name="product_uom_id"
groups="uom.group_uom"
options="{'no_open': True}"
/>
<button
name="action_barcode_detailed_operation_unlink"
type="object"
class="btn"
icon="fa-trash"
title="Remove detailed operation"
context="{'wiz_barcode_id': parent.id}"
/>
</tree>
<kanban class="o_kanban_mobile">
<field name="product_id" />
<field name="qty_done" />
<field name="product_uom_id" />
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_card">
<div class="row">
<div class="col-7">
<strong>
<span>
<field name="product_id" />
<notebook>
<page string="Detailed operations">
<field
name="move_line_ids"
options="{'no_open': True, 'always_reload': True}"
nolabel="1"
force_save="1"
mode="tree,kanban"
>
<tree>
<field name="picking_code" invisible="1" />
<field name="product_id" options="{'no_open': True}" />
<field
name="location_id"
options="{'no_open': True}"
groups="stock.group_stock_multi_locations"
attrs="{'invisible': [('picking_code', '=', 'incoming')]}"
optional="show"
/>
<field
name="location_dest_id"
options="{'no_open': True}"
groups="stock.group_stock_multi_locations"
attrs="{'invisible': [('picking_code', '=', 'outgoing')]}"
optional="show"
/>
<field
name="lot_id"
groups="stock.group_production_lot"
options="{'no_open': True}"
optional="show"
/>
<field
name="result_package_id"
groups="stock.group_tracking_lot"
options="{'no_open': True}"
optional="show"
/>
<field name="qty_done" />
<field
name="product_uom_id"
groups="uom.group_uom"
options="{'no_open': True}"
/>
<button
name="action_barcode_detailed_operation_unlink"
type="object"
class="btn"
icon="fa-trash"
title="Remove detailed operation"
context="{'wiz_barcode_id': parent.id}"
/>
</tree>
<kanban class="o_kanban_mobile">
<field name="product_id" />
<field name="qty_done" />
<field name="product_uom_id" />
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_card">
<div class="row">
<div class="col-7">
<strong>
<span>
<field name="product_id" />
</span>
</strong>
</div>
<div class="col-2">
<span
class="float-right text-end font-weight-bold"
>
<field name="qty_done" />
</span>
</strong>
</div>
<div class="col-2">
<span
class="float-right text-end font-weight-bold"
>
<field name="qty_done" />
</span>
</div>
<div class="col-3 text-end">
<button
name="action_barcode_detailed_operation_unlink"
type="object"
icon="fa-trash"
title="Remove"
class="btn mt0"
context="{'wiz_barcode_id': parent.id}"
/>
</div>
</div>
<div class="row">
<div class="col-4">
Lot: <field name="lot_id" />
</div>
<div class="col-3 text-end">
<button
name="action_barcode_detailed_operation_unlink"
type="object"
icon="fa-trash"
title="Remove"
class="btn mt0"
context="{'wiz_barcode_id': parent.id}"
/>
</div>
</div>
<t
t-if="record.result_package_id.raw_value"
>
<div class="row">
<div class="col-4">
Package: <field
name="result_package_id"
/>
Lot: <field name="lot_id" />
</div>
</t>
<t
t-if="record.result_package_id.raw_value"
>
<div class="col-4">
Package: <field
name="result_package_id"
/>
</div>
</t>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</group>
</t>
</templates>
</kanban>
</field>
</page>
</notebook>
</group>
<xpath expr="//button[@id='btn_create_lot']" position="after">
<field name="display_assign_serial" invisible="1" />
Expand Down
3 changes: 2 additions & 1 deletion stock_barcodes/wizard/stock_barcodes_read_todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def _get_all_products_quantities_in_package(self, package):
def _prepare_fill_record_values(self, wiz_barcode, line, position):
vals = {
"product_id": line.product_id.id,
"product_uom_qty": line.product_uom_qty,
"name": "To do action",
"position_index": position,
"picking_code": line.picking_code,
Expand All @@ -94,6 +93,7 @@ def _prepare_fill_record_values(self, wiz_barcode, line, position):
)
vals.update(
{
"product_uom_qty": line.move_id.product_uom_qty,
"location_id": line.location_id.id,
"location_dest_id": line.location_dest_id.id,
"lot_id": line.lot_id.id,
Expand All @@ -111,6 +111,7 @@ def _prepare_fill_record_values(self, wiz_barcode, line, position):
else:
vals.update(
{
"product_uom_qty": line.move_id.product_uom_qty,
"location_id": (line.move_line_ids[:1] or line).location_id.id,
"location_dest_id": (
line.move_line_ids[:1] or line
Expand Down

0 comments on commit cbe6ee6

Please sign in to comment.