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

In the below fuction I want to update  "account_bank_statement" table field balance_end_real with the vale balance_end. i.e "update account.bank.statement set balance_end_real=balance_end where id=ids"

 

"def _compute_difference(self, cr, uid, ids, fieldnames, args, context=None):
        result =  dict.fromkeys(ids, 0.0)

        for obj in self.browse(cr, uid, ids, context=context):
            
            result[obj.id] = obj.balance_end_real - obj.balance_end

        return result  "

 

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

It seems that balance_end_real field already in the same model (or inherited) with the method you defined. In that case you don't need to use update sql manually, just use write method.

self.write(cr, uid, ids, {'balance_end_real': obj.balance_end}, context=context)

 

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

Thank you very much. This is the best answer

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

Hi,

You can use "cr.execute" to update record based on id. Refer the following example:

cr.execute('update account_period set state=%s where id=%s', (mode, id))

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

Use "cr.execute" and update directly using sql update statement...

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 9 23
6548
1
thg 7 20
5282
0
thg 12 23
8438
0
thg 3 15
3518
0
thg 3 15
3794