Odoo Help

Welcome!

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.

1

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

By
yopi
on 1/28/15, 1:20 AM 908 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:

...

    @api.multi
    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(
                reslt[orders.id]['discount_fidelity'])
            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.

Thanks.

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

Hi,

You can simply override method as below.

@api.multi
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.

Thanks.

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

0
yopi
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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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