Odoo Help

0

Add two value fields in Qweb report

By
Odoo Group Ecuador
on 9/6/16, 1:00 AM 1,051 views

I'm sorry for my English

I am writing a custom Qweb print report for Odoo invoices and my goal is add o.amount_untaxed + tax_amount_by_group(only positive values, excluding negative withholding); this is my code:

<t t-set="total" t-value="o.amount_untaxed"/>
<t t-foreach="o._get_tax_amount_by_group()"
   t-as="amount_by_group">
  <small> <tr>
    <td> <span t-if="amount_by_group[0] == 'Taxes'">
      <span t-esc="amount_by_group[1]"/> </span> <br></br>
    <t t-set="total" t-value="unicode(o.amount_untaxed)+amount_by_group[1]"/>
    <t t-esc="total"/>
    </td>
  </tr> </small> <br></br>
</t>

But the result is (based on actual DB records):

Subtotal $ 4,644.95
Taxes $ 557.39

Taxes 4644.95$ 557.39
Witholding 4644.95$ -167.21
Witholding 4644.95$ -46.45

My expected result need be (based on actual DB records):

Subtotal $ 4,644.95
Taxes $ 557.39

Total $ 5202.34

Total is the result of untaxed_amount + taxes (excluding withholding); I really tried many ways and I can not find the right one!

:'(

0
Farid Ghanchi
On 7/5/17, 1:14 AM

Hello,

please create report py file

You add context dictionary on init method like

class test_test(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(test_test, self).__init__(cr, uid, name, context)
        self.localcontext.update({    
            'total_subtotat_plus_tax': self.total_subtotat_plus_tax,          
        })

class test_test(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(test_test, self).__init__(cr, uid, name, context)
        self.localcontext.update({    
            'total_subtotat_plus_tax': self.total_subtotat_plus_tax,          
        })
    def total_subtotat_plus_tax(self, obj):
    return obj.amount_untaxed + obj._get_tax_amount_by_group[1]
 

now in xml

Total: <span t-esc="total_subtotal_plus_tax(o)" />

Thanks


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.

Register

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

2 follower(s)

Stats

Asked: 9/6/16, 1:00 AM
Seen: 1051 times
Last updated: 7/5/17, 1:14 AM