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账号

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

    继承并重定义函数,执行时仍然执行父类函数的问题

    Odoo 开发与实施交流
    2
    3
    2592
    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

      如下代码,此字段是父类已有的字段,子类中重新定义,同时重定义_amount_all函数,但是遇到了问题就是执行是仍然执行父类的_amount_all而不是子类重定义过的。
      经过joshua的指点,问题出在属性multi上,这个属性表示多个字段共享一个function,因此需要将与此字段共享函数的其他字段也重定义一下,问题就可以解决。

      <br />&#039;amount_total&#039;: fields.function(_amount_all, digits_compute= dp.get_precision(&#039;Sale Price&#039;), string=&#039;总计&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; store = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;sales.order&#039;: (lambda self, cr, uid, ids, c={}: ids, &#91;&#039;order_line&#039;], 10),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;sales.order.line&#039;: (_get_order, &#91;&#039;price_unit&#039;, &#039;product_uom_qty&#039;], 10),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; multi=&#039;sums&#039;, help=&quot;The total amount.&quot;),<br />
      
      1 Reply Last reply Reply Quote 0
      • C
        ChanInOpenERP last edited by

        ;D刚好自己也遇到类似的问题,表示感谢

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