stock_vertical_lift: packaging template more flexible

As the template is not used by JS we can pass full objects to it.
This way we can use any recordset information directly in the template
without having to override the method.
This commit is contained in:
Simone Orsi
2020-09-02 13:06:05 +02:00
committed by Hai Lang
parent 59952bf8c4
commit 6a702b30bb
2 changed files with 11 additions and 16 deletions

View File

@@ -229,14 +229,13 @@ class VerticalLiftOperationBase(models.AbstractModel):
self.next_step()
def _render_product_packagings(self, product):
values = {
"packagings": [
{"name": pkg.name, "qty": pkg.qty, "unit": product.uom_id.name}
for pkg in product.packaging_ids
]
}
content = self.env["ir.qweb"].render("stock_vertical_lift.packagings", values)
return content
return self.env["ir.qweb"].render(
"stock_vertical_lift.packagings",
self._prepare_values_for_product_packaging(product),
)
def _prepare_values_for_product_packaging(self, product):
return {"product": product}
def _get_tray_qty(self, product, location):
quants = self.env["stock.quant"].search(

View File

@@ -1,24 +1,20 @@
<odoo>
<template id="packagings">
<ul class="o_vlift_packaging list-unstyled">
<t t-foreach="packagings" t-as="packaging">
<t t-foreach="product.packaging_ids" t-as="packaging">
<li>
<span>1</span>
<span
class="packaging_name"
itemprop="name"
t-esc="packaging['name']"
t-esc="packaging.name"
/>
<span>: </span>
<span
class="packaging_qty"
itemprop="qty"
t-esc="packaging['qty']"
/>
<span class="packaging_qty" itemprop="qty" t-esc="packaging.qty" />
<span
class="packaging_unit"
itemprop="unit"
t-esc="packaging['unit']"
t-esc="product.uom_id.name"
/>
</li>
</t>