Odoo Help

Welcome!

This community 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.

0

How updation works while importing in openerp?

By
vivek
on 10/4/13, 3:53 PM 780 views

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

  • 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
    • Teacher
    • Total Marks

Now when i import another set of records i would like the importing functionality to perform like below

  1. Create main record if data in the main record doesn't exist already
  2. Update main record if data in the main record exist already
  3. If main record data exist and one of the sub record doesn't exist create a sub record and map it to main record
  4. 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.

Sample is _export_crm.lead_187

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.

0

Brett Lehrer

--Brett Lehrer--
1252
| 5 4 8
Milwaukee, United States
--Brett Lehrer--
Director of IT and open source enthusiast.
Brett Lehrer
On 10/22/13, 12:47 AM

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 10/4/13, 3:53 PM
Seen: 780 times
Last updated: 3/16/15, 8:10 AM