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

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

    求助:如何在 search 中为 order 指定一个 “复杂”的字段

    Odoo 开发与实施交流
    2
    4
    2169
    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.
    • C
      ccdos last edited by

      ids = order_lines_obj.search(cr, uid, [],order='product_id.name')

      我是要 类似这个效果
      但是 order 里是不能这样写的,只能 是 简单的字段名

      1 Reply Last reply Reply Quote 0
      • C
        ccdos last edited by

        测试了一下,
        ids = order_lines_obj.search(cr, uid, [],order='product_id')

        这句生成的对应sql 如下,

        SELECT &quot;sale_order_line&quot;.id <br />FROM &quot;sale_order_line&quot; <br />LEFT JOIN &quot;product_product&quot; as &quot;sale_order_line__product_id&quot; <br />ON (&quot;sale_order_line&quot;.&quot;product_id&quot; = &quot;sale_order_line__product_id&quot;.&quot;id&quot;) <br />ORDER BY &quot;sale_order_line__product_id&quot;.&quot;default_code&quot; ,&quot;sale_order_line__product_id&quot;.&quot;name_template&quot; 
        





        经查,

        &nbsp; &nbsp; _name = &quot;product.product&quot;<br />&nbsp; &nbsp;  _order = &#039;default_code,name_template&#039;
        



        看来,product_id 这样的 many2one字段作为order 时,实际使用的是其 主表的  _order .

        如此看来,前述需求就是要修改一下 "product.product" 的 _order 了
        但是 不知道会不会动静 太大

        有没有办法,仅仅在 本次 search 时,动态修改一下  "product.product" 的 _order  呢?

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

          建议给 line 加个 sequence 然后  保存时, 取 product.product__name 排个序. 然后 生成相应的 sequence.

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