UPLOADED MODULE TO GIT --> https://github.com/Kushikime/Invoice_currency_changer
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
Your inheritance is already fine, but you should try change _logger.debug(..
for _logger.info(
to see your logs, I got this messages from my log console the other mode start the Odoo server in DEBUG mode:
2018-07-04 07:17:34,612 13072 INFO mydatabase odoo.addons.mymodule.models.sale: PRINT TRUE IF INHERIT IS SUCCESS
2018-07-04 07:18:19,591 13072 INFO mydatabase odoo.addons.mymodule.models.sale: PRINT TRUE IF SUCCESS INHERITED
2018-07-04 07:18:23,249 13072 INFO mydatabase werkzeug: 127.0.0.1 - - [04/Jul/2018 07:18:23] "POST /longpolling/poll HTTP/1.1" 200 -
2018-07-04 07:18:49,016 13072 INFO mydatabase odoo.addons.mymodule.models.sale: Print OK if all OK
2018-07-04 07:19:03,848 13072 INFO mydatabase odoo.addons.mymodule.models.sale: PRINT TRUE IF SUCCESS INHERITED
I hope this answer can be helpful for you.