Ajuda

1

Is there a way to flag duplicate products?

I am looking to indicate when two products that have the same product Internal Reference number exist, the text in the product list changes to another color. This is hopefully the end goal.

I immagine there is a simple way of doing this with the view files (running on Saas version within a browser), but I am still new to editing code, and I still trying to figure out how it all works.

5 Comentários
Avatar
Descartar

@ Ray & Ben. Yeah I don't know. In another question I posted I was told that text color can be edited based off of checks that are done by default. https://www.odoo.com/forum/help-1/question/how-does-one-change-the-default-text-color-that-openerp-uses-58724 In this case the product.product.tree was edited. In my goal, I imagine I would have to create an entirely different one, but have the same color edit and different check.

@ Med Said Bara. In the "Product Unique EAN or Reference Code (product_unique)" does the "default_code" refer to the Internal Reference Code? In this case this module would do exactly as I need?

Avatar
Med Said BARA
-

Yes, "product code" referes to the internal code. Try also https://www.odoo.com/apps/7.0/product_unique_default_code/

@ Med Said Bara. Thanks for the reply. Also you wouldn't happen to know if these modules add to my module count, such that when I start a paid service my rates would increase?

Avatar
Med Said BARA
-

Hard to say ! But let's say, more you give, more you get.

4 Respostas
8
Avatar
Janeesh
Best Answer

Hi,

It will be difficult to control with xml file. But we have different options to avoid duplicate products. Either you can give _sql_constarints for this field or you can override the create method and check whether any records existing with same internal reference.

Avatar
Descartar
3
Avatar
Med Said BARA
Best Answer

Having products with the same internal code or the same product name is a nonsense.

This kind of practice should be avoided (banned).

This is also true for the  barcode identification field.

All, must be unique.

Just use: https://www.odoo.com/apps/7.0/product_unique/  and https://www.odoo.com/apps/7.0/product_name_unique_per_company/ to avoid this type of errors.

 

 

Avatar
Descartar
1
Avatar
Ray Carnes
Best Answer

XML view definitions are only 'aware' of the current record so I don't see how this is possible with XML.

1 Comentário
Avatar
Descartar
Avatar
Ben Bernard
-

So it is a good idea to make new custom field (boolean) to the target model, product.product. Then in the view you can define it (maybe as a checkbox).

0
Avatar
Ankit H Gandhi(AHG)
Best Answer

Dear,

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.


Avatar
Descartar