• odoo方法


    # 创建按钮
    def action_view_sigining_contract(self, cr, uid, ids, context=None):
    if not context:
    context = {}
    selfobj=self.browse(cr,uid,ids[0],context=context)
    pickobj=self.pool('sigining.contract')
    传值
    ctx={'default_contract_type':selfobj.lx_type,'default_name':selfobj.name.id,'default_display_name':selfobj.display_name.id}
    mod_obj = self.pool.get('ir.model.data')
    form_res = mod_obj.get_object_reference(cr, uid, 'demo_contract', 'view_sigining_contract_form')
    form_id = form_res and form_res[1] or False

    return {
    'name':u'创建合同',
    'type': 'ir.actions.act_window',
    'view_type': 'form,tree',
    'view_mode': 'form,tree',
    'res_model': 'sigining.contract',
    'views': [(form_id, 'form')],
    'view_id':form_id,
    'context':ctx,
    }

    <div class="oe_right oe_button_box" name="buttons">
                            <button  class="oe_inline oe_stat_button" icon="fa-list" name="action_open_jiesuan_order" type="object">
                                <field string="结算清单" name="jiesuan_order_count" widget="statinfo" />
                            </button>
                        </div>

    这是右边的页签:计算条数:

    # 新加地方,要记录立项的条数,通过合同号来找到
    def _get_lx_order_count(self, cr, uid, ids, field_name, arg, context=None):
    res = dict.fromkeys(ids, 0)

    try:
    lx_origin=self.browse(cr,uid,ids[0],context=context).lx_origin
    obj=self.pool('demo.contract.lx')
    demo_contract_lx_ids=obj.search(cr,uid,[('lx_origin','=',lx_origin)])
    res[ids[0]]=len(demo_contract_lx_ids)
    except:
    print u"err"
    finally:
    return res



    _columns = {

    'lx_order_count':fields.function(_get_lx_order_count,string='立项单'),

    }


     ###############链接到立项页面tree视图
    def action_open_lx_order(self, cr, uid, ids, context=None):
    try:
    act_obj = self.pool.get('ir.actions.act_window')
    mod_obj = self.pool.get('ir.model.data')
    obj=self.browse(cr,uid,ids[0],context=context)
    lx_origin=obj.lx_origin
    result = mod_obj.xmlid_to_res_id(cr, uid, 'demo_contract.action_demo_contract_lx',raise_if_not_found=True) #查找出动作的ID
    result = act_obj.read(cr, uid, [result], context=context)[0]

    result['domain'] = "[('lx_origin','=','" + lx_origin + "')]"
    except:
    print u"err"
    finally:
    return result


    <record id="view_demo_contract_lx_form" model="ir.ui.view">
    <field name="name">demo.contract.lx.form</field>
    <field name="model">demo.contract.lx</field>
    <field name="arch" type="xml">
    <form striing="demo contract lx">
    <header>
    <button name="action_split_order" string="确认" type="object" states="draft"/>
    <button name="action_cancel_order" string="取消" type="object" states="confirm"/>
    <button name="action_view_sigining_contract" string="创立合同" type="object" states="confirm"/>
    <field name="state" widget="statusbar" statusbar_visible="draft,confirm"/>
    </header>
    <sheet>
    <div class="oe_right oe_button_box" name="buttons">
    <button class="oe_inline oe_stat_button" icon="fa-list" name="action_open_lx_order" type="object">
    <field string="立项单" name="lx_order_count" widget="statinfo" />
    </button>
    </div>
    <h1
    >

    <label string="立项"/>
    <field name="lx_origin" class="oe_inline" readonly="1"/>
    </h1>
     
  • 相关阅读:
    C语言常用函数
    信号处理函数误用不可重入函数导致的进程死锁情况
    Shell脚本学习
    文件I/O详解
    字体标记的使用
    无序列表标记
    换行标记的使用
    HTML文件的基本结构
    预格式化标记的使用
    特殊标记的使用
  • 原文地址:https://www.cnblogs.com/1314520xh/p/6941146.html
Copyright © 2020-2023  润新知