Odoo功能不起作用

时间:2015-06-24 04:43:17

标签: python openerp

OpenErp 8 - Python

我有场。使用更改compute_date时,单击“保存”按钮。更改state_for_date:

如果compute_date> 20然后state_for_date = comp

如果compute_date< 20然后state_for_date = new

state_for_datestatusbar

compute_date = fields.Integer('Int')

state_for_date = fields.Selection([('new', 'New'),
                                       ('comp', 'Comp')],
                                        'State', default='new', required=True)

 def write(self, vals):

       if self.compute_date < 20:
             vals = {'state': 'new'}

       if self.compute_date > 20:
             vals = {'state': 'comp'}

       return self.write(vals)

无法正常工作帮助我 错误:RuntimeError:超出最大递归深度

1 个答案:

答案 0 :(得分:1)

您正在调用递归写入方法而不是调用super方法。 你需要调用super方法。

def write(self, vals):
    if self.compute_date < 20:
        vals = {'state': 'new'}
    if self.compute_date > 20:
        vals = {'state': 'comp'}
    return super(class_name, self).write(vals)