zoukankan      html  css  js  c++  java
  • function field , store={}...

     1     def _get_product_state(self,cr,uid,ids,fields,arg=None,context=None):
     2         res={}
     3         dic=dict( self.pool.get('product.product')._columns['state'].selection )
     4         for sol in self.browse(cr,uid,ids,):
     5             if sol.product_id.state in dic:
     6                 res[sol.id]=dic[sol.product_id.state]
     7             else:
     8                 res[sol.id]='N/A'
     9         return res
    10     def _get_sol_by_product(self,cr,uid,ids,context=None):
    11         sol_ids = self.pool.get('sale.order.line').search(cr,uid,[('product_id','in',ids),])
    12         return sol_ids
    13     _columns={
    14         'product_state':fields.function(_get_product_state,arg=None, type='char', string='Product State',readonly=True, store={
    15                     'product.product': (_get_sol_by_product, ['state',], 20),   
    16                     'sale.order.line': (lambda self, cr, uid, ids, c={}: ids, ['product_id'], 20),                                 
    17                      }), 

    store={ 'model.name': (  function_return_ids,  fieds_name_list, 20 ),}

    when model.name's   field(include by fields_name_list) change, the  function_return_ids will return the ids ,

    those ids will re-counter the function field and store it.

    ~~~~~~~ 需要odoo 实施,二开,培训 等服务 QQ:190170444
  • 相关阅读:
    矩阵分析 p13~p20
    矩阵分析 p1~p13
    复变函数2
    口语80篇(1-2)
    复变函数1
    背单词方法
    writing practice
    将博客搬至CSDN
    windows内核编程 白话设备栈
    sfliter__except_handler4
  • 原文地址:https://www.cnblogs.com/alangwansui/p/3196268.html
Copyright © 2011-2022 走看看