Skip to content
  • Categories
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • 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 70.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
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
      • wjfonhandW Offline
        wjfonhandW 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

                      • Login

                      • Don't have an account? Register

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