zoukankan      html  css  js  c++  java
  • openerp学习笔记 tree视图增加复选处理按钮

    wizard:用于确认或选择

    wizard/sale_multi_action.py

    # -*- encoding: utf-8 -*-
    from openerp.osv import fields, osv
    from openerp.tools.translate import _  #用于翻译代码中的静态字符串

    class dispatch_sale_multi_action(osv.Model):
        _name = 'dispatch.sale.multi.action'
        _description = 'dispatch.sale.multi.action'
       
        '''
        def fields_view_get(self, cr, uid, view_id=None, view_type='form',
                            context=None, toolbar=False, submenu=False):
           
            if context is None:
                context={}
            res = super(dispatch_sale_multi_action, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
            if context.get('active_model','') != 'dispatch.sale':
                raise osv.except_osv(_('Warning!'), _('选择的对象列表与处理方法对应不正确.'))
            if context.get('active_model','') == 'dispatch.sale' and len(context['active_ids']) < 1:
                raise osv.except_osv(_('Warning!'), _('请选择需要确认的销售单.'))
           
            return res
        '''

        def multi_set_to_confirm(self,cr,uid,ids,context=None):
            return self.pool.get('dispatch.sale').set_to_confirmed(cr, uid, context['active_ids'], context=context)
       
    dispatch_sale_multi_action()

    wizard/sale_multi_action_view.xml

    <?xml version="1.0" encoding="utf-8"?>
    <openerp>

        <data>
         <record model="ir.ui.view" id="view_dispatch_sale_multi_action">
                <field name="name">批量确认销售记录</field>
                <field name="model">dispatch.sale.multi.action</field>
                <field name="arch" type="xml">
                    <form string="批量确认销售记录" version="7.0">
                        <separator string="您确认需要 确认 当前选中单据吗?确认后单据不允许修改和删除!"/>
                        <label string="" colspan="4"/>
         <footer>
          <button name="multi_set_to_confirm" string="确认选中单据" type="object" class="oe_highlight"/>
          or
          <button name="cancel" string="取消" class="oe_link" special="cancel" />
         </footer>
        </form>
       </field>
      </record>

        <act_window id="action_dispatch_sale_multi_confirm"
                name="确认"
                multi="True"
                key2="client_action_multi"
                res_model="dispatch.sale.multi.action"
                src_model="dispatch.sale"
                view_mode="form" target="new" view_type="form" view_id="view_dispatch_sale_multi_action"
                />
        </data>
      
    </openerp>

    sale.py

        #提交
        def set_to_confirmed(self, cr, uid, ids, context=None):
            for rec in self.browse(cr, uid, ids, context=context):
                if rec.state != 'confirmed':
                    if rec.create_uid.id != uid:
                        raise osv.except_osv(_(u'警告!'),_(u'您不能确认他人创建的单据.'))
                    self.write(cr, uid, ids, {'state':'confirmed'})
            return {}

  • 相关阅读:
    Mybatis中#{}和${}传参的区别
    笔记摘抄 —— shiro学习篇
    使用Spring的Testcase的单元测试的写法
    【转】FreeMarker学习笔记
    破解Pycharm,IDEA,PhpStrom等系列产品的,有关JetbrainsCrack的使用方法
    Python的字符串
    python的变量
    python开头注释
    h5-动画小案例-滚动展示
    h5-钟表动画案例
  • 原文地址:https://www.cnblogs.com/cnshen/p/3163517.html
Copyright © 2011-2022 走看看