Skip to content

Commit

Permalink
stock_vertical_lift: make pkg compute more solid (#16)
Browse files Browse the repository at this point in the history
* stock_vertical_lift: make pkg compute more solid

Somehow sometimes you can get a move line without product
while computing product packaging in inventory.

Make it more defensive and skip packaging rendering if no product is
there.
  • Loading branch information
simahawk authored Sep 3, 2020
1 parent bd041a3 commit 775a9f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions stock_vertical_lift/models/vertical_lift_operation_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ def button_release(self):
self.next_step()

def _render_product_packagings(self, product):
if not product:
return ""
return self.env["ir.qweb"].render(
"stock_vertical_lift.packagings",
self._prepare_values_for_product_packaging(product),
Expand Down Expand Up @@ -343,10 +345,10 @@ def on_barcode_scanned(self, barcode):
@api.depends("current_move_line_id.product_id.packaging_ids")
def _compute_product_packagings(self):
for record in self:
if not record.current_move_line_id:
product = record.current_move_line_id.product_id
if not product:
record.product_packagings = ""
continue
product = record.current_move_line_id.product_id
content = self._render_product_packagings(product)
record.product_packagings = content

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ def _compute_tray_data(self):
@api.depends("current_inventory_line_id.product_id.packaging_ids")
def _compute_product_packagings(self):
for record in self:
if not record.current_inventory_line_id:
product = record.current_inventory_line_id.product_id
if not product:
record.product_packagings = ""
continue
product = record.current_inventory_line_id.product_id
content = self._render_product_packagings(product)
record.product_packagings = content

Expand Down

0 comments on commit 775a9f9

Please sign in to comment.