Odoo’s Coding Tips
Some Odoo tips found during my development.
This author has yet to write their bio.Meanwhile lets just say that we are proud Kitti Upariphutthiphong contributed a whooping 45 entries.
Some Odoo tips found during my development.
ประเภทของ ondelete option ใน fields.Many2one มีอยู่ด้วยกัน 3 แบบ fields.Many2one(‘model’, ondelete=’cascade‘) หมายความว่า ถ้าข้อมูลรายการของ model ที่ถูกอ้างถึงถูกลบ รายการผู้อ้างก็จะถูกลบไปด้วย fields.Many2one(‘model’, ondelete=’restrict‘) หมายความว่า ถ้าข้อมูลรายการของ model ที่ถูกอ้างถึงถูกลบ ระบบจะเตือนว่ามีรายการอื่นที่ยังอ้างถึงอยู่และระบบจะไม่ยอมให้ลบ fields.Many2one(‘model’, ondelete=’set null‘) หมายความว่า ถ้าข้อมูลรายการของ model ที่ถูกอ้างถึงถูกลบก็ยอมให้ลย แต่ระบบจะ set null ในฟิลด์นี้ของรายการที่อ้ง การประกาศว่า cascade แต่ละแบบเหมาะสมกับแต่ละสถานการณ์ไม่เหมือนกัน Cascade มักใช้กับ Document ที่มีส่วนหัวและส่วนรายการที่ถึงเป็นเอกสารเดียวกัน อย่างเช่น Sales Order มี Sales Order Line, ใน sales order line จะมีการสร้าง order_id = fields.Many2one(‘sale.order’, ondelete=’cascade’) ซึ่งจะให้เมื่อ […]
Though I have done a lot of coding in Odoo, but after I bought the book Odoo 10 Development Essential and start reading it. It reminds me many of the command that I forgot. Here are some of them.
Ecosoft Co., Ltd.
6/F NST One Building, 281/19-23, Room 604, Silom Road, Silom, Bangrak, Bangkok Thailand 10500
Phone: +66 (8) 1 841 7480, +66 (6) 1 860 1994
sales@ecosoft.co.th