-1

我是 Python 和 openerp 的新手。当我想制作一个简单的批准按钮来更改状态时,我遇到了问题,只是为了更改状态。

错误消息:未找到处理程序。

这是我的脚本:

XML:

<button name="approve" states="draft" string="Approve" type="object"/>

Python:

...
class student(osv.osv):
    _name = "sim.student"
    _description = "Data Siswa"

    def approve(self, cr, uid, ids, context=None):
        """ 
        confirm one or more order line, update order status and create new cashmove 
        """
        #cashmove_ref = self.pool.get('lunch.cashmove')
        orders_ref = self.pool.get('sim.student')
        for order_line in orders_ref.browse(cr, uid, ids, context=context):
            if order_line.status != 'confirmed':

                #cashmove_ref.create(cr, uid, values, context=context)
                order_line.write({'status': 'confirmed'}, context=context)
        return order_line.create(cr, uid, ids, context=context)

    ...
4

2 回答 2

0

order_line是可浏览对象,而不是模型,write()应该在模型对象上完成。

代替:

order_line.write({'status': 'confirmed'}, context=context)

尝试:

orders_ref.write(cr, uid, order_line.id, {'status': 'confirmed'}, context=context)
于 2013-01-11T09:46:28.207 回答
0

您的错误是由于create()函数返回时调用的函数。你只需要return True. create 函数也没有 id 作为参数。您需要传递包含学生记录所需字段和值的字典。如果您尝试复制当前学生记录,请使用 copy() 函数。

于 2013-01-11T11:42:16.587 回答