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

Is there a way I can override the value of an existing function? I wanted to override the value of the variable, transactions.


def _query_avatax_taxes(self, commit):

if not self:

return {}

if not self.company_id.sudo().avalara_api_id or not self.company_id.sudo().avalara_api_key:

raise RedirectWarning(

_('Please add your AvaTax credentials'),

self.env.ref('base_setup.action_general_configuration').id,

_("Go to the configuration panel"),

)

client = self._get_client(self.company_id)

transactions = {record: record._get_avatax_taxes(commit) for record in self}

return {

record: client.create_transaction(transaction, include='Lines')

for record, transaction in transactions.items()

}


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

Hi, 

You can change the variable value and super the function to achieve this.

def _query_avatax_taxes(self, commit):
    transactions = # Your updated transactions
    return super()._query_avatax_taxes()


Hope it helps

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

Hi,

If you see the code, the value to transactions is returned form the function _get_avatax_taxes , so you can just inherit this function and make the changes in it.

And this hook may be made for the same purpose.

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 24
1673
1
thg 5 23
3536
0
thg 5 16
3426
2
thg 12 15
3482
0
thg 6 25
900