跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • 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

  • 默认(Flatly)
  • 不使用皮肤
折叠

Odoo 中文社区

  1. 主页
  2. 版块
  3. Odoo 新手求助
  4. 定义的action不执行

定义的action不执行

已定时 已固定 已锁定 已移动 Odoo 新手求助
4 帖子 2 发布者 3.2k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • T 离线
    T 离线
    timwang
    写于 最后由 编辑
    #1

    已经忙了几个小时了,实在找不到原因,求助大家。

    原意是在出货View里面把“全部处理”去掉,改成分批处理,定义的方法是“action_partial_process”。但是Button始终不触发事件。不知道哪里出了问题。

    view.xml代码如下:
    <!-- 入出库Form中去掉全部处理、设为可用功能,增加分批发货功能 -->
            <record id="view_move_form_x_sale" model="ir.ui.view">
                <field name="name">stock.move.form</field>
                <field name="model">stock.move</field>
                <field name="inherit_id" ref="stock.view_move_form"/>
                <field name="arch" type="xml">
                    <data>
                        <xpath expr="//button[@name='action_done']" position="replace">                 
                            <button name="action_done" invisible="1"/>
                        </xpath>                   
                        <xpath expr="//button[@name='force_assign']" position="replace">                 
                            <button name="force_assign" invisible="1"/>
                        </xpath>                   
    [color=red]                    <button name="%(stock.action_partial_move_server)d" position="replace">
                        <button name="action_partial_process" string="入出库操作" type="action" states="assigned,confirmed" class="oe_highlight"/>
                        </button>
    [/color]                   
                        <!-- 
                        <xpath expr="//button[@name='Process Partially']" position="replace">                 
                        <button name="action_partial_process" string="入出库操作" type="action" states="assigned,confirmed" class="oe_highlight"/>
                        </xpath>
                        -->
                    </data>
              </field>
            </record>   

    py里面的代码如下

    class stock_move(osv.osv):
        _name = 'stock.move'
        _inherit = 'stock.move'
        log_create = True
       
        def test(self, cr, uid, ids, context=None):
            raise osv.except_osv(
    ('Warning!'), '123456')
            return True
       
    [color=red]    def action_partial_process(self, cr, uid, ids, context=None):
            if context is None: context = {}
           
            logging.log(10, "12345")


            context.update({
                'active_model': self.name,
                'active_ids': ids,
                'active_id': len(ids) and ids[0] or False
            })
            return {
                'name':
    ("Products to Process"),
                'view_mode': 'form',
                'view_id': False,
                'view_type': 'form',
                'res_model': 'stock.partial.move',
                'type': 'ir.actions.act_window',
                'nodestroy': True,
                'target': 'new',
                'domain': '[]',
                'context': context
            }  [/color]
           
        def do_partial(self, cr, uid, ids, partial_datas, context=None):
            """
            @param partial_datas : Dictionary containing details of partial picking
                              like partner_id, partner_id, delivery_date,
                              delivery moves with product_id, product_qty, uom
            @return: Dictionary of values
            """
           
            picking_obj = self.pool.get('stock.picking')
                   
            delivery_date = partial_datas['delivery_date']
           
            res = super(stock_move,self).do_partial(cr, uid, ids, partial_datas, context)
           
            self.write(cr, uid, res, {'date': delivery_date})
           
            for move in self.browse(cr, uid, res, context=context):
                picking_obj.write(cr, uid, [move.picking_id.id], {'date_done': delivery_date})
                       
            return res

        _columns = {
            'date_expected': fields.date('计划日期', required=False),   
            'date': fields.date('实际日期', required=False),   
        }

        _defaults = {
            'date': lambda *a: time.strftime('%Y-%m-%d'),
        }

    1 条回复 最后回复
    0
    • T 离线
      T 离线
      timwang
      写于 最后由 编辑
      #2

      <button name="action_partial_process" string="入出库操作" type="action" states="assigned,confirmed" class="oe_highlight"/>

      这句话里面的type="action"改成type="object"就好了。

      看来代码不能乱抄。

      1 条回复 最后回复
      0
      • mrshellyM 离线
        mrshellyM 离线
        mrshelly
        写于 最后由 编辑
        #3

        嗯.  type="object' 很重要...

        1 条回复 最后回复
        0

        • 登录

        • 没有帐号? 注册

        • 登录或注册以进行搜索。
        • 第一个帖子
          最后一个帖子
        0
        • 版块
        • 标签
        • 热门
        • 用户
        • 群组