如何限制在odoo的订单行中再次添加相同的产品

How to restrict adding a same product once again in order line in odoo

在订单行中添加产品后的销售订单中,我们可以再次添加相同的产品。所以我想限制 it.If我将添加相同的产品,它必须显示警告你已经添加了相同的产品.

任何人都可以帮助我,我该怎么做。

使用sql约束:

在您的产品型号中添加以下行。

_sql_constraints = [
    ('constraint name', 'unique(field1,field2)', 'Warning msg'),
    ]

希望对您有所帮助。