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.
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj się| Powiązane posty | Odpowiedzi | Widoki | Czynność | |
|---|---|---|---|---|
|
|
2
maj 25
|
1964 | ||
|
|
3
mar 25
|
1568 | ||
|
|
2
sty 24
|
3424 | ||
|
|
0
lis 23
|
2073 | ||
|
|
0
wrz 23
|
1864 |