Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
9065 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 4 22
12240
4
thg 1 19
32052
1
thg 3 17
8179
0
thg 5 16
3885
0
thg 3 16
3099