I just found out that write() method only loads vals of fields that have been changed or altered. How can I force it to load a field that has not been changed or altered.
In my code below I am trying to have the write() method to load prod_id value which is the id of the product created by the create() method.
[code]
class intrac_courses(osv.osv):
def create(self, cr, uid, vals, context=None):
if not vals:
vals = {}
if context is None:
context = {}
product_name = vals.get('name', '1')
product_fee = vals.get('course_fee', '0.0')
product_desc = vals.get('course_outline', '')
product_obj = self.pool.get('product.template')
product_type = 'service'
vals['prod_id']= product_obj.create(cr, uid, {'name' : product_name, 'type': product_type, 'list_price': product_fee, 'description': product_desc }, context=context)
return super(intrac_courses, self).create(cr, uid, vals, context=context)
def write(self, cr, uid, ids, vals, context=None):
product_id = vals.get('prod_id', 'unable to load product id')
product_name = vals.get('name', 'unable to load product name') #this is not able toload
product_fee = vals.get('course_fee', '0.0')
product_desc = vals.get('course_outline', '')
product_obj = self.pool.get('product.template')
product_type = 'service'
product_obj.write(cr, uid, [product_id], {'name' : product_name,'type': product_type, 'list_price': product_fee, 'description': product_desc }, context=context)
return super(intrac_courses, self).write(cr, uid, ids, vals, context=context)
_name = 'intrac.courses'
_columns = {
'prod_id': fields.char('Product ID'),
'course_id': fields.char('Course ID'),
'course_category': fields.selection([('General English','General English'),('Intensive English','Intensive English'),('English for Special Purposes','English for Special Purposes'),('Business Edge','Business Edge'),('Information Technology','Information Technology'),('Other','Other')], 'Course Category', required=True),
'name': fields.char('Course Name', size=100, required=True),
'course_arabic_name': fields.char('Arabic Name', size=100),
'course_long_name': fields.char('Long Name', size=200, required=True),
'course_duration': fields.integer('Duration (Hours)', required=True),
'course_fee': fields.char('Fees Per Trainee'),
'course_outline': fields.html('Course Outline & Details'),
'course_notes': fields.one2many('intrac.courses.notes', 'course_name', 'Course Notes'),
}
intrac_courses()
[/code]