UPLOADED MODULE TO GIT --> https://github.com/Kushikime/Invoice_currency_changer
I want to change the _create_invoice() method in sale.advance.payment.inv model.
This method is called from another method of the same class create_invoices()
I was tried to inherit the method. But have success only with create_invoices()
So in result, I want to know why I can't change _create_method() (i know they called private method's but the way of inheriting must be the same I think)
Code:
#original Odoo class
class SaleAdvancePaymentInv(models.TransientModel):
_name="sale.advance.payment.inv"
...
@api.multi
def create_invoices(self):
...
self._create_invoice(order, so_line, amount)
@api.multi
def _create_invoice(self, order, so_line, amount):
...
And here is the code, how i tried to inherit methods:
class myClass(models.TransientModel):
_inherit="sale.advance.payment.inv"
#INHERITING create_invoices() **SUCCESS INHERITED**
@api.multi
def create_invoices(self):
_logger.debug("PRINT TRUE IF INHERIT IS SUCCESS")
#HERE ODOO PRINT THE MESSAGE SUCCESS.
...
self._create_invoice(order, so_line, amount)#HERE I TRY TO CALL THE METHOD WHICH I WAS CREATED FOR INHERITING
_logger.debug("Print OK if all OK")
#HERE ODOO IS NOT PRINT ANYTHING
res = super(myClass, self).create_invoices()
return res
#HERE I TRY TO INHERIT THE ORIGINAL _create_invoice() method
@api.multi
def _create_invoice(self, order, so_line, amount):
_logger.debug("PRINT TRUE IF SUCCESS INHERITED")
#IN DEBUG LOGS ODOO DIDN'T PRINTED ANYTHING HERE
So it's look like after i call _create_invoice() in my inherited method, odoo from that point start to use the code from original class and not from myClass().
any help will be appreciated