一个many2many的问题
-
many2many字段在画面上是不显示的吗?比如下面的代码,students是many2many类型的,view中也有<field name="students"/>的描述,但是显示出来的画面上却没有学生的相关信息。
lesson.py<br />class oecn_training_lesson(osv.osv):<br /> _name = "oecn.training.lesson"<br /> _discription = "OECN 培训课程"<br /> _columns = {<br /> "name": fields.char(u"课程名", size=64, select=True),<br /> "date_start": fields.date(u"开始日期", select=True),<br /> "total_day": fields.float(u"总天数", digits=(16, 1)),<br /> "teacher": fields.many2one("res.users", u"授课老师"),<br /> "students": fields.many2many("res.partner", "lesson_student_rel", "lesson_id", "student_id", u"学生"),<br /> "price": fields.float(u"价格", digits=(16, 2)),<br /> }<br />oecn_training_lesson()<br />
lesson_view.xml<br /> <!--定义表单视图 --><br /> <record model="ir.ui.view" id="oecn_training_lesson_from_view"><br /> <field name="name">课程表单</field><br /> <field name="type">form</field><br /> <field name="model">oecn.training.lesson</field><br /> <field name="arch" type="xml"><br /> <field name="name" /><br /> <field name="date_start" /><br /> <field name="total_day" /><br /> <field name="price" /><br /> <field name="teacher" /><br /> <field name="students"/><br /> </field><br /> </record><br />
显示的画面上并没有student(学生)的信息,这是为什么呢?
[img [检测到链接无效,已移除] /img] -
<br /><br /><!--定义表单视图 --><br /> <record model="ir.ui.view" id="oecn_training_lesson_from_view"><br /> <field name="name">课程表单</field><br /> <field name="type">form</field><br /> <field name="model">oecn.training.lesson</field><br /> <field name="arch" type="xml"><br /> <form string="Lesson"><br /> <field name="name" /><br /> <field name="date_start" /><br /> <field name="total_day" /><br /> <field name="price" /><br /> <field name="teacher" /><br /> <field name="students"/><br /> </form><br /> </field><br /> </record><br /><br />
-
[quote author=mrshelly link=topic=5844.msg14660#msg14660 date=1364476200]
<br /><br /><!--定义表单视图 --><br /> <record model="ir.ui.view" id="oecn_training_lesson_from_view"><br /> <field name="name">课程表单</field><br /> <field name="type">form</field><br /> <field name="model">oecn.training.lesson</field><br /> <field name="arch" type="xml"><br /> <form string="Lesson"><br /> <field name="name" /><br /> <field name="date_start" /><br /> <field name="total_day" /><br /> <field name="price" /><br /> <field name="teacher" /><br /> <field name="students"/><br /> </form><br /> </field><br /> </record><br /><br />Thanks.......<br /><br />
[/quote]