Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
259 Lượt xem


_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


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Tác giả

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!

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 25
2737
1
thg 7 25
1093
1
thg 8 25
1151
0
thg 5 25
1521
2
thg 4 25
3710