I have created two wizards which are shown below:
from osv import fields, osv
class fee_structure(osv.osv_memory):
_name="fee.structure"
_description="Fee Structure"
_columns={
'name': fields.char('Title', size=64),
'area_id': fields.many2one('department.area', 'Area'),
'grade_id': fields.many2one('department.grade', 'Grade'),
'fee_template_ids': fields.many2many('department.fee_template', 'fee_structure_template_rel', 'fee_structure_id', 'dept_fee_template_id', 'Templates'),
'fee_ids': fields.one2many('wizard.fee', 'fee_structure_id','Extra Fee'),
}
def button_create(self, cr, uid, ids, context={}):
print '..................button_create................'
wizard_obj=self.browse(cr, uid, ids, context=context)[0]
template_ids=[]
for template_id in wizard_obj.fee_template_ids:
template_ids.append(template_id.id)
self.pool.get('institution.fee').create(cr, uid, {
'name': wizard_obj.name,
'active': True,
'area_id': wizard_obj.area_id.id,
'grade_id': wizard_obj.grade_id.id,
'fee_template_ids': [(6,0,template_ids)],
# needs to add values for field fee_ids here,
})
fee_structure()
class wizard_fee(osv.osv_memory):
_name="wizard.fee"
_description="Fee Wizard"
_columns={
'fee_id': fields.many2one('fee.fee', 'Fee'),
'amount': fields.float('Amount'),
'fee_structure_id': fields.many2one('fee.structure', 'Fee Structure'),
}
wizard_fee()
The model institution.fee
is
class institution_fee(osv.osv):
_name="institution.fee"
_description="Institution Fee"
_columns={
'name': fields.char('Fee Name', size=64),
'active': fields.boolean('Active'),
'area_id': fields.many2one('department.area', 'Area'),
'grade_id': fields.many2one('department.grade', 'Grade'),
'fee_template_ids': fields.many2many('department.fee_template', 'institution_fee_template_rel', 'inst_fee_id', 'dept_fee_template_id', 'Fee Template'),
'fee_ids': fields.one2many('department.fee_structure', 'inst_fee_id', 'Extra Fee'),
}
_defaults={
'active': True
}
institution_fee()
I have added the values of the many2one field fee_template_ids
to model institution.fee
, similarly I want to add the values to the one2many field fee_ids
using wizard.fee
to institution.fee
.
The fee.structure wizard is called from a menuitem and its use is to create a fee structure(institution.fee model).