Skip to content

Commit

Permalink
[IMP] stock_barcodes: Allow apply putaway strategy as screen option
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-teruel committed Mar 21, 2024
1 parent 559cfd4 commit 1096a90
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stock_barcodes/models/stock_barcodes_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class StockBarcodesOptionGroup(models.Model):
display_notification = fields.Boolean(
string="Display Odoo notifications",
)
use_location_dest_putaway = fields.Boolean(
string="Use location dest. putaway",
)

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 @@ -45,6 +45,7 @@
<field name="ignore_quant_location" />
<field name="auto_lot" />
<field name="create_lot" />
<field name="use_location_dest_putaway" />
</group>
</group>
<separator string="Steps to scan" />
Expand Down
1 change: 1 addition & 0 deletions stock_barcodes/views/stock_picking_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<field name="arch" type="xml">
<field name="name" position="after">
<field name="code" string="Type of operation" />
<field name="sequence_code" string="Code" />
<filter
string="Barcode Options"
name="barcode_options"
Expand Down
6 changes: 6 additions & 0 deletions stock_barcodes/wizard/stock_barcodes_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,17 @@ def check_option_required(self):
self.product_id.tracking == "none" or self.auto_lot or self.lot_name
):
continue
if self._option_required_hook(option):
continue
self._set_messagge_info("info", option.name)
self.action_show_step()
return False
return True

def _option_required_hook(self, option_required):
"""Hook to evaluate is an option is required"""
return False

def _scanned_location(self, barcode):
location = self.env["stock.location"].search(self._barcode_domain(barcode))
if location:
Expand Down
16 changes: 16 additions & 0 deletions stock_barcodes/wizard/stock_barcodes_read_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,22 @@ def action_clean_values(self):
self.visible_force_done = False
return res

def _option_required_hook(self, option_required):
if (
option_required.field_name == "location_dest_id"
and self.option_group_id.use_location_dest_putaway
):
self.location_dest_id = self.picking_id.location_dest_id.with_context(
avoid_location_with_reserve=True
)._get_putaway_strategy(
self.product_id,
self.product_qty,
self.result_package_id,
self.packaging_id,
)
return bool(self.location_dest_id)
return super()._option_required_hook(option_required)


class WizCandidatePicking(models.TransientModel):
"""
Expand Down

0 comments on commit 1096a90

Please sign in to comment.