Odoo中文社区可以通过以下两个域名访问:shine-it.net , odoo.net.cn

由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

一个many2many的问题



  • many2many字段在画面上是不显示的吗?比如下面的代码,students是many2many类型的,view中也有<field name="students"/>的描述,但是显示出来的画面上却没有学生的相关信息。

    lesson.py

    <br />class oecn_training_lesson(osv.osv):<br />&nbsp; &nbsp; _name = &quot;oecn.training.lesson&quot;<br />&nbsp; &nbsp; _discription = &quot;OECN 培训课程&quot;<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;name&quot;: fields.char(u&quot;课程名&quot;, size=64, select=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;date_start&quot;: fields.date(u&quot;开始日期&quot;, select=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;total_day&quot;: fields.float(u&quot;总天数&quot;, digits=(16, 1)),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;teacher&quot;: fields.many2one(&quot;res.users&quot;, u&quot;授课老师&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;students&quot;: fields.many2many(&quot;res.partner&quot;, &quot;lesson_student_rel&quot;, &quot;lesson_id&quot;, &quot;student_id&quot;, u&quot;学生&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;price&quot;: fields.float(u&quot;价格&quot;, digits=(16, 2)),<br />&nbsp; &nbsp; }<br />oecn_training_lesson()<br />
    


    lesson_view.xml

    <br />		&lt;!--定义表单视图 --&gt;<br />		&lt;record model=&quot;ir.ui.view&quot; id=&quot;oecn_training_lesson_from_view&quot;&gt;<br />			&lt;field name=&quot;name&quot;&gt;课程表单&lt;/field&gt;<br />			&lt;field name=&quot;type&quot;&gt;form&lt;/field&gt;<br />			&lt;field name=&quot;model&quot;&gt;oecn.training.lesson&lt;/field&gt;<br />			&lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt;<br />				&lt;field name=&quot;name&quot; /&gt;<br />				&lt;field name=&quot;date_start&quot; /&gt;<br />				&lt;field name=&quot;total_day&quot; /&gt;<br />				&lt;field name=&quot;price&quot; /&gt;<br />				&lt;field name=&quot;teacher&quot; /&gt;<br />				&lt;field name=&quot;students&quot;/&gt;<br />			&lt;/field&gt;<br />		&lt;/record&gt;<br />
    


    显示的画面上并没有student(学生)的信息,这是为什么呢?
    [img [检测到链接无效,已移除] /img]



  • 解决了,需要加个Form 😮



  • [quote author=baolang00 link=topic=5844.msg14584#msg14584 date=1363912244]
    解决了,需要加个Form 😮
    [/quote]

    在哪儿加啊。。。不是已经有了吗。。我还以为是6和7的区别呢。。。。



  • <br /><br />&lt;!--定义表单视图 --&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;record model=&quot;ir.ui.view&quot; id=&quot;oecn_training_lesson_from_view&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot;&gt;课程表单&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;type&quot;&gt;form&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;model&quot;&gt;oecn.training.lesson&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;form string=&quot;Lesson&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;date_start&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;total_day&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;price&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;teacher&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;students&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;/form&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;<br /><br />
    


  • [quote author=mrshelly link=topic=5844.msg14660#msg14660 date=1364476200]

    <br /><br />&lt;!--定义表单视图 --&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;record model=&quot;ir.ui.view&quot; id=&quot;oecn_training_lesson_from_view&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot;&gt;课程表单&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;type&quot;&gt;form&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;model&quot;&gt;oecn.training.lesson&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;form string=&quot;Lesson&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;date_start&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;total_day&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;price&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;teacher&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;students&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;/form&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;<br /><br />Thanks.......<br /><br />
    


    [/quote]


Log in to reply