Odoo Help


Display Previous records in one to many field .

on 8/27/14, 5:52 AM 1,514 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 .


How to achieve this .




| 5 3 6
Jakarta, Indonesia
On 8/27/14, 6:44 AM

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.

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

on 8/27/14, 6:54 AM

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.

on 8/27/14, 7:39 AM

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 .

on 8/27/14, 8:08 AM

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

on 8/27/14, 9:01 AM

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

on 8/28/14, 11:28 PM

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.

on 8/29/14, 1:30 AM

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

on 8/29/14, 3:52 AM

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.

on 9/3/14, 2:40 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/27/14, 5:52 AM
Seen: 1514 times
Last updated: 3/16/15, 8:10 AM