How to enable same UPC barcode in 2 different items

@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?

I think not possible,
But i free from workspace then if possible solution then we will provide the script.
Currently not possible.

Thank You!

1 Like

thanks!!

Hi @l4cky,

Here we set the Standard Selling Price in the Valuation Rate field.
Please check the video.

Code:

frappe.ui.form.on('Item', {
	refresh: function(frm) {
		frappe.db.get_value("Item Price", {
            "item_code": frm.doc.item_code,
            "price_list": "Standard Selling"
        }, ['price_list_rate'],
        function (value) {
            if (value.price_list_rate !== undefined) {
                if (frm.doc.valuation_rate === 0 || frm.doc.valuation_rate !== value.price_list_rate) {
                    frm.set_value("valuation_rate", value.price_list_rate);
                }
            }
        });
	}
});

If comfortable with it then use it.

Thank You!

1 Like

Hello,

Where can I copy paste this script (which section)?

Please check it.

Thanks!

This is wonderful, I just replaced the valuation_rate field with a new field called: rate_fetch_from_standard_selling_price_list and as expected, the field is not editable and will not save unless we go to standard price list.

@NCP

Thank you! such a great help for the entire thread! Couldn’t have done it without you Sir!

Do you know if we update ERPNext version, or bench update, bench backup, bench restore commands will be able to save the added fields and client script we modified?

Hi @l4cky,

When you update the erpnext then it does not affect customization like (Custom Field, Server Script, or Client/Custom Script.)

Keep one thing in mind when you update the erpnext first take a backup.
Okay.

Have a good day!
Thank You!

1 Like

Hi @NCP

Thank you.

I have a small problem with currency decimal using the script and occurs in print format, the 0 at the end of the rate is missing.

In my client script

frappe.ui.form.on('Item', {
	refresh: function(frm) {
	    set_css(frm);
		frappe.db.get_value("Item Price", {
            "item_code": frm.doc.item_code,
            "price_list": "Standard Selling"
        }, ['price_list_rate'],
        function (value) {
            if (value.price_list_rate !== undefined) {
                if (frm.doc.rate_fetch_from_standard_selling_price_list === 0 || frm.doc.rate_fetch_from_standard_selling_price_list !== value.price_list_rate) {
                    frm.set_value("rate_fetch_from_standard_selling_price_list", value.price_list_rate);
                }
            }
        });
	}
});

var set_css = function (frm)
    {
    document.querySelectorAll("[data-fieldname='rate_fetch_from_standard_selling_price_list']")[1].style.height ="25px";
    document.querySelectorAll("[data-fieldname='rate_fetch_from_standard_selling_price_list']")[1].style.width ="70px";
    document.querySelectorAll("[data-fieldname='rate_fetch_from_standard_selling_price_list']")[1].style.color ="black";
    document.querySelectorAll("[data-fieldname='rate_fetch_from_standard_selling_price_list']")[1].style.backgroundColor ="yellow";
    }

In item master, I have created a new field for the fetched rate:

So far everything works.


But in the print format, then I use the code

      <div class="label-item-price label-field">
          {{ frappe.get_doc('Item Price', item_code).price_list_rate }}
      </div>

The price displayed is all good but ONLY WHEN it has a 0 at the end, it removes it.

So If the price is 1.17 → It will show 1.17 (Good)
So If the price is 0.07 → It will show 0.07 (Good)
But If the price is 1.00 → It will show 1.0 (missing a 0 at the end)
But If the price is 1.10 → It will show 1.1 (missing a 0 at the end)

Do you know how and where I can fix the 0 missing at the end?

Thank you!

Hi @l4cky,

Please check it whole post regarding jinja rounding.

Thank You!

{{ "{:,.2f}".format(frappe.get_doc('Item Price', item_code).price_list_rate) }}

Yes, it works super well! thank you!! @NCP