2

我有一个表单视图。我在字段中输入了一个值。我如何检索该值并将其分配给 .py 中的某个变量以进行操作

例如:我有 ActiveFrom 字段。我在表单视图中输入值 23-11-2011 到字段。我想在 openerp 中动态获取该值。我怎样才能做到这一点?

4

1 回答 1

1

I suspect you want the on_change event. It lets you trigger server-side code when the user changes a field's value. You can then change the value of other fields, or pop up a warning message.

Here's an example of how to pop up a warning from the warning module (slightly edited):

def onchange_partner_id(self, cr, uid, ids, part):
    warning = {}
    title = False
    message = False
    partner = self.pool.get('res.partner').browse(cr, uid, part)
    if partner.sale_warn != 'no-message':
        title =  _("Warning for %s") % partner.name
        message = partner.sale_warn_msg
        warning = {
                'title': title,
                'message': message,
        }

    result =  super(sale_order, self).onchange_partner_id(cr, uid, ids, part)
    return {'value': result.get('value',{}), 'warning':warning}
于 2011-11-24T01:20:40.957 回答