跳至内容
菜单
此问题已终结
3 回复
12583 查看

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

形象
丢弃
相关帖文 回复 查看 活动
0
9月 23
6135
1
7月 20
4889
0
12月 23
7957
0
3月 15
3173
0
3月 15
3366