Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
12805 มุมมอง

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  "

 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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)

 

อวตาร
ละทิ้ง
ผู้เขียน

Thank you very much. This is the best answer

คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.ย. 23
6314
Insert query in odoo 13 แก้ไขแล้ว
1
ก.ค. 20
5076
0
ธ.ค. 23
8212
0
มี.ค. 15
3317
0
มี.ค. 15
3552