ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Using Item attributes in custom app

customization

#1

Hi,
I am trying to make a custom app that updates values on delivery note and delivery note item on the bases of item attributes.
I am able to update the values field following the tutorial:
Frappe - Creating a Custom Application & Integrating it with ERPNext

What I want to do is fetch item attribute vales, make calculations based on the attribute values and update the corresponding fields.

Example:
Item attributes = Height,Length and Width
Field on delivery note item: Item_volume = item.Height x Item.Length x Item.Width
Field on delivery note: total_volume= sum of all item_volume
Regards.


#2

From where you want to fetch the item attribute?

can you Please provide the example for that or screenshot.


#3

My App path:

ahmad@HP-Pavilion:~/master-frappe-bench/apps/steelpipes/steelpipes/sp_delivery_note$

In the below particular scenario:
delivery note item: item_weight = (1.2 x item.Pipe Thinkness x item.Strip.Width x item.Pipe Length) / 508
Devlivery note: total_weight = sum of all the item_weights


#4

To fetch Item Attribute

frappe.call({
        method:"frappe.client.get_list",
        args:{
            doctype:"Item Variant Attribute",
            filters:{
                parent:"Item Code",
                parentfield:'attributes',
                parenttype:'Item',
                attribute:'Attribute Name (Length,width)'
            },
            fields:['from_range','to_range','attribute_value']
        },
        callback:function(r){
          console.log(r.message)
        }
    })

#5

Thanks I get the Idea from .js point of view. But how to do that in .py file.

i am thinking this approach
item_obj = frappe.get_doc("Item", itemcode)

But here I wonder do I need to import a specific module in my .py file to perform that ?

for Example:

from frappe.modules.utils import get_doc


#6

In Python File same way as we are doing in js file.

frappe.get_list('DocType Name',filters={
                parent:"Item Code",
                parentfield:'attributes',
                parenttype:'Item',
                attribute:'Attribute Name (Length,width)'
            },
fields:['from_range','to_range','attribute_value'])

#7

I will try and then update. Thanks Rohan