openerp-india team mailing list archive
-
openerp-india team
-
Mailing list archive
-
Message #08804
[Bug 893079] Re: [6.1] impossible to call super in ids getter method of store from function field : wrong self type
This may be relevant.
http://thingspython.wordpress.com/2010/09/27/another-super-wrinkle-raising-typeerror/
--
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/893079
Title:
[6.1] impossible to call super in ids getter method of store from
function field : wrong self type
Status in OpenERP Server:
Confirmed
Bug description:
Hello,
I found that it is impossible to override a method used in a stored
function field.
For exemple, I try to extend account.analytic.line depending on /analytic_multicurrency/account_analytic_line.py .
This for the following fields :
_columns = {
'aa_currency_id': fields.function(_get_account_currency, method=True, type='many2one', relation='res.currency', string='Account currency',
store={
'account.analytic.account': (_get_account_line, ['currency_id','company_id'], 50),
'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount','product_uom_id'],10),
},
help="The related analytic account currency."),
'aa_amount_currency': fields.function(_amount_currency, method=True, digits=(16, int(config['price_accuracy'])), string='Amount currency',
store={
'account.analytic.account': (_get_account_line, ['currency_id','company_id'], 50),
'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount','product_uom_id'],10),
},
help="The amount expressed in the related analytic account currency."),
'company_id': fields.related('general_account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
}
Now, here are the problems :
1) To extend the triggers on multi, by adding one new object to check, I have to rewrite the whole store dict
2) I will have to redefine _get_account_line or any trigger method as it seems out of scope for store triggering.
3) I can't use 'super' in rewritten method. -> no override is possible
No inheritance is possible because the 'self' which is given by the
trigger is an instance of the triggering object calling a method of
the triggered object.
I also tried to define the function that way :
from analytic_multicurrency import account_analytic_line
_get_account_line = account_analytic_line.account_analytic_line._get_account_line
Still the error on store load is
TypeError: unbound method _get_account_line() must be called with
account_analytic_line instance as first argument (got
account.analytic.account instance instead)
The only way I found is to rewrite the whole getter method in my new class. That's a bit dirty.
My running python : Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
Yannick
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/893079/+subscriptions
References