How to enable same UPC barcode in 2 different items

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?

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