Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
15643 Переглядів

I have a system where there are duplicate copies of products and also sales orders for those duplicate products. I need to remove duplicate entries of products without affecting a single sales order that depend on those duplicate product. I cannot do it manually because there are 1500 products and 1000 sales orders.

Аватар
Відмінити
Найкраща відповідь

Have you tried an app called Product Merge? It doesn't work, however, if the duplicates are in different UOMs...

Otherwise, you'd have to uncheck "Active" in the duplicate you want to deactivate and leave it hidden...

Аватар
Відмінити
Найкраща відповідь

Dear,

To check exist the same Product in the line level.

from odoo import models, fields, api
from odoo.exceptions import ValidationError


class SaleOrder(models.Model):
_inherit = "sale.order"

@api.multi
@api.constrains('order_line')
def _check_exist_product_in_line(self):
for sale in self:
exist_product_list = []
for line in sale.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.


Аватар
Відмінити
Найкраща відповідь

Hi,

if the order is validated you can not change it.

and you can not remove products while other records still reference it.

so I think the only solution is to make SQL requettes in postgresql.

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
трав. 25
3717
0
лист. 24
1049
1
серп. 24
1770
1
бер. 24
4593
1
серп. 24
3213