[odoo 10]odoo警告时如何保存记录?
[odoo10]How to save the record while odoo warning is happend?
在我的自定义模块中,我添加了
application_no = fields.Char(string="Application Number")
_sql_constraints = [
('application_no_unique',
'UNIQUE(application_no)',
"Application Number already exist.Please specify another number or make sure the application number is correct"),
]
并且我使用 sql 约束 来显示警告。
它工作正常,当我们输入重复的申请号时,它会显示警告并阻止访问保存记录
问题
报警时如何保存记录??
注
我认为 SQL 约束不适合这个。
此功能还有其他方法吗?
我认为使用 onchange 方法可能会对您有所帮助:
@api.onchange('your_field')
def your_onchange(self):
count=self.search_count([('your_field','=',self.your_field)])
return {
'warning': {'title': _('Warning'), 'message': _('Warning message'),},
}
这会显示消息,您可以毫无问题地保存。希望对你有帮助。
在我的自定义模块中,我添加了
application_no = fields.Char(string="Application Number")
_sql_constraints = [
('application_no_unique',
'UNIQUE(application_no)',
"Application Number already exist.Please specify another number or make sure the application number is correct"),
]
并且我使用 sql 约束 来显示警告。
它工作正常,当我们输入重复的申请号时,它会显示警告并阻止访问保存记录
问题
报警时如何保存记录??
注
我认为 SQL 约束不适合这个。 此功能还有其他方法吗?
我认为使用 onchange 方法可能会对您有所帮助:
@api.onchange('your_field')
def your_onchange(self):
count=self.search_count([('your_field','=',self.your_field)])
return {
'warning': {'title': _('Warning'), 'message': _('Warning message'),},
}
这会显示消息,您可以毫无问题地保存。希望对你有帮助。