Contributors mailing list archives

contributors@odoo-community.org

Re: How to write hook addon properly.

by
Ecosoft, Kitti Upariphutthiphong
- 07/03/2019 07:55:39
Hello Jordi,

Thanks for clarification

On Thu, Mar 7, 2019 at 11:37 AM Jordi Ballester Alomar <jordi.ballester@eficent.com> wrote:
Hi Kittj,

You do this to respect the inheritance chain. Just overriding the method will kill it.




El jue., 7 mar. 2019 4:52, Kitti Upariphutthiphong <kittiu@ecosoft.co.th> escribió:
Dear all

I am looking for the right way to write a hook addon when working with OCA modules.


I see that, it is doing things like this in hooks.py

def post_load_hook():
def new_action_invoice_create(self, grouped=False, final=False):

if not hasattr(self, '_get_invoice_group_key'):
return self.action_invoice_create_original(grouped=grouped,
final=final)

From what I see, since this module is being installed, the new_action_invoice_create() will be used always anyway. I am trying to understand why we would need to do this, instead of directly overwrite method with hook point ?

Thank you for your support.
Kitti U.

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe