Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
3 Ответы
12821 Представления

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
6315
1
июл. 20
5077
0
дек. 23
8215
0
мар. 15
3324
0
мар. 15
3553