Does anyone who knows how to set parent_id while creating it's child on onchange method? The case is this, i have my class installment and installment_schedule. These are some of its definition:
class installment(orm.Model):
_name = 'installment'
_columns = {
'date_start' : fields.date('Date Start'),
'date_end' : fields.date('Date End'),
'factor' : fields.function(_get_factor,.....),
'child_ids': fields.one2many('installment.schedule','parent_id','Schedule'),
}
def on_change_fields(self, cr, uid, ids, d_start, d_end, factor, context=None):
i = seq = 0
range = 24
sched_obj = self.pool.get('installment.schedule')
while seq < range:
while i < factor:
date = datetime.strptime(date_start, '%Y-%m-%d') + relativedelta(months=+i)
sched_obj.create(cr,uid,{
"regular_date" : date.strftime('%Y-%m-%d'),
"seq" : seq,
}
i += 1
seq += 1
return True
...
installment()
class installment_schedule(orm.Model):
...
_columns = {
'parent_id' : fields.many2one('installment','Installment'),
'regular_date' : fields.date('Regular Date'),
'seq' : fields.integer('Sequence'),
}
...
installment_schedule()
What i want is whenever that three fields (in installment class) are being change i also want to populate the installment_schedule class and at the same time show it on my installement_view.xml.
Any help/suggestion/recommendation is highly appreciated