Skip to content

Commit 5ee31c6

Browse files
simahawkKimkhoi3010
authored andcommitted
stock_vertical_lift: make pkg compute more solid (#16)
* 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.
1 parent a6119b8 commit 5ee31c6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

stock_vertical_lift/models/vertical_lift_operation_base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ def button_release(self):
229229
self.next_step()
230230

231231
def _render_product_packagings(self, product):
232+
if not product:
233+
return ""
232234
return self.env["ir.qweb"].render(
233235
"stock_vertical_lift.packagings",
234236
self._prepare_values_for_product_packaging(product),
@@ -343,10 +345,10 @@ def on_barcode_scanned(self, barcode):
343345
@api.depends("current_move_line_id.product_id.packaging_ids")
344346
def _compute_product_packagings(self):
345347
for record in self:
346-
if not record.current_move_line_id:
348+
product = record.current_move_line_id.product_id
349+
if not product:
347350
record.product_packagings = ""
348351
continue
349-
product = record.current_move_line_id.product_id
350352
content = self._render_product_packagings(product)
351353
record.product_packagings = content
352354

stock_vertical_lift/models/vertical_lift_operation_inventory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ def _compute_tray_data(self):
143143
@api.depends("current_inventory_line_id.product_id.packaging_ids")
144144
def _compute_product_packagings(self):
145145
for record in self:
146-
if not record.current_inventory_line_id:
146+
product = record.current_inventory_line_id.product_id
147+
if not product:
147148
record.product_packagings = ""
148149
continue
149-
product = record.current_inventory_line_id.product_id
150150
content = self._render_product_packagings(product)
151151
record.product_packagings = content
152152

0 commit comments

Comments
 (0)