Skip to content
  • Categories
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse

Odoo 中文社区

  1. Home
  2. Categories
  3. Odoo 开发与实施交流
  4. OpenERP对象定义详解(连载中...)

OpenERP对象定义详解(连载中...)

Scheduled Pinned Locked Moved Odoo 开发与实施交流
30 Posts 17 Posters 94.4k Views 2 Watching
  • 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.
  • JoshuaJ Offline
    JoshuaJ Offline
    Joshua
    管理员
    wrote on last edited by
    #21

    关于field.function我有其他问题,例如
    sale这个模块里面的

    <br />&#039;amount_untaxed&#039;: fields.function(_amount_all, method=True, digits=(16, int(config&#91;&#039;price_accuracy&#039;])), string=&#039;Untaxed Amount&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; store = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;sale.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;sale.order.line&#039;: (_get_order, &#91;&#039;price_unit&#039;, &#039;tax_id&#039;, &#039;discount&#039;, &#039;product_uom_qty&#039;], 10),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; multi=&#039;sums&#039;),<br />
    


    _get_order

    <br />&nbsp; &nbsp; def _get_order(self, cr, uid, ids, context={}):<br />&nbsp; &nbsp; &nbsp; &nbsp; result = {}<br />&nbsp; &nbsp; &nbsp; &nbsp; for line in self.pool.get(&#039;sale.order.line&#039;).browse(cr, uid, ids, context=context):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result[line.order_id.id] = True<br />&nbsp; &nbsp; &nbsp; &nbsp; return result.keys()<br />
    


    问题来了上面的代码是在sale.order里面的,他是根据sale.order.line的变化。而触发调不调用 _amount_all。但是_get_oeder里面的ids究竟是从何而来呢?是自动对应这个sale.order的sale.order.line吗?这里的_amount_all是任意一个sale.order.line变化就会触发,还是某个sale.order的sale.order.line变化才促发呢?

    【上海先安科技】(joshua AT openerp.cn),欢迎关注公众号:openerp_cn

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NewZN
      wrote on last edited by
      #22

      > 问题来了上面的代码是在sale.order里面的,他是根据sale.order.line的变化。而触发调不调用 _amount_all。但是_get_oeder里面的ids究竟是从何而来呢?是自动对应这个sale.order的sale.order.line 吗?这里的_amount_all是任意一个sale.order.line变化就会触发,还是某个sale.order的 sale.order.line变化才促发呢?

      这个问题太深入了,俺没深入调查源代码,只是凭经验回答。_get_order里面的ids从界面上来,是界面上当前Order的order.line的ids。因此,当前界面上的sale.order的任意一个 sale.order.line的变化,将会触发_amount_all的调用。

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wjfonhand
        wrote on last edited by
        #23

        sale.order.line有个比较讨厌的地方就是,他有单独的menu。这样用户可能不在订单header界面进去而是直接修改订单行。

        估计这个store参数就是为了解决这个问题的

        GoodERP -- Odoo China fork

        1 Reply Last reply
        0
        • K Offline
          K Offline
          K_Go
          wrote on last edited by
          #24

          写的真好~~

          1 Reply Last reply
          0
          • C Offline
            C Offline
            codefans
            wrote on last edited by
            #25

            原来楼主就是老肖

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mf1389004071
              wrote on last edited by
              #26

              mark

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                zx0800
                wrote on last edited by
                #27

                很好,mark

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  hzren
                  wrote on last edited by
                  #28

                  很好,mark

                  1 Reply Last reply
                  0
                  • 佳 Offline
                    佳 Offline
                    佳先生
                    wrote on last edited by
                    #29

                    请问,text 可以显示长度吗??

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      lindyue
                      wrote on last edited by
                      #30

                      学习了

                      1 Reply Last reply
                      0

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Tags
                      • Popular
                      • Users
                      • Groups