Navigation

    Odoo 中文社区

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Popular
    • Users
    • Groups

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

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

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

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

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

    关于one2many自动新建两条记录的问题

    Odoo 开发与实施交流
    2
    5
    2499
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jerry79 last edited by

      在res.partner那里,模仿res.partner.address,新建了两个one2many字段,分别是base_info和account_info,代码如下:

      <br />class base_info:<br />{<br />&nbsp; &nbsp; #相关字段<br />}<br />class account_info:<br />{<br />&nbsp;  #相关字段<br />}<br />class res_partner(osv.osv):<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; _name = &quot;res.partner&quot;<br />&nbsp; &nbsp; _inherit = &#039;res.partner&#039;<br /><br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;base_info&#039;: fields.one2many(&#039;res.partner.base.info&#039;, &#039;partner_id&#039;, &#039;Base&#039;),&nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;account_info&#039;: fields.one2many(&#039;res.partner.account.info&#039;, &#039;partner_id&#039;,&#039;Account&#039;),<br />&nbsp; &nbsp; }<br />res_partner()<br />
      


      在view中:

      <br />&lt;page string=&quot;基本信息&quot;&gt;<br />&nbsp; &nbsp; &nbsp;  &lt;field colspan=&quot;4&quot; mode=&quot;form&quot; name=&quot;base_info&quot; nolabel=&quot;1&quot; select=&quot;1&quot; height=&quot;260&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  相关字段<br />&nbsp; &nbsp; &nbsp;  &lt;/field&gt;<br />
      


      现在的问题是,新建一个客户后,即使我不点击one2many字段的新建按钮,保存的时候也会默认建立两条记录。即一条是我保存的记录,一条是空记录。
      请问为什么会出现这样的问题呢?
      谢谢

      1 Reply Last reply Reply Quote 0
      • J
        jerry79 last edited by

        https://bugs.launchpad.net/openerp-web/+bug/980529

        1 Reply Last reply Reply Quote 0
        • mrshelly
          mrshelly last edited by

          奇怪... 确认是个BUG后, 为什么标准  addons 里的数据不存在问题?

          1 Reply Last reply Reply Quote 0
          • J
            jerry79 last edited by

            标准addons的数据偶尔会出问题,几率比较小

            1 Reply Last reply Reply Quote 0
            • First post
              Last post