[IMP] stock_vertical_lift: increase coverage

This commit is contained in:
Hai Lang
2021-11-22 19:35:01 +07:00
parent 53eacf9af3
commit 73b1c95adc
4 changed files with 36 additions and 3 deletions

View File

@@ -423,9 +423,7 @@ class VerticalLiftOperationTransfer(models.AbstractModel):
def _compute_product_packagings(self):
for record in self:
product = record.current_move_line_id.product_id
if not product:
record.product_packagings = ""
continue
# Empty product is taken care in _render_product_packagings
content = self._render_product_packagings(product)
record.product_packagings = content

View File

@@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _
from odoo.tests.common import Form
from .common import VerticalLiftCase
@@ -40,6 +41,31 @@ class TestInventory(VerticalLiftCase):
self.assertEqual(action["res_model"], "vertical.lift.shuttle.manual.barcode")
self.assertEqual(action["name"], "Barcode")
operation = self._open_screen("put")
self.assertEqual(operation._name, "vertical.lift.operation.put")
self.assertEqual(operation.state, "scan_source")
VerticalLiftShuttleManualBarcode = self.env[action["res_model"]]
ClassWithContextOnlyModel = VerticalLiftShuttleManualBarcode.with_context(
active_model=operation._name,
)
vls_manual_form = Form(ClassWithContextOnlyModel)
rec_id = vls_manual_form._values.get("id")
vls_manual = ClassWithContextOnlyModel.browse(rec_id)
vls_manual.button_save()
ClassWithContext = VerticalLiftShuttleManualBarcode.with_context(
active_ids=operation.ids,
active_id=operation.ids[0],
active_model=operation._name,
)
vls_manual_form = Form(ClassWithContext)
vls_manual_form.barcode = self.product_socks.barcode
vls_manual_form.save()
rec_id = vls_manual_form._values.get("id")
vls_manual = ClassWithContext.browse(rec_id)
vls_manual.button_save()
def test_inventory_count_ops(self):
self._update_qty_in_location(self.location_1a_x1y1, self.product_socks, 10)
self._update_qty_in_location(self.location_1a_x2y1, self.product_recovery, 10)

View File

@@ -258,3 +258,11 @@ class TestPick(VerticalLiftCase):
self.assertEqual(operation.tray_qty, 50)
self._update_quantity_in_cell(cell, self.out_move_line.product_id, -20)
self.assertEqual(operation.tray_qty, 30)
self.assertTrue(operation.product_packagings)
def test_product_packagings(self):
operation = self.shuttle._operation_for_mode()
ml = operation.current_move_line_id
ml.move_id.state = "draft"
ml.product_id = False
self.assertFalse(operation.product_packagings)

View File

@@ -13,6 +13,7 @@ class VerticalLiftShuttleManualBarcode(models.TransientModel):
def button_save(self):
active_id = self.env.context.get("active_id")
model = self.env.context.get("active_model")
assert model
record = self.env[model].browse(active_id).exists()
if not record:
return