تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
3395 أدوات العرض

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.

الصورة الرمزية
إهمال
أفضل إجابة

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.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
3
يوليو 25
1938
1
أبريل 25
1441
0
أكتوبر 24
1202
2
مايو 24
6456
2
مايو 24
4009