Odoo Help


How to modify count total amount in sale order? [SOLVED]

on 1/28/15, 1:20 AM 1,013 views

i experienced some problem when override method _amount_all(), 

here the error:

TypeError: _amount_all() got an unexpected keyword argument 'context'

and here my code:


    def _amount_all(self, field_name):
        reslt = {}
        result = super(sale_order, self)._amount_all(field_name)
        for orders in self.browser(self.id):
            reslt[orders.id] = {
                'discount_fidelity': self.discount_fidelity
            result[orders.id]['discount_fidelity'] = cur_obj.round(
            result[orders.id]['amount_total'] = result[orders.id][
                'amount_total'] - reslt[orders.id]['discount_fidelity']
        return result

The point why i override this function because i want to add new field to use when counting total amount.


Nishant Jogi
On 1/28/15, 1:33 AM


You can simply override method as below.

def _amount_all(self, field_name, arg):
    ret_val = super(sale_order, self)._amount_all(field_name, arg)
    for order in self:
        ret_val[order.id]['field_name'] += order.new_field
    return ret_val

Hope this will help you.


Rochdi Bouslama
On 5/5/16, 5:59 PM

Hi yopi, did you create new module to do that and then you did the inheritance method ?

On 1/28/15, 1:56 AM

to Nishant Jogi, thanks a lot, it's work.

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 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

2 follower(s)


Asked: 1/28/15, 1:20 AM
Seen: 1013 times
Last updated: 5/6/16, 8:50 AM