On 22 Jan 16:55, Gmail - Iasmini wrote:
Hi,
As I've said before, I created the same new fields on account_tax and
account_invoice_tax. I created a new tax and filled those fields.
What I want is: when I insert a new product on a invoice those fields
must to be filled with the same information that was registered when
I configured the tax of this product.
To get this I need to modify Invoice._compute_tax.
Invoice._compute_tax is static. But I need to override this method to
include the new fields. How can I do?
>You can see all staticmethod as classmethod which don't need in the
>code the cls, so you can override them using a classmethod.
This way I'll have to copy the method to my module and modify it, right?
Because when I try to do:
@classmethod
def _compute_tax(cls, invoice_tax, invoice_type):
super(Invoice)._compute_tax(invoice_tax, invoice_type)
It gives me the error: AttributeError: 'super' object has no attribute
'_compute_tax'
Traceback (most recent call last):
File "/trytond/protocols/jsonrpc.py", line 123, in _marshaled_dispatch
response['result'] = dispatch_method(method, params)
File "/trytond/protocols/jsonrpc.py", line 156, in _dispatch
res = dispatch(*args)
File "/trytond/protocols/dispatcher.py", line 174, in dispatch
result = rpc.result(meth(inst, *c_args, **c_kwargs))
File "/trytond/modules/nfse_br/invoice.py", line 193, in on_change_lines
changes = super(Invoice, self).on_change_lines()
File "/trytond/modules/account_invoice/invoice.py", line 426, in
on_change_lines
return self._on_change_lines_taxes()
File "/trytond/modules/account_invoice/invoice.py", line 456, in
_on_change_lines_taxes
self.type or 'out_invoice')
File "/trytond/modules/nfse_br/invoice.py", line 159, in _compute_tax
super(Invoice)._compute_tax(invoice_tax, invoice_type)
AttributeError: 'super' object has no attribute '_compute_tax'
I'm a bit confused:
1. When I do a new module and I want to change something in a core
module I create a file with the same name as the core. This is
considered a inheritance or partial class?
a. If inheritance, how can I refer to superclass without using super,
because I want the class instead of the instance? Because both have the
same name.
b. If partial class (I don´t know if it exists on Python) Tryton do a
mixin and replaces the conflicts names with the names of the second class?
--
Iasmini Gomes
Sílex Sistemas
www.silexsistemas.com.br
---
Este email está limpo de vírus e malwares porque a proteção do avast! Antivírus
está ativa.
http://www.avast.com