Tutorial Odoo 9.0 Part 5 : Relations between models
จาก Morange Wiki
รุ่นแก้ไขเมื่อ 09:43, 14 กรกฎาคม 2559 โดย Sirawich (คุย | มีส่วนร่วม) (หน้าที่ถูกสร้างด้วย '<h3>Relations between models</h3> แก้ไขไฟล์ดังนี้ <h3>openacademy/models.py</h3> <pre> name = fields....')
Relations between models
แก้ไขไฟล์ดังนี้
openacademy/models.py
name = fields.Char(string="Title", required=True) description = fields.Text() class Session(models.Model): _name = 'openacademy.session' name = fields.Char(required=True) start_date = fields.Date() duration = fields.Float(digits=(6, 2), help="Duration in days") seats = fields.Integer(string="Number of seats")
openacademy/views/openacademy.xml
<!-- Full id location: action="openacademy.course_list_action" It is not required when it is the same module --> <!-- session form view --> <record model="ir.ui.view" id="session_form_view"> <field name="name">session.form</field> <field name="model">openacademy.session</field> <field name="arch" type="xml"> <form string="Session Form"> <sheet> <group> <field name="name"/> <field name="start_date"/> <field name="duration"/> <field name="seats"/> </group> </sheet> </form> </field> </record> <record model="ir.actions.act_window" id="session_list_action"> <field name="name">Sessions</field> <field name="res_model">openacademy.session</field> <field name="view_type">form</field> <field name="view_mode">tree,form</field> </record> <menuitem id="session_menu" name="Sessions" parent="openacademy_menu" action="session_list_action"/> </data> </openerp>