Odoo Help

Welcome!

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

0

How to use create and write on function fields

By
Jihen BEN ALI
on 5/12/16, 12:50 PM 265 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

IBS

--IBS--
1302
| 4 5 8
Tétouan, Morocco
--IBS--

For more informations about IBS, please visit our website at www.ibs-na.com.

For a specific questions, collaboration or help, please send us an email to support@ibs-na.com

IBS
On 5/12/16, 1:16 PM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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