Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0] stock_barcodes: enable filter on products for inventory #664

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -176,6 +176,9 @@
return True
return False

def _hook_process_barcode_product(self, product):
return True

def process_barcode_product_id(self):
domain = self._barcode_domain(self.barcode)
product = self.env["product.product"].search(domain)
Expand All @@ -188,6 +191,9 @@
"not_found", _("The product type is not allowed")
)
return False
res_hook = self._hook_process_barcode_product(product)
if res_hook is False:
return False

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

View check run for this annotation

Codecov / codecov/patch

stock_barcodes/wizard/stock_barcodes_read.py#L196

Added line #L196 was not covered by tests
self.action_product_scaned_post(product)
# self.action_done()
return True
Expand Down
16 changes: 16 additions & 0 deletions stock_barcodes/wizard/stock_barcodes_read_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
_name = "wiz.stock.barcodes.read.inventory"
_inherit = "wiz.stock.barcodes.read"
_description = "Wizard to read barcode on inventory"
_allowed_product_types = ["product"]

inventory_id = fields.Many2one(comodel_name="stock.inventory", readonly=True)
inventory_product_qty = fields.Float(
Expand Down Expand Up @@ -165,3 +166,18 @@
def _onchange_lot_id(self):
if self.lot_id and not self.env.context.get("keep_auto_lot"):
self.auto_lot = False

def _hook_process_barcode_product(self, product):
if (
self.inventory_id.product_ids
and product.id not in self.inventory_id.product_ids.ids
):
self._set_messagge_info(

Check warning on line 175 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#L175

Added line #L175 was not covered by tests
"not_found",
_(
"This inventory is filtered on products and product '%s' is not part of it."
)
% product.display_name,
)
return False

Check warning on line 182 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#L182

Added line #L182 was not covered by tests
return super()._hook_process_barcode_product(product)
Loading