Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

Best Practice for Module Design

by
MoaHub, Graeme Gellatly
- 30/12/2016 01:24:34
Hi,

I'm just refactoring some modules at the moment.  One of these is a custom version of sale_intercompany_auto.  Essentially it just extends the existing behaviour and adds some fields based on the sum of all other custom modules.

Now it has occurred me that perhaps a smarter way is that, in existing modules to just to do the inheritance and override there.

For example

Module A - add field a to sale order and purchase order

def _do_something_automatically(self):
   res = super()
   res.update(field a)
   return res

Module B - add field b to sale order and purchase order

def _do_something_automatically(self):
   res = super()
   res.update(field b)
   return res

As these functions are only called by the inter_company_rules module, I am thinking I can allow for the possibility that it might be installed, but not need to worry if it isn't, and not declare an explicit dependency.

Thoughts?  Better ways?


Follow-Ups