Skip to Content
Menu
This question has been flagged
2 Replies
266 Zobrazenia


_columns = {

'credit': fields.integer( 'Credit', help='Project Credit'), 

'money': fields.integer( 'Money', help='Project Money'),  

}

def _calculate_rate(self, cr, uid, ids, money, context=None):

res = {}

for record in self.browse(cr, uid, ids, context=context):

res[record.id] = record.money * 100

return res

def on_change_credit_id(self, cr, uid, ids,money, context=None):

print ('-----------------------Credit--------------------')

res = {'value':{'credit': self._calculate_rate(self, cr, uid, ids, money,context=context),

----------------> TypeError: _calculate_rate() got multiple values for keyword argument 'context'

Who can help me please


Avatar
Zrušiť
Best Answer

Abdelwahed,

Ramadan Kareem.

You must not depend on 'ids' when its an onchange!

The onchange might get called up when the record is unsaved. I observed that you used browse() on _calculate_rate.

Rather the call from your onchange should be treated specially, like context.get('from_onchange'), then use money value from method, not from browse().

Thanks.

Avatar
Zrušiť
Autor

Ramadan Kareem. Thanks a lot for your help really!! It was solved. But can you please help me on this question : https://www.odoo.com/fr_FR/forum/help-1/question/print-many2one-field-display-false-in-odoo-87282

Replied there. In case you did not go through complete training,do tell us on contact@serpentcs.com. We hope you are safe from today's attack!

Best Answer

sure it has multiple values...you have a typo error:

res = {'value':{'credit': self._calculate_rate(self, cr, uid, ids, money,context=context),

you do not need second 'self' argument when you call _calculate_rate method...

Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
2
aug 25
2742
1
júl 25
1095
1
aug 25
1151
0
máj 25
1521
2
apr 25
3713