This question has been flagged
1 Reply
5223 Views

I have created a small module  to update the Employee client records . I have attached the screenshot of the form view . Also created the workflow with states . 

In the form view i created one field  of one2many  type , and i wann to display  all the previous records created  whn the state is reached to approved .

http://www.mygeekstyle.in/2014/08/image.html

How to achieve this .

Avatar
Discard
Best Answer

You have to create a model that memorize the historical information of the record (either exactly the same set of fields or just select fields + some version indicator).  Then in every changes that you want to log (you can inherit create, write, and unlink method for this purpose) save a copy of the old values into that historical informatioin model.

Avatar
Discard
Author

The records are already stored , i can view them in the tree view , but its not showing in the form view one2many field .

If the records that hold the historical values have been stored, has it been linked to the main model, i.e. the model should have one2many to the historical value records and the historical value record should have many2one to the main model.

Author

Yes i have one one2many and many2one relations liked to the main model "sicon.client.details" , but still in the xml form view the record dosent show up . In python file : 'employee_line': fields.one2many('sicon.client.details', 'sicon_client_id', 'Historical Entries', size=64), 'sicon_client_id':fields.many2one('sicon.client.details','Sicon Client Details'), In Xml file : Am i still missing on something .

Have you checked the table in the database whether sicon_client_id field is populated at all?

Author

I checked the in database , the field sicon_client_id is thr but no data tht .

Well, there is your problem. The sicon_client_id in your code is the Foreign Key that ties the between 2 related sicon.client.details. So, everytime a new record is created, all records that are considered the old record of this new record need to have the sicon_client_id populated with the new record's ID to estblish the relation.

Author

how to achieve that , any example or in it implemented in openerp code .

The short answer, as I've mentioned, is to populate the field everytime a new record is created. Technically it means inheriting the create method of sicon.client.details models, then, after the super of the method is called, search for all records that is considered the "history" then update (write) the sicon_client_id field using the newly created record's ID (return from the super) . I'm afraid I would not be able to help further without knowing the details.