Hi. im just new in Odoo, please guide me thanks
here is my scenario:
1.) I made a module name 'Shipping information' module here is my .py code
from openerp.osv import osv,fields
class si(osv.osv):
_name='si'
_columns ={
'addr':fields.char('Shipping Address',size=100,required=True),
'current':fields.boolean('Current'),
}
si()
as you can see it has 2 fields 1.) Shipping Address(char) which the user will input his address, 2.) Current (boolean), each address contains 'current' field wherein it is with a 'button'.. if the user clicks the button it will toggle the boolean field of a certain record to 'true'.. here is my xml (just a snippet, dont worry it has no defect)
here is the image to better appreciate : http://postimg.org/image/k0gjwlmcj/
<record model="ir.ui.view" id="view_si_tree">
<field name="name">si.tree</field>
<field name="model">si</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Shipping Information">
<field name="addr" />
<button name="btnSet" string="Set" type="object"/>
</tree>
</field>
</record>
as you can see i use type='object' (or am i wrong? ) because i will call a function which contains the query, im planning to make this function and add to .py file, unfortunately im not able to do that because the function is not finish yet.. can you help me? i want that when the button is pressed it will toggle the boolean variable to 'true' of that certain id.. how can i link this to the button i have made in the xml?
def set_current_addr(self,cr,uid,ids,name,arg,context=None):
res={} #is this necessary? i just saw it in other sites
cr.execute("""UPDATE si SET current='true' where id=ids;""")
return res #is this necessary? i just saw it in other sites
Please guide me so that i can continue my learning in odoo.
also is 'uid' in the function there the create_id i and the 'ids' the id n openerp?
Hey ! I hope you got the answer from the below. If yes then please accept it. Thanks.