Odoo Help


This community 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.


Can anybody help me with a simple Python change?

David Dean
on 10/24/14, 7:31 PM 826 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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


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