擅长:python、mysql、java
<p>您可以添加python约束,该约束将在修改给定字段时执行。在</p>
<pre><code>class product_template(models.Model):
_inherit = 'product.template'
@api.multi
@api.constrains('seller_ids')
def onchange_seller(self):
for record in self :
if not record.seller_ids :
raise ValidationError("You should fill in the supplier details, at least one.")
return
</code></pre>
<p>有关约束的详细信息:<a href="https://www.odoo.com/documentation/10.0/reference/orm.html#module-odoo.api" rel="nofollow noreferrer">click here</a></p>