Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I need to do importing in openerp with the following scenario.
I have already a set of records in my system. And the form values are similar to this.
- Course Name (For now i'll call this as main record)
- Course ID
- Subjects (one2many record) (For now i'll call this as sub record)
- Subject Name
- Total Marks
Now when i import another set of records i would like the importing functionality to perform like below
- Create main record if data in the main record doesn't exist already
- Update main record if data in the main record exist already
- If main record data exist and one of the sub record doesn't exist create a sub record and map it to main record
- If main record data exist and sub records also exist then update the sub records with new values
Is it possible to do all the above with openerp default importing functionality. From my knowledge i see that if the importing record doesnt have the id then it creates a new record and if id exist then it updates. Not sure how it works for sub records as i don't find any id for them.
So the clue i have is i am able to update a record with the export id of the record.
Kindly feel free to edit the question if it's not of better clarity. Hope i've narrated the issue in an understandable manner. Thanks for your time.
For starters, this has to be broken into two imports, since it's affecting two distinct objects. You have to do courses first, then subjects.
You can just put in a random unique string as the ID, I believe it will be assigned the XML ID of "_import_.<your id="" string="">". I'd say export all of your current courses to get XML IDs for all of them. Then include those XML IDs as the ID when re-importing so you don't duplicate.
I don't think you can import one2many records in a single import, but you can definitely import many2one IDs. You'll need to import all the courses first, then on the subject import file, use the XML ID of the course in the course_id field within the subject. It'll find the course record and link to it. Since one2many fields are just aggregations of many2one fields, as long as the many2one field is correctly added on the subjects import, they should be listed on the courses when you're done.
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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 10/4/13, 3:53 PM|
|Seen: 1118 times|
|Last updated: 3/16/15, 8:10 AM|