Can someone help me with this… I want to add custom fields in item price i.e. "price list 1"and “rate 1” this is done so that i can add two prices for the same item with different price lists and rates at the same time. i have created the fields but i need some help here because the saved rates for the particular price list must be fetched while doing the transactions.
if anyone could tell me how to do this…Thank you
in advance
the actual problem is not to add the fields within the item price, but you need to find the place in the code where the price is fetched. depends on where you want to use the added fields. selling? purchase? with specific conditions?
Thanks for the reply…but i have already given the field type as link and it is linked to price list, the field just fetches the price lists and when i save the doctype its just just there…i cannot use them
Thanks for the reply…may be i should make myself clear
i have a situation that if the user should be able to add prices for the same item for different pricelist i.e. one is for selling and another for purchasing in the same item price doctype at a time.
The prices should be fetched when using both selling and purchasing price list.
i am new to Erpnext…if you could tell me where should i put the code to do this
Almost correct… I dont want to make my requirement tiring but the thing is to have two or more price list and to add rates to each price list within a single item price doctype at one go. This requirement is made because if the user could add different prices for same item without requiring to create one item price for an item and then saving another item price for the same item with different price.
So instead of creating multiple item prices. You want to create only one Item Price. Then within that one Item Price contains multiple rates?
If this is the case it sounds like it is going to be more work then it’s worth. If you’re worried about price input being time consuming you can use the Data Import tool to import all your prices in one shot.
You’ll have to write a custom script that fetches the correct rate field from the Item Price for each doctype that will be using it. Ex: Sales Order, Purchase Order.
You can check here for some more info about custom scripts: Custom Scripts
Sure…But I have Solved it in more simple way.
Wrote a simple client script… I just created a new item price document in the after_save() that takes all the values in the previous document(Price list 2 and rate 2),item code and put the values in the new doctype.
Still it is not automatically saving, there pops a quick entry with all the values fetched and have to save manually.
Hope this is a correct way…Any suggestion would be great
Thankss
This is what i want to achieve… add 3 price list and corresponding 3 rates in one item price doctype. so that 3 price can be added in one shot.
Below is the script…sorry for the bad scripting way, avoid the ‘console.log’ if its disturbing, I just want to make sure correct values are fetched
frappe.ui.form.on(‘Item Price’, {
validate(frm) {
// check if the fields price list1,2,3 are entered correctly
},
after_save(frm) {
var pp=frappe.get_list(“Item Price”);
console.log(‘kkkkkkkkkkkkkkkkkkkkkk’);
console.log(‘999999999999999=============’,pp);
console.log(‘itemcode ====’,pp[0].item_code);
console.log(‘pricelist====’,pp[0].price_list);
console.log(‘pricelist Rate====’,pp[0].price_list_rate);
console.log(‘pricelist2===’,pp[0].price_list_2);
console.log(‘pricelist3===’,pp[0].price_list_3);
console.log(‘pricelist Rate 2===’,pp[0].rate_for_price_list_2);
console.log(‘pricelist Rate 3===’,pp[0].rate_for_price_list_3);
frappe.db.insert({
doctype: ‘Item Price’,
item_code:pp[0].item_code,
price_list:pp[0].price_list_2,
price_list_rate:pp[0].rate_for_price_list_2
}).then(function(doc) {
console.log(${doc.doctype} ${doc.name} created on ${doc.creation});
});
frappe.db.insert({
doctype: ‘Item Price’,
item_code:pp[0].item_code,
price_list:pp[0].price_list_3,
price_list_rate:pp[0].rate_for_price_list_3
}).then(function(doc) {
console.log(${doc.doctype} ${doc.name} created on ${doc.creation});
});
}
});