Odoo Help


Can anybody help me with a simple Python change?

David Dean
on 10/24/14, 7:31 PM 1,192 views

I'm trying to extend the sale_layout module to include a total (at the moment it only has subtotal). Being a Python newbie I'm struggling. This is the error I'm getting:

QWebException: ""finaltotal" while evaluating
"p['finaltotal']"" while evaluating
"translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.report_saleorder_document')"


Here is the code, with my additions highlighted in bold:


def grouplines(self, ordered_lines, sortkey):
    """Return lines from a specified invoice or sale order grouped by category"""
    grouped_lines = []
    for key, valuesiter in groupby(ordered_lines, sortkey):
        group = {}
        group['category'] = key
        group['lines'] = list(v for v in valuesiter)
        group['finaltotal'] = sum(line.price_subtotal for line in group['lines'])

        if 'subtotal' in key and key.subtotal is True:
            group['subtotal'] = sum(line.price_subtotal for line in group['lines'])

    return grouped_lines



<template id="finaltotal_template">
    <!-- Final Total -->
    <t t-if="'subtotal' in p['category'] and p['category'].subtotal is True">
        <tr class="text-right">
            <td colspan="100">
                <strong>Total: </strong>
                <span t-esc="p['finaltotal']" t-esc-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>

I've only made basic changes, but I cannot figure out why this isn't working. I know the calculation isn't right, I'm just trying to add the field to start with. Thanks.


Ben Bernard

--Ben Bernard--

| 4 3 6
Jakarta, Indonesia
--Ben Bernard--
Ben Bernard
On 10/25/14, 3:02 AM

Try to add field 'finaltotal' in model 'sale_layout.category' similar to field 'subtotal' (with default = True).

Thank you, I knew it would be something really obvious. Adding the field to the model worked great.

David Dean
on 10/25/14, 5:26 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 10/24/14, 7:31 PM
Seen: 1192 times
Last updated: 3/16/15, 8:10 AM