Je crée un rapport (vue QWEB) dans le modèle account.invoice et je souhaite résumer quelques champs pour chaque ligne de facture comme indiqué dans l'image suivante:Comment faire une somme de champs dans une vue Qweb?
Le problème est cette somme pas champs que je veux. Que devrais-je faire?
cantidad_producto = fields.Integer(string='Cantidad Producto', store=True, readonly=True, compute='cantidad_consolidado')
total_precio_unitario = fields.Monetary(string='Total precio unitario', store=True, readonly=True, compute='cantidad_consolidado')
total_precio_neto = fields.Monetary(string='Total Cantidad Producto', store=True, readonly=True, compute='cantidad_consolidado')
Et ceci est ma fonction calculer dans le fichier account.invoice.py:
@api.one
@api.depends('invoice_line_ids.quantity', 'invoice_line_ids.price_unit', 'invoice_line_ids.price_subtotal')
def cantidad_consolidado(self):
self.cantidad_producto = sum(line.quantity for line in self.invoice_line_ids)
self.total_precio_unitario = sum(line.price_unit for line in self.invoice_line_ids)
self.total_precio_neto = sum(line.price_subtotal for line in self.invoice_line_ids
Et enfin, voici mon code de la vue:
<p>Resumen</p>
<table class="table table-bordered">
<thead>
<tr>
<th class="text-center">Total Cantidad</th>
<th class="text-center">Total Precio Unitario</th>
<th class="text-center">Total Precio(Neto)</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<td class="text-center">
<span t-esc="cantidad_producto" />
</td>
<td class="text-center">
<span t-esc="total_precio_unitario" />
</td>
<td class="text-center">
<span t-esc="total_precio_neto" />
</td>
</tbody>
</table>
Pourquoi ne pas la somme champs dans le rapport? Quelqu'un pourrait me dire et m'aider s'il vous plaît.
Le lien n'est plus disponible. – Zety