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

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

    請教osv_memory wizard中的return值問題

    Odoo 新手求助
    2
    4
    2986
    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.
    • K
      kk071700 last edited by

      小弟上次經mrshelly大指點 採用新的osv_memory wizard 編寫程式
      遇到一個問題 就是執行onchange_product_id Function時 return 值能改變頁面上顯示資料
      但是執行count_inv Function時 return 值卻無法改變頁面上顯示資料

      請問是我哪裡漏失了? 請大大指教 Thanks
      附件為可執行之osv_memory wizard

        def onchange_product_id(self, cr, uid, ids, product_id,IDX):
                  if product_id!='False':
                      PT_ID="0"
                      cr.execute("""select product_tmpl_id from product_product where id='"""+str(product_id)+"""'""")
                      resT = cr.fetchall()
                      for rowT in resT:
                          PT_ID=str(rowT[0])

                      list_price="0"
                      standard_price="0"
                      cr.execute('select list_price,standard_price from product_template where id='+PT_ID)
                      resPR = cr.fetchall()
                      for rowPR in resPR:
                          list_price=str(rowPR[0])
                          standard_price=str(rowPR[1])


                      val = {
                      'price_unit_sale'+str(IDX): list_price,
                      'price_unit_purchase'+str(IDX): standard_price
                      }
                      return {'value': val}


          def count_inv(self, cr, uid, ids, context=None):

                      x=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]
                      record = self.read(cr, uid, ids, [])
                      record = record and record[0]
                      inv_total_qty=0
                      inv_total_amount=0

                      for n in x:
                              product_name=str(record[('product_name'+str(n))])
                              if product_name!='False':
                                  product_qty=str(record[('product_qty'+str(n))])
                                  price_unit_purchase=str(record[('price_unit_purchase'+str(n))])

                                  f_purchase_subamount=float(product_qty)*float(price_unit_purchase)
                                  inv_total_qty=inv_total_qty+int(product_qty)
                                  inv_total_amount=inv_total_amount+f_purchase_subamount

                      A=inv_total_qty
                      B=inv_total_amount

                      val = {
                      'inv_total_qty1' : inv_total_qty,
                      'inv_total_amount1' : inv_total_amount
                      }
                      return {'value': val}

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

        onchange 事件, 与 按钮点击事件, 是两种事件...

        1 Reply Last reply Reply Quote 0
        • K
          kk071700 last edited by

          [quote author=mrshelly link=topic=2885.msg9701#msg9701 date=1334237628]
          onchange 事件, 与 按钮点击事件, 是两种事件...
          [/quote]

          感謝mrshelly大解惑

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