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
    7
    3179
    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
      jundi1000 last edited by

      我的工作流:
      [img http://i.imgur.com/IngqTao.png /img]

      在trans里该怎么设置呢,把条件放在condition,是对的吗?然后price_unit和list_price前面需要加什么吗?例如:product_id.list_price之类的。
      [img http://i.imgur.com/zhTrZdL.png /img]

      price_unit
      [img http://i.imgur.com/soFNLHm.png /img]

      list_price
      [img http://i.imgur.com/qLCnVXQ.png /img]

      1 Reply Last reply Reply Quote 0
      • digitalsatori
        digitalsatori 管理员 last edited by

        @judi1000 基本思路是对的, 也看得出来你是在销售订单上设置工作流。

        但是你的判断条件是针对销售订单明细的,销售订单和明细是一对多的关系。需要对其作遍历,所以一般情况下,这个判断条件应该要写成一个函数。

        【上海先安科技】(tony AT openerp.cn)

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

          @digitalsatori 那该函数该怎么写呢?希望能指点下我。谢谢

          1 Reply Last reply Reply Quote 0
          • digitalsatori
            digitalsatori 管理员 last edited by

            def product_discount(self, cr, uid, ids, context=None):<br />&nbsp; &nbsp; context = context or {}<br />&nbsp; &nbsp; for so in self.browse(cr, uid, ids, context=context):<br />&nbsp; &nbsp; &nbsp; &nbsp; return any(sol.price_uinit &lt; sol.product_id.list_price for sol in so.order_line)<br />&nbsp; &nbsp;  <br />
            


            需要继承sale.order 对象,定义上述方法。并在workflow的condition中将price_unit<list_price改为[tt]product_dicount()[/tt], 将price_unit>list_price改为:[tt]not product_discount()[/tt]
            代码没有经过测试,仅供参考。

            【上海先安科技】(tony AT openerp.cn)

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

              好的,我试试看先

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

                [quote author=digitalsatori link=topic=16355.msg27921#msg27921 date=1398306437]

                def product_discount(self, cr, uid, ids, context=None):<br />&nbsp; &nbsp; context = context or {}<br />&nbsp; &nbsp; for so in self.browse(cr, uid, ids, context=context):<br />&nbsp; &nbsp; &nbsp; &nbsp; return any(sol.price_uinit &lt; sol.product_id.list_price for sol in so.order_line)<br />&nbsp; &nbsp;  <br />
                


                需要继承sale.order 对象,定义上述方法。并在workflow的condition中将price_unit<list_price改为[tt]product_dicount()[/tt], 将price_unit>list_price改为:[tt]not product_discount()[/tt]
                代码没有经过测试,仅供参考。
                [/quote]

                @digitalsatori 你提供的代码经过测试是可行的,谢谢啦。 🙂

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