How to enable same UPC barcode in 2 different items

erpnext Barcode Y already used in Item X

ERPnext doesn’t allow me to put 2 same barcodes in 2 different items.

Here, we have some medications in Canada with a DIN number for drug identification, and that DIN number is the same for the drug but can exist in 2 different format with different pricings.

I create a DIN as a barcode in Doctype > Item Barcode > Edit barcode type in “fields” > options > add DIN below default EAN/UPC.

But that DIN number can not be duplicated to be the same in 2 different products.

Product 1 different UPC than product 2, but both have same DIN. How can I make it happen?

Is there a way to disable the default duplicate barcode disabled?

Hi @l4cky,

Unfortunately, it is not possible to disable the default duplicate barcode check-in ERPNext. The system is designed to prevent the use of the same barcode on multiple items to avoid confusion and mistakes in inventory management.

One possible workaround for your situation could be to use a suffix or prefix in the barcode for one of the items to differentiate them while still using the same DIN. For example, you could add a “-A” suffix to the barcode for one item and a “-B” suffix for the other item. This way, the barcodes will be unique, but the items can still be identified by their common DIN.

Alternatively, you could consider using a different identifier for one of the items, such as a different type of barcode or a different identification number. This would allow you to keep the DIN as the identifier for one of the items while still having unique identifiers for both items.

I hope this helps!

Thank You!

Hi @NCP
Thank you for your great insights.
As for the 2nd alternative, do you mean I can write the same number but one under DIN, the other same number under DIN2 (for example), and then DIN3 (adding DIN2, DIN3 Edit barcode type in “fields” > options)?

Also, I have another question regarding ninja/html and fetch a doctype value, and I haven’t been able to figure out the code (syntax) to retrieve standard selling price rate and wonder if you can help me out.

Hmm :thinking:,

Yes, you can create a custom field in the item master called “DIN2” or something similar and use that field to enter the second DIN number. Then, you can add a new barcode type in the Item Barcode doctype and link it to the “DIN2” field in the Item master. This will allow you to use both DIN numbers in the system while avoiding duplicate barcodes.

Regarding your question about fetching a doctype value, the syntax for fetching a value from a doctype in ERPNext using Jinja templating language (used in Ninja/HTML) is as follows:

# I haven't tried so please try it and check it.
{{ frappe.get_doc('Doctype', docname).fieldname }}

Replace ‘Doctype’ with the name of the doctype you want to fetch data from, ‘docname’ with the name of the document you want to fetch data from, and ‘fieldname’ with the name of the field you want to fetch the value from.

For example, to fetch the standard selling price rate from the item master, you can use the following syntax:

# I haven't tried so please try it and check it.
{{ frappe.get_doc('Item', item_code).standard_selling_rate }}

Replace ‘Item’ with the name of the doctype, ‘item_code’ with the name of the item you want to fetch the value from, and ‘standard_selling_rate’ with the name of the field you want to fetch the value from.

I hope this helps!

Thank You!

When i tried to copy paste {{ frappe.get_doc(‘Item’, item_code).standard_selling_rate }}, it gives me this error

{{ no such element: erpnext.stock.doctype.item.item.Item object[‘standard_selling_rate’] }}

but if I type {{ frappe.get_doc(‘Item’, item_code).standard_rate }}

it works, but it gives me the standard rate of the item master, not the rate of the standard selling price. list which is different than the standard rate of the item master (the latter doesn’T seem to be able to be modified)

I apologize for the confusion. The standard_rate field in the Item doctype is not related to the standard selling price rate.

To fetch the standard selling price rate of an item, you can use the following syntax:

{{ frappe.get_value('Item Price', {'item_code': item_code, 'price_list': 'Standard Selling'}, 'price_list_rate') }}

Replace ‘Item Price’ with the name of the doctype, ‘item_code’ with the name of the item you want to fetch the value for, and ‘price_list_rate’ with the name of the field you want to fetch the value from.

The above code will fetch the rate for the ‘Standard Selling’ price list for the given item code. If you want to fetch the rate for a different price list, replace ‘Standard Selling’ with the name of the price list you want to fetch the value for.

Thank You!

When I copy paste, it has this error

not sure what went wrong…

But this one works

{{ frappe.get_doc(‘Item Price’, item_code).price_list_rate }}

thanks!

Please again try and check it.

{{ frappe.db.get_value('Item Price', {'item_code': item_code, 'price_list': 'Standard Selling'}, 'price_list_rate') }}
1 Like

now it gives me this error

pymysql.err.ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘{ item_code }} AND price_list=‘Standard Selling’ ORDER BY modified DESC L…’ at line 1”)

Please check it.

It worked in jinja.

I think I didn’t put the headers {%- for item in doc.items -%} and {%- endfor -%}
Now there is no error, however i am not sure if my headers is correctly written as it gives me no value (blank)

@NCP

Do you know if it’s possible to add the selling rate value of ITEM PRICE into ITEM master doctype? I have trying to do it using the configuration below, but sometime this is the closest I get. It takes the item ID rather than the item amount and I am not sure how I can fix that.

Thanks! you’re a real life saver!

Please try it.

{{ frappe.db.get_value("Item Price", doc.price_list_rate, 'price_list_rate') }}

Check-in print format.

Thank You!

2 Likes

wonderful that works well!! great! thanks

As for the other problem above, do you know how I can have the same Rate displayed in the “price_list_rate” to be an amount rather than “1245f79547” (which is the item ID) that displays in the item master (picture from the post above yours)

Hi @l4cky,

Please add the new custom field (field name: rate). then fetch from condition apply in customization form in rate field like (price_list_rate.price_list_rate).

Then reload and check it.
Please don’t remove the price_list_rate field in Item master because item price fetch from price_list_rate so …

Have a good day!
Thank You!

1 Like

Excellent. This works great!

In summary, I have a total of 2 fields in the item master:
A) Item ID (in standard selling)
B) Rate (set in standard selling)

However, I need to manually select A) Item ID so B rate will be automatically shown.

Is there a way to have A) Item ID automatically select rather than manually?

Thanks,

If an item has multiple prices then how can be set automatically, It’s not possible.

Thank You!

I see. That makes sense.

I was wondering if we can like narrow just to one specific price list which is the standard price list so we don’t have multiple prices for this specific field.

Will that be possible?

Hi @l4cky,

Only possible if the item has only one price, then you can set using a custom script with a refresh event.

Thank You!

Thanks.

Without a script, it’s not possible to “copy” the price from the standard selling list to the item master without an additional step (manually), right?