Em 23/01/2014 11:05, Cédric Krier escreveu:
On 23 Jan 10:34, Gmail - Iasmini wrote:
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'

It must be:

     @classmethod
     def _compute_tax(cls, invoice_tax, invoice_type):
         super(Invoice, cls)._compute_tax(invoice_tax, invoice_type)



Ok.


May you please answer this question?

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?

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?

Thank you,

--

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

Reply via email to