跳至內容
選單
此問題已被標幟
2 回覆
277 瀏覽次數


_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


頭像
捨棄
最佳答案

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.

頭像
捨棄
作者

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!

最佳答案

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...

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
8月 25
2745
1
7月 25
1095
1
8月 25
1151
0
5月 25
1521
2
4月 25
3713