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.

1

functions in odoo like .write, .execute etc?

By
Milva Joy
on 4/15/15, 7:42 AM 693 views

can anyone explain me the different functions available in odoo?

1
Alby Antony
On 4/15/15, 7:43 AM


on_change

please refer claim_management module submit claim

this function is used to check validation of a field on changing the value of the field

this function can pass value to the controller with in the function invocation parameters(eg: cancellation date is send as argument to controller in below code)

view file code

<field name="visa_cancellation_date" on_change="onchange_visadate(visa_cancellation_date)"/>

function definition in controller.py

def onchange_visadate(self, cr, uid, ids, visa_cancellation_date=None, context=None):

res = {'value':{}}

claim_date=time.strftime('%Y-%m-%d')

---operations to be performed on this function----

return {'value': res.get('value',{})}

.create

to insert a new row in a table

this function have a argument vals which contains all the values submitted by the form. print vals variable to know more

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

if context is None:

context = {}

print 'valsvalsvals',vals

--------operations to be performed on this---------

row_id = super(claim_submitted, self).create(cr, uid, vals, context=context)

return True

.write

this function is used to update a record in table

def action_verify(self,cr, uid, ids, context=None):

if context is None:

context = {}

self.write(cr, uid, ids, {'state': 'verify','verified_date': time.strftime('%Y-%m-%d'),'verified_id':uid}, context=context)

return True

cr.execute

to execute a query in python or in function

refer claim module in kmcc

def onchange_member_id(self, cr, uid, ids, member_id, context=None):

v={}

if member_id:

print member_id

member_id=[member_id]

cr.execute('SELECT * FROM res_users WHERE id=%s',(tuple(member_id)))

res = cr.fetchone()

print '########res_users##########',res

return {'value':v}

0

You Can see more info Here

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: 4/15/15, 7:42 AM
Seen: 693 times
Last updated: 4/15/15, 11:26 AM