I am trying to modify an OpenERP addon called mrp_bom_history to get default values from the existing bom lines as default value.
I have made a _read_line method to return a list of bom_line ids similar to how to initialize a default one2many fields in OpenERP, but I get an 'Record not correctly loaded' exception, and I am having trouble figuring out why.
Python code from save_bom_history.py:
class save_bom_history(osv.osv_memory):
def _read_line(self,cr,uid,context=None):
bom = self.pool.get('mrp.bom').browse(cr,uid,context['active_id'])
result = []
for lines in bom.bom_lines:
result.append(lines.id)
return result
_name = "save.bom.history"
_columns = {
'name' : fields.char('Name'),
'cut_off_date' : fields.date('Cut-off Date'),
'new_bom_ids' : fields.one2many('save.bom.history.line','\
wizard_id','New Bill of Material'),
}
_defaults = {
'name' : "History",
'cut_off_date' : time.strftime('%Y-%m-%d'),
'new_bom_ids' : _read_line,
}