openerp 7 create method override -


i new openerp 7 programming. have created booking module allows guest book more 1 room. want able change room status available booked when creating new reservation. solution kind of scenario seems overriding create or write orm methods openerp.

i don't know how incorporate in code. below part of code.

class reservation(osv.osv):     _columns = {             'name': fields.char('reservation no', required=true, select=true, readonly=true),             'date_order':fields.datetime('date ordered', required=true, readonly=true),             'reserved_rooms': fields.one2many('hotel.reservation.line','line_id', 'reserved rooms'),             'state': fields.selection([('draft', 'draft'),('confirmed','confirmed'),('cancelled','cancelled'),('done','done')], 'state',readonly=true),     } reservation()  _defaults = {         'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid,'hotel.reservation'),         'state': lambda *a: 'draft',         'date_order': lambda *a: time.strftime('%y-%m-%d %h:%m:%s') } 

the reservation created default state draft. how , in code put , use create or write method? thanks.

try following,

class reservation(osv.osv):     _columns = {             'name': fields.char('reservation no', required=true, select=true, readonly=true),             'date_order':fields.datetime('date ordered', required=true, readonly=true),             'reserved_rooms': fields.one2many('hotel.reservation.line','line_id', 'reserved rooms'),             'state': fields.selection([('draft', 'draft'),('confirmed','confirmed'),('cancelled','cancelled'),('done','done')], 'state',readonly=true),      }      _defaults = {         'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid,'hotel.reservation'),         'state': lambda *a: 'draft',         'date_order': lambda *a: time.strftime('%y-%m-%d %h:%m:%s')      }      def create(self, cr, uid, vals, context=none):         ###add code here         ####update status in vals         return super(reservation,self).create(cr, uid, vals, context=context)      def write(self, cr, uid, ids, vals, context=none):         ###add code here         ####update status in vals         ## fields vals updated.         return super(reservation,self).write(cr, uid, ids, vals, context=context) 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -