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

Hello everyone,

I have a new object and I need to write on the field 'credit' on the class account.account which is a function fields how can I do it and thanks a lot

class kms_remise(osv.osv):

_name='account.check.remise'

def create(self, cr, uid, vals, context=None):

result = super(kms_remise, self).create(cr, uid, vals, context=context)

check_remise_obj = self.browse(cr, uid, result, context=context)

bank_account = check_remise_obj.bank.id

bank_name = check_remise_obj.bank.journal_id.name

print 'bank_name', bank_name

account_obj= self.pool.get('account.account').search(cr, uid, [('name','=',bank_name)])

print 'account_obj', account_obj

if bank_account:

for check in check_remise_obj.check_line:

bank_amount = check.amount

print ' bank_amount', bank_amount

self.pool.get('account.voucher').write(cr, uid, check.id,{'bank':bank_account})

self.pool.get('account.account').write(cr, uid, account_obj,{'credit':bank_amount})

return result

_columns = {

'bank': fields.many2one('res.partner.bank', 'Bank account'),

'check_line': fields.many2many('account.voucher','check_remise_ref','remise_id','voucher_id','Checks List'),

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

Computed fields are not supposed to be modified directly, you need to change your strategy.

Ảnh đại diện
Huỷ bỏ