Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Inheritance - How to Inherit From Another Addon

on 3/19/15, 10:51 AM 369 views

Let's say that you have one addon that does basically what you want it to do.  However, what it does when it inherits another class should be tweaked. For instance, account/account_invoice.py has:

class mail_compose_message(models.Model):
_inherit = 'mail.compose.message'

def send_mail(self):
context = self._context
if context.get('default_model') == 'account.invoice' and \
context.get('default_res_id') and context.get('mark_invoice_as_sent'):
invoice = self.env['account.invoice'].browse(context['default_res_id'])
invoice = invoice.with_context(mail_post_autofollow=True)
invoice.write({'sent': True})
invoice.message_post(body=_("Invoice sent"))
return super(mail_compose_message, self).send_mail()

If I inherit mail_compose_message and update something, say set 'sent' to False, the account_invoice code runs afterwards and sets it back to True.

In this example, how do I inherit send_mail() method AFTER the code above is run to set sent or mail_post_autofollow to False? 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)


Asked: 3/19/15, 10:51 AM
Seen: 369 times
Last updated: 3/19/15, 10:51 AM