Hello,
Previously in the purchase order more than 100 products are entered, many times the user is equipment and orders twice the same product, how can I solve it?
Something that blocks me if they repeat themselves or give me a warning?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello,
Previously in the purchase order more than 100 products are entered, many times the user is equipment and orders twice the same product, how can I solve it?
Something that blocks me if they repeat themselves or give me a warning?
Hi,
You can use sql constrains for this,
_sql_constraints = [
('Unique product', 'unique(order_id,product_id)', 'duplicate order line exists'),
]Thanks
Hello, thanks for the answer. this line in which part of the code should I add? Thank you.
Dear Eduardo,
To check exist the same Product in the line level.
from odoo import models, fields, api
from odoo.exceptions import ValidationError
class PurchaseOrder(models.Model):
_inherit = "purchase.order"
@api.multi
@api.constrains('order_line')
def _check_exist_product_in_line(self):
for purchase in self:
exist_product_list = []
for line in purchase.order_line:
if line.product_id.id in exist_product_list:
raise ValidationError(_('Product should be one per line.'))
exist_product_list.append(line.product_id.id)
Hope this code help you
Best Thanks,
Ankit H Gandhi.
Hello, thanks for the answer. this line in which part of the code should I add? Thank you.
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up| Related Posts | Replies | Views | Activity | |
|---|---|---|---|---|
|
|
2
मई 25
|
1970 | ||
|
|
3
मार्च 25
|
1575 | ||
|
|
2
जन॰ 24
|
3435 | ||
|
|
0
नव॰ 23
|
2078 | ||
|
|
0
सित॰ 23
|
1875 |