Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
11138 มุมมอง

i have two class x and y

class x_obj(osv.osv):

   _columns ={

        fields ..........

      x_id:fields.many2one('y.obj')

                 }

x_obj() 


class y_obj(osv.osv):

_columns ={

fields ..........

y_id:fields.one2many('x.obj', 'x_id', 'x_child'),

}

y_obj()

I have form view that retrieves all records in x_obj table based on certain condition 

but what i am facing is i don't want a new record to be created in x_table except y_obj's reference only to be updated in existing x_object table records when i save the record in y_obj, and how can really retrieve child x_obj's id through  y_id field i can access all fields but i couldn't get x_obj's id through one2many field reference 


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Please Check existing Answers check in Google or check in help forrum.Its a duplicate question,

Just call the super of parent class


https://www.odoo.com/forum/help-1/question/how-to-use-create-and-write-function-18592

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Learn how to override create method in Odoo v8 using API with example,

http://odootechnical.com/learn-overriding-create-method-in-odoo-8/

Learn how to override write method in Odoo v8 using API with example,

http://odootechnical.com/learn-overriding-write-method-in-odoo-8/

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

@Dep Thanks for your help but the link you referred is not helping me in my case, I am in y_obj's form and wants change the status for created records in x_obj  (using one2may reference) table but instead it is creating a new record with updated state and x_id but what i want is i only wanted the state to be changed and the reference id which is x_id

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
เม.ย. 20
3632
1
พ.ย. 17
3811
update fields on write() method แก้ไขแล้ว
2
ม.ค. 16
35049
6
ส.ค. 19
62427
2
ส.ค. 19
4329