Skip to content

Commit

Permalink
[IMP] stock_barcodes: Add accumulate_read_quantity option to be used …
Browse files Browse the repository at this point in the history
…in inventory. In the future it can be used by other process.

TT46934
  • Loading branch information
carlosdauden committed Jan 5, 2024
1 parent 404c536 commit 36f717f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions stock_barcodes/models/stock_barcodes_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class StockBarcodesOptionGroup(models.Model):
keep_screen_values = fields.Boolean(
help="If checked the wizard values are kept until the pending move is completed",
)
accumulate_read_quantity = fields.Boolean(
help="If checked quantity will be accumulated to the existing record instead of "
"overwrite it with the new quantity value",
)

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 @@ -35,6 +35,7 @@
<field name="keep_screen_values" />
<field name="is_manual_confirm" />
<field name="is_manual_qty" />
<field name="accumulate_read_quantity" />
<field name="allow_negative_quant" />
<field name="fill_fields_from_lot" />
<field name="auto_lot" />
Expand Down
6 changes: 4 additions & 2 deletions stock_barcodes/wizard/stock_barcodes_read_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def _inventory_quant_domain(self):
"<=",
fields.Date.context_today(self).strftime("%Y-%m-%d"),
),
("inventory_quantity_set", "=", True),
("product_id", "=", self.product_id.id),
("location_id", "=", self.location_id.id),
("lot_id", "=", self.lot_id.id),
Expand All @@ -78,7 +77,10 @@ def _add_inventory_quant(self):
):
self._serial_tracking_message_fail()
return False
quant.inventory_quantity = self.product_qty
if self.option_group_id.accumulate_read_quantity:
quant.inventory_quantity += self.product_qty
else:
quant.inventory_quantity = self.product_qty
else:
if self.product_id.tracking == "serial" and self.product_qty != 1:
self._serial_tracking_message_fail()
Expand Down

0 comments on commit 36f717f

Please sign in to comment.