Odoo Help

0

How to use create and write on function fields

By
Jihen BEN ALI
on 5/12/16, 12:50 PM 617 views

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

0
odoo.ma by IBS Group
On 5/12/16, 1:16 PM

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

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 5/12/16, 12:50 PM
Seen: 617 times
Last updated: 5/13/16, 3:28 AM