On Mon, Apr 23, 2012 at 2:38 AM, Olivier Dony <[email protected]> wrote:
> On 04/20/2012 08:01 PM, Ovnicraft wrote: > > Hello we are working with hr_payroll module, so we implement another > module > > inherit from it. > > Here is our case: > > > > A hr_payroll (core openerp) > > B hr_payroll_b (custom module) here we redefine compute_sheet method > > C hr_payroll_c (another custom module) here we redefine compute_sheet > again but > > we need run compute_sheet redefined in B module but sytem calls method > from A. > > * Option 1 (not your case apparently) > If your dependencies are the following: C -> B -> A (hr_payroll) > then your don't need to do anything, because when you call super() in C's > compute_sheet() you will call B's compute_sheet(). And then probably B > should > call super() at some point to make sure the original hr_payroll method is > called. > Hello, This is my case but in my class when call C super() it does not calls B definition, so it calls A definition. That is why i am getting wrong. > > * Option 2 (looks like your case) > If your dependencies are the following: > B --> A (hr_payroll) > C --> A (hr_payroll) > and you still need C to call B's method, then something is wrong in your > design. In such a case the hierarchy depends on the ORM module loading > order > Totally agree but is not my case. > (you can't really control it unless you put an explicit dependency). B > could > have C as parent, or C could have B as parent, it depends. So they must be > clearly independent of each other. If they're not, you have to fix your B > and C > implementation to make sure they are properly calling super() and can be > invoked in any order. > Or if you _really_ need to make B and C aware of each other without having > a > direct dependency between them you can add a third "link module" D with: > 'depends': ['B', 'C'], > 'auto_install': True > It will be installed as soon as B *and* C are installed (6.1+ only) and > can be > used to make them work together, as it knows it will have B and C as > parents. > This is a bit similar to the project_mrp module making the connection > between > project and mrp modules. But don't touch the MRO! > Best regards, > > > > Reading about MRO[1] in Python , i need to know how to solve this issue > in > > OpenERP and if system support this. > > You should never touch the MRO to alter OpenERP models inheritance, or at > all. > This is a Python implementation detail and the ORM takes care of managing > it > properly when you use OpenERP inheritance. If you need to mess with it your > design is probably bad and certainly too complicated. > > Hope this helps... > -- Cristian Salamea @ovnicraft
_______________________________________________ Mailing list: https://launchpad.net/~openerp-expert-framework Post to : [email protected] Unsubscribe : https://launchpad.net/~openerp-expert-framework More help : https://help.launchpad.net/ListHelp

