Hello All, we developing the integration of our CAD Software and the ERPNext Sales Order, and have some questions.

The code below, parse the CAD file, and create each item described on project scope, and append the material list to item (Sales BOM), but:

If we can get one saved item to update your content, we don't can refresh the price data, we obtain the price list, but do not understand what to do after this point to update the price of the item.

If we create a new item based on template using the webnotes.bean(copy=args) method, on call item.doc.fields.update(*args) this update all fields, but does not update the brand, and the brand is defined on args.

For now we are with these difficulties, could anyone shed some light?

@webnotes.whitelist()
def get_project_costs(filenames):
    from ParsePromob import PromobReader  # The file parse
    from webnotes.model.bean import getlist
    # The Item, Sales BOM and Price templates
enviroment_template = [
    <span style="color:rgb(153,153,136);font-style:italic" class="comment"># The Item</span>
    {
        <span style="color:rgb(221,17,68)" class="string">&#39;doctype&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;Item&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;item_code&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;_Item Template_Code&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;item_name&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;_Item Template_Name&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;description&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;__Item Template_Description&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;brand&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;New&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;item_group&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;Itens Projetados&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;stock_uom&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;Un&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;is_stock_item&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;No&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;is_purchase_item&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;No&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;is_sales_item&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;Yes&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;is_service_item&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;No&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;is_sample_item&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;No&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;max_discount&#39;</span>: <span style="color:rgb(0,153,153)" class="number">65</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;default_income_account&#39;</span>: <span style="color:rgb(221,17,68)" class="string">u&#39;Vendas - Grupo Realize Móveis&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;default_sales_cost_center&#39;</span>: <span style="color:rgb(221,17,68)" class="string">u&#39;Auto Inventory Accounting - Grupo Realize Móveis&#39;</span>,    
    }, 
    <span style="color:rgb(153,153,136);font-style:italic" class="comment"># The Price</span>
    {
        <span style="color:rgb(221,17,68)" class="string">&#39;doctype&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;Item Price&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;parentfield&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;ref_rate_details&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;price_list_name&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;Itens Projetados&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;ref_rate&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;_Item Template_Price&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;ref_currency&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;BRL&#39;</span>,
        <span style="color:rgb(221,17,68)" class="string">&#39;buying_or_selling&#39;</span>: <span style="color:rgb(221,17,68)" class="string">&#39;Selling&#39;</span>
    }
]

sales_bom_template = [
    <span style="color:rgb(153,153,136);font-style:italic" class="comment">#nothing</span>
]

cost, increase = <span style="color:rgb(0,153,153)" class="number">0</span>, <span style="color:rgb(0,153,153)" class="number">0</span>
items = []

<span style="color:rgb(51,51,51);font-weight:bold" class="keyword">for</span> project_files <span style="color:rgb(51,51,51);font-weight:bold" class="keyword">in</span> filenames.split(<span style="color:rgb(221,17,68)" class="string">&#39;;&#39;</span>):
    reader = PromobReader(project_files)              <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Init the parse</span>
    project = reader.getProject()                     <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Get the xml root element </span>
    data = project.toDict()                           <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Get the item and subitems to compose the sales bom</span>
    cost += data.get(<span style="color:rgb(221,17,68)" class="string">&#39;project_cost&#39;</span>, <span style="color:rgb(0,153,153)" class="number">0</span>)               <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Get the raw price of the item</span>
    increase += data.get(<span style="color:rgb(221,17,68)" class="string">&#39;project_increase&#39;</span>, <span style="color:rgb(0,153,153)" class="number">0</span>)       <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Get the project increase</span>

    <span style="color:rgb(51,51,51);font-weight:bold" class="keyword">for</span> i <span style="color:rgb(51,51,51);font-weight:bold" class="keyword">in</span> data.get(<span style="color:rgb(221,17,68)" class="string">&#39;items&#39;</span>, []):                                                    <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Process each item for CAD File</span>
        price = i.pop(<span style="color:rgb(221,17,68)" class="string">&#39;price&#39;</span>)                                                        <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Pop the price to append this on your doctype</span>
        <span style="color:rgb(51,51,51);font-weight:bold" class="keyword">try</span>:
            item = webnotes.bean(<span style="color:rgb(221,17,68)" class="string">&#39;Item&#39;</span>, i[<span style="color:rgb(221,17,68)" class="string">&#39;item_code&#39;</span>])                            <span style="color:rgb(153,153,136);font-style:italic" class="comment"># First can get the doctype from db</span>
            item.doc.fields.update(i)                                                <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Update the item data based on CAD data</span>
            pricelist = getlist(item.doclist, <span style="color:rgb(221,17,68)" class="string">&#39;ref_rate_details&#39;</span>)                   <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Get the price list</span>
            item.save()                                                             <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Save the item</span>
        <span style="color:rgb(51,51,51);font-weight:bold" class="keyword">except</span>:
            item = webnotes.bean(copy=enviroment_template)                          <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Make a new item based on template</span>
            item.doc.fields.update(i)                                               <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Update the item data based on CAD data</span>
            item.doclist[<span style="color:rgb(0,153,153)" class="number">1</span>].fields.update({<span style="color:rgb(221,17,68)" class="string">&#39;ref_rate&#39;</span>: price})                      <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Update the price</span>
            item.insert()                                                           <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Save the item</span>
        items.append(i[<span style="color:rgb(221,17,68)" class="string">&#39;item_code&#39;</span>]) <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Append item code to response</span>

<span style="color:rgb(51,51,51);font-weight:bold" class="keyword">return</span> {
    <span style="color:rgb(221,17,68)" class="string">&#39;project_cost&#39;</span>: cost,
    <span style="color:rgb(221,17,68)" class="string">&#39;project_increase&#39;</span>: increase,
    <span style="color:rgb(221,17,68)" class="string">&#39;project_cost_net&#39;</span>: cost-increase,
    <span style="color:rgb(221,17,68)" class="string">&#39;items&#39;</span>: items
}</code></pre>
--


Maxwell Morais
(+55 11) 3931-1412 Ramal 31

www.realizemodulados.com.br



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CABK1YkMVUtSsSwzZLHPt1pC7H-Fie%3DvPKLVuQ7BXSUu%3DnDW1GQ%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Max,

The price data is in the "doclist" of the Item "bean" object.

# get the item bean object
item = webnotes.bean("Item", item_id)

# get the price list record
item_price = item.doclist.get({"doctype": "Item Price", "price_list_name": "My Price List"})

# set a new price
if item_price:
  item_price[0].ref_rate = product_cost
  item.save()


To get a better idea, just do a print on item.doclist - you will get an idea, its a collection of records (one parent + many children)

best,
Rushabh

T: @rushabh_mehta

On 03-Jul-2013, at 8:07 PM, Maxwell Morais <ma...@gmail.com> wrote:

Hello All, we developing the integration of our CAD Software and the ERPNext Sales Order, and have some questions.

The code below, parse the CAD file, and create each item described on project scope, and append the material list to item (Sales BOM), but:

If we can get one saved item to update your content, we don't can refresh the price data, we obtain the price list, but do not understand what to do after this point to update the price of the item.

If we create a new item based on template using the webnotes.bean(copy=args) method, on call item.doc.fields.update(*args) this update all fields, but does not update the brand, and the brand is defined on args.

For now we are with these difficulties, could anyone shed some light?

@webnotes.whitelist()
def get_project_costs(filenames):
    from ParsePromob import PromobReader  # The file parse
    from webnotes.model.bean import getlist
    # The Item, Sales BOM and Price templates
enviroment_template = [
    <span style="color:rgb(153,153,136);font-style:italic" class="comment"># The Item</span>
    {
        <span style="color:rgb(221,17,68)" class="string">'doctype'</span>: <span style="color:rgb(221,17,68)" class="string">'Item'</span>,
        <span style="color:rgb(221,17,68)" class="string">'item_code'</span>: <span style="color:rgb(221,17,68)" class="string">'_Item Template_Code'</span>,
        <span style="color:rgb(221,17,68)" class="string">'item_name'</span>: <span style="color:rgb(221,17,68)" class="string">'_Item Template_Name'</span>,
        <span style="color:rgb(221,17,68)" class="string">'description'</span>: <span style="color:rgb(221,17,68)" class="string">'__Item Template_Description'</span>,
        <span style="color:rgb(221,17,68)" class="string">'brand'</span>: <span style="color:rgb(221,17,68)" class="string">'New'</span>,
        <span style="color:rgb(221,17,68)" class="string">'item_group'</span>: <span style="color:rgb(221,17,68)" class="string">'Itens Projetados'</span>,
        <span style="color:rgb(221,17,68)" class="string">'stock_uom'</span>: <span style="color:rgb(221,17,68)" class="string">'Un'</span>,
        <span style="color:rgb(221,17,68)" class="string">'is_stock_item'</span>: <span style="color:rgb(221,17,68)" class="string">'No'</span>,
        <span style="color:rgb(221,17,68)" class="string">'is_purchase_item'</span>: <span style="color:rgb(221,17,68)" class="string">'No'</span>,
        <span style="color:rgb(221,17,68)" class="string">'is_sales_item'</span>: <span style="color:rgb(221,17,68)" class="string">'Yes'</span>,
        <span style="color:rgb(221,17,68)" class="string">'is_service_item'</span>: <span style="color:rgb(221,17,68)" class="string">'No'</span>,
        <span style="color:rgb(221,17,68)" class="string">'is_sample_item'</span>: <span style="color:rgb(221,17,68)" class="string">'No'</span>,
        <span style="color:rgb(221,17,68)" class="string">'max_discount'</span>: <span style="color:rgb(0,153,153)" class="number">65</span>,
        <span style="color:rgb(221,17,68)" class="string">'default_income_account'</span>: <span style="color:rgb(221,17,68)" class="string">u'Vendas - Grupo Realize Móveis'</span>,
        <span style="color:rgb(221,17,68)" class="string">'default_sales_cost_center'</span>: <span style="color:rgb(221,17,68)" class="string">u'Auto Inventory Accounting - Grupo Realize Móveis'</span>,    
    }, 
    <span style="color:rgb(153,153,136);font-style:italic" class="comment"># The Price</span>
    {
        <span style="color:rgb(221,17,68)" class="string">'doctype'</span>: <span style="color:rgb(221,17,68)" class="string">'Item Price'</span>,
        <span style="color:rgb(221,17,68)" class="string">'parentfield'</span>: <span style="color:rgb(221,17,68)" class="string">'ref_rate_details'</span>,
        <span style="color:rgb(221,17,68)" class="string">'price_list_name'</span>: <span style="color:rgb(221,17,68)" class="string">'Itens Projetados'</span>,
        <span style="color:rgb(221,17,68)" class="string">'ref_rate'</span>: <span style="color:rgb(221,17,68)" class="string">'_Item Template_Price'</span>,
        <span style="color:rgb(221,17,68)" class="string">'ref_currency'</span>: <span style="color:rgb(221,17,68)" class="string">'BRL'</span>,
        <span style="color:rgb(221,17,68)" class="string">'buying_or_selling'</span>: <span style="color:rgb(221,17,68)" class="string">'Selling'</span>
    }
]

sales_bom_template = [
    <span style="color:rgb(153,153,136);font-style:italic" class="comment">#nothing</span>
]

cost, increase = <span style="color:rgb(0,153,153)" class="number">0</span>, <span style="color:rgb(0,153,153)" class="number">0</span>
items = []

<span style="color:rgb(51,51,51);font-weight:bold" class="keyword">for</span> project_files <span style="color:rgb(51,51,51);font-weight:bold" class="keyword">in</span> filenames.split(<span style="color:rgb(221,17,68)" class="string">';'</span>):
    reader = PromobReader(project_files)              <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Init the parse</span>
    project = reader.getProject()                     <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Get the xml root element </span>
    data = project.toDict()                           <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Get the item and subitems to compose the sales bom</span>
    cost += data.get(<span style="color:rgb(221,17,68)" class="string">'project_cost'</span>, <span style="color:rgb(0,153,153)" class="number">0</span>)               <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Get the raw price of the item</span>
    increase += data.get(<span style="color:rgb(221,17,68)" class="string">'project_increase'</span>, <span style="color:rgb(0,153,153)" class="number">0</span>)       <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Get the project increase</span>

    <span style="color:rgb(51,51,51);font-weight:bold" class="keyword">for</span> i <span style="color:rgb(51,51,51);font-weight:bold" class="keyword">in</span> data.get(<span style="color:rgb(221,17,68)" class="string">'items'</span>, []):                                                    <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Process each item for CAD File</span>
        price = i.pop(<span style="color:rgb(221,17,68)" class="string">'price'</span>)                                                        <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Pop the price to append this on your doctype</span>
        <span style="color:rgb(51,51,51);font-weight:bold" class="keyword">try</span>:
            item = webnotes.bean(<span style="color:rgb(221,17,68)" class="string">'Item'</span>, i[<span style="color:rgb(221,17,68)" class="string">'item_code'</span>])                            <span style="color:rgb(153,153,136);font-style:italic" class="comment"># First can get the doctype from db</span>
            item.doc.fields.update(i)                                                <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Update the item data based on CAD data</span>
            pricelist = getlist(item.doclist, <span style="color:rgb(221,17,68)" class="string">'ref_rate_details'</span>)                   <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Get the price list</span>
            item.save()                                                             <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Save the item</span>
        <span style="color:rgb(51,51,51);font-weight:bold" class="keyword">except</span>:
            item = webnotes.bean(copy=enviroment_template)                          <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Make a new item based on template</span>
            item.doc.fields.update(i)                                               <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Update the item data based on CAD data</span>
            item.doclist[<span style="color:rgb(0,153,153)" class="number">1</span>].fields.update({<span style="color:rgb(221,17,68)" class="string">'ref_rate'</span>: price})                      <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Update the price</span>
            item.insert()                                                           <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Save the item</span>
        items.append(i[<span style="color:rgb(221,17,68)" class="string">'item_code'</span>]) <span style="color:rgb(153,153,136);font-style:italic" class="comment"># Append item code to response</span>

<span style="color:rgb(51,51,51);font-weight:bold" class="keyword">return</span> {
    <span style="color:rgb(221,17,68)" class="string">'project_cost'</span>: cost,
    <span style="color:rgb(221,17,68)" class="string">'project_increase'</span>: increase,
    <span style="color:rgb(221,17,68)" class="string">'project_cost_net'</span>: cost-increase,
    <span style="color:rgb(221,17,68)" class="string">'items'</span>: items
}</code></pre>
--


Maxwell Morais
(+55 11) 3931-1412 Ramal 31

 www.realizemodulados.com.br




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CABK1YkMVUtSsSwzZLHPt1pC7H-Fie%3DvPKLVuQ7BXSUu%3DnDW1GQ%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/6917FF67-EA75-488C-B8D3-D984C7526F91%40erpnext.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Rushabh, one more question.

If we have 2 doclist, the stored in database and the updated data.
webnotes lib, provide a good form to evaluate the diference between these doclist?



2013/7/3 Rushabh Mehta <rm…@gmail.com>

Max,

The price data is in the "doclist" of the Item "bean" object.

# get the item bean object
item = webnotes.bean("Item", item_id)

# get the price list record
item_price = item.doclist.get({"doctype": "Item Price", "price_list_name": "My Price List"})

# set a new price
if item_price:
item_price[0].ref_rate = product_cost
item.save()


To get a better idea, just do a print on item.doclist - you will get an idea, its a collection of records (one parent + many children)


best,

Rushabh



On 03-Jul-2013, at 8:07 PM, Maxwell Morais <ma...@gmail.com> wrote:

Hello All, we developing the integration of our CAD Software and the ERPNext Sales Order, and have some questions.

The code below, parse the CAD file, and create each item described on project scope, and append the material list to item (Sales BOM), but:

If we can get one saved item to update your content, we don't can refresh the price data, we obtain the price list, but do not understand what to do after this point to update the price of the item.

If we create a new item based on template using the webnotes.bean(copy=args) method, on call item.doc.fields.update(*args) this update all fields, but does not update the brand, and the brand is defined on args.

For now we are with these difficulties, could anyone shed some light?

@webnotes.whitelist()
def get_project_costs(filenames):
    from ParsePromob import PromobReader  # The file parse
    from webnotes.model.bean import getlist
    # The Item, Sales BOM and Price templates
enviroment_template = [
    <span style="color:rgb(153,153,136);font-style:italic"># The Item</span>
    {
        <span style="color:rgb(221,17,68)">&#39;doctype&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Item&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;item_code&#39;</span>: <span style="color:rgb(221,17,68)">&#39;_Item Template_Code&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;item_name&#39;</span>: <span style="color:rgb(221,17,68)">&#39;_Item Template_Name&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;description&#39;</span>: <span style="color:rgb(221,17,68)">&#39;__Item Template_Description&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;brand&#39;</span>: <span style="color:rgb(221,17,68)">&#39;New&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;item_group&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Itens Projetados&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;stock_uom&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Un&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;is_stock_item&#39;</span>: <span style="color:rgb(221,17,68)">&#39;No&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;is_purchase_item&#39;</span>: <span style="color:rgb(221,17,68)">&#39;No&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;is_sales_item&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Yes&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;is_service_item&#39;</span>: <span style="color:rgb(221,17,68)">&#39;No&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;is_sample_item&#39;</span>: <span style="color:rgb(221,17,68)">&#39;No&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;max_discount&#39;</span>: <span style="color:rgb(0,153,153)">65</span>,
        <span style="color:rgb(221,17,68)">&#39;default_income_account&#39;</span>: <span style="color:rgb(221,17,68)">u&#39;Vendas - Grupo Realize Móveis&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;default_sales_cost_center&#39;</span>: <span style="color:rgb(221,17,68)">u&#39;Auto Inventory Accounting - Grupo Realize Móveis&#39;</span>,    
    }, 
    <span style="color:rgb(153,153,136);font-style:italic"># The Price</span>
    {
        <span style="color:rgb(221,17,68)">&#39;doctype&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Item Price&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;parentfield&#39;</span>: <span style="color:rgb(221,17,68)">&#39;ref_rate_details&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;price_list_name&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Itens Projetados&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;ref_rate&#39;</span>: <span style="color:rgb(221,17,68)">&#39;_Item Template_Price&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;ref_currency&#39;</span>: <span style="color:rgb(221,17,68)">&#39;BRL&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;buying_or_selling&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Selling&#39;</span>
    }
]

sales_bom_template = [
    <span style="color:rgb(153,153,136);font-style:italic">#nothing</span>
]

cost, increase = <span style="color:rgb(0,153,153)">0</span>, <span style="color:rgb(0,153,153)">0</span>
items = []

<span style="color:rgb(51,51,51);font-weight:bold">for</span> project_files <span style="color:rgb(51,51,51);font-weight:bold">in</span> filenames.split(<span style="color:rgb(221,17,68)">&#39;;&#39;</span>):
    reader = PromobReader(project_files)              <span style="color:rgb(153,153,136);font-style:italic"># Init the parse</span>
    project = reader.getProject()                     <span style="color:rgb(153,153,136);font-style:italic"># Get the xml root element </span>
    data = project.toDict()                           <span style="color:rgb(153,153,136);font-style:italic"># Get the item and subitems to compose the sales bom</span>
    cost += data.get(<span style="color:rgb(221,17,68)">&#39;project_cost&#39;</span>, <span style="color:rgb(0,153,153)">0</span>)               <span style="color:rgb(153,153,136);font-style:italic"># Get the raw price of the item</span>
    increase += data.get(<span style="color:rgb(221,17,68)">&#39;project_increase&#39;</span>, <span style="color:rgb(0,153,153)">0</span>)       <span style="color:rgb(153,153,136);font-style:italic"># Get the project increase</span>

    <span style="color:rgb(51,51,51);font-weight:bold">for</span> i <span style="color:rgb(51,51,51);font-weight:bold">in</span> data.get(<span style="color:rgb(221,17,68)">&#39;items&#39;</span>, []):                                                    <span style="color:rgb(153,153,136);font-style:italic"># Process each item for CAD File</span>
        price = i.pop(<span style="color:rgb(221,17,68)">&#39;price&#39;</span>)                                                        <span style="color:rgb(153,153,136);font-style:italic"># Pop the price to append this on your doctype</span>
        <span style="color:rgb(51,51,51);font-weight:bold">try</span>:
            item = webnotes.bean(<span style="color:rgb(221,17,68)">&#39;Item&#39;</span>, i[<span style="color:rgb(221,17,68)">&#39;item_code&#39;</span>])                            <span style="color:rgb(153,153,136);font-style:italic"># First can get the doctype from db</span>
            item.doc.fields.update(i)                                                <span style="color:rgb(153,153,136);font-style:italic"># Update the item data based on CAD data</span>
            pricelist = getlist(item.doclist, <span style="color:rgb(221,17,68)">&#39;ref_rate_details&#39;</span>)                   <span style="color:rgb(153,153,136);font-style:italic"># Get the price list</span>
            item.save()                                                             <span style="color:rgb(153,153,136);font-style:italic"># Save the item</span>
        <span style="color:rgb(51,51,51);font-weight:bold">except</span>:
            item = webnotes.bean(copy=enviroment_template)                          <span style="color:rgb(153,153,136);font-style:italic"># Make a new item based on template</span>
            item.doc.fields.update(i)                                               <span style="color:rgb(153,153,136);font-style:italic"># Update the item data based on CAD data</span>
            item.doclist[<span style="color:rgb(0,153,153)">1</span>].fields.update({<span style="color:rgb(221,17,68)">&#39;ref_rate&#39;</span>: price})                      <span style="color:rgb(153,153,136);font-style:italic"># Update the price</span>
            item.insert()                                                           <span style="color:rgb(153,153,136);font-style:italic"># Save the item</span>
        items.append(i[<span style="color:rgb(221,17,68)">&#39;item_code&#39;</span>]) <span style="color:rgb(153,153,136);font-style:italic"># Append item code to response</span>

<span style="color:rgb(51,51,51);font-weight:bold">return</span> {
    <span style="color:rgb(221,17,68)">&#39;project_cost&#39;</span>: cost,
    <span style="color:rgb(221,17,68)">&#39;project_increase&#39;</span>: increase,
    <span style="color:rgb(221,17,68)">&#39;project_cost_net&#39;</span>: cost-increase,
    <span style="color:rgb(221,17,68)">&#39;items&#39;</span>: items
}</code></pre>
--


Maxwell Morais
(+55 11) 3931-1412 Ramal 31

www.realizemodulados.com.br




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CABK1YkMVUtSsSwzZLHPt1pC7H-Fie%3DvPKLVuQ7BXSUu%3DnDW1GQ%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.







You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/6917FF67-EA75-488C-B8D3-D984C7526F91%40erpnext.com.


For more options, visit https://groups.google.com/groups/opt_out.





--


Maxwell Morais

(+55 11) 3931-1412 Ramal 31
www.realizemodulados.com.br



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CABK1YkM4_Qf8dX6Tc%2BLZix6ZxA5F1WdepRvyJ7Kr5FBJhB%3DnrA%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Hi Max,

As of now, there is no method to find a diff between two doclists.

What kind of diff do you want? Something like "if doc with item_code=something" exists in old and not in new? and/or "what fields have changed in the doc between old and new", etc.

Maybe there could be an easier solution without going into diffs. Can you give an overview of what you are trying to achieve?

-Anand.

On 04-Jul-2013, at 1:39 AM, Maxwell Morais <ma...@gmail.com> wrote:

Rushabh, one more question.

If we have 2 doclist, the stored in database and the updated data.
webnotes lib, provide a good form to evaluate the diference between these doclist?



2013/7/3 Rushabh Mehta <rm…@gmail.com>

Max,

The price data is in the "doclist" of the Item "bean" object.

# get the item bean object
item = webnotes.bean("Item", item_id)

# get the price list record
item_price = item.doclist.get({"doctype": "Item Price", "price_list_name": "My Price List"})

# set a new price
if item_price:
  item_price[0].ref_rate = product_cost
  item.save()


To get a better idea, just do a print on item.doclist - you will get an idea, its a collection of records (one parent + many children)


best,

Rushabh



On 03-Jul-2013, at 8:07 PM, Maxwell Morais <ma...@gmail.com> wrote:

Hello All, we developing the integration of our CAD Software and the ERPNext Sales Order, and have some questions.

The code below, parse the CAD file, and create each item described on project scope, and append the material list to item (Sales BOM), but:

If we can get one saved item to update your content, we don’t can refresh the price data, we obtain the price list, but do not understand what to do after this point to update the price of the item.

If we create a new item based on template using the webnotes.bean(copy=args) method, on call item.doc.fields.update(*args) this update all fields, but does not update the brand, and the brand is defined on args.

For now we are with these difficulties, could anyone shed some light?

@webnotes.whitelist()
def get_project_costs(filenames):
    from ParsePromob import PromobReader  # The file parse
    from webnotes.model.bean import getlist
    # The Item, Sales BOM and Price templates

    enviroment_template = [
        # The Item
        {
            'doctype': 'Item',
            'item_code': '_Item Template_Code',
            'item_name': '_Item Template_Name',
            'description': '__Item Template_Description',
            'brand': 'New',
            'item_group': 'Itens Projetados',
            'stock_uom': 'Un',
            'is_stock_item': 'No',
            'is_purchase_item': 'No',
            'is_sales_item': 'Yes',
            'is_service_item': 'No',
            'is_sample_item': 'No',
            'max_discount': 65,
            'default_income_account': u'Vendas - Grupo Realize Móveis',
            'default_sales_cost_center': u'Auto Inventory Accounting - Grupo Realize Móveis',    
        }, 
        # The Price
        {
            'doctype': 'Item Price',
            'parentfield': 'ref_rate_details',
            'price_list_name': 'Itens Projetados',
            'ref_rate': '_Item Template_Price',
            'ref_currency': 'BRL',
            'buying_or_selling': 'Selling'
        }
    ]

    sales_bom_template = [
        #nothing
    ]

    cost, increase = 0, 0
    items = []

    for project_files in filenames.split(';'):
        reader = PromobReader(project_files)              # Init the parse
        project = reader.getProject()                     # Get the xml root element 
        data = project.toDict()                           # Get the item and subitems to compose the sales bom
        cost += data.get('project_cost', 0)               # Get the raw price of the item
        increase += data.get('project_increase', 0)       # Get the project increase

        for i in data.get('items', []):                                                    # Process each item for CAD File
            price = i.pop('price')                                                        # Pop the price to append this on your doctype
            try:
                item = webnotes.bean('Item', i['item_code'])                            # First can get the doctype from db
                item.doc.fields.update(i)                                                # Update the item data based on CAD data
                pricelist = getlist(item.doclist, 'ref_rate_details')                   # Get the price list
                item.save()                                                             # Save the item
            except:
                item = webnotes.bean(copy=enviroment_template)                          # Make a new item based on template
                item.doc.fields.update(i)                                               # Update the item data based on CAD data
                item.doclist[1].fields.update({'ref_rate': price})                      # Update the price
                item.insert()                                                           # Save the item
            items.append(i['item_code']) # Append item code to response

    return {
        'project_cost': cost,
        'project_increase': increase,
        'project_cost_net': cost-increase,
        'items': items
    }
--


Maxwell Morais
(+55 11) 3931-1412 Ramal 31

 www.realizemodulados.com.br




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CABK1YkMVUtSsSwzZLHPt1pC7H-Fie%3DvPKLVuQ7BXSUu%3DnDW1GQ%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/6917FF67-EA75-488C-B8D3-D984C7526F91%40erpnext.com.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--


Maxwell Morais

(+55 11) 3931-1412 Ramal 31
 www.realizemodulados.com.br




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CABK1YkM4_Qf8dX6Tc%2BLZix6ZxA5F1WdepRvyJ7Kr5FBJhB%3DnrA%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/365BE2A7-8384-4E01-9204-0FDB16DCC36A%40erpnext.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Hello Anand!

In a basic way, I just want to be able to compare 2 DocList, from left to right, why, I have a method that I just list all the items that will be included in a “good” sales.

ex:

dl1 = [....] # These are the items that are in the database, counting 33
DL2 = [....] # These items are updated, counting 28

dldiff = diff (DL1, DL2)
toinsert = dldiff.new_docs # These docs are in DL2 and not in dl1
toupdate = dldiff.updated_docs = # These docs are in dl1 and are modified in DL2
todelete = dldiff.removed_docs = # These docs are in dl1 not in DL2
unchanged = dldiff.unchanged_docs = # These docs existing in both dl's



2013/7/4 Anand Doshi <an...@iwebnotes.com>
Hi Max,

As of now, there is no method to find a diff between two doclists.

What kind of diff do you want? Something like "if doc with item_code=something" exists in old and not in new? and/or "what fields have changed in the doc between old and new", etc.

Maybe there could be an easier solution without going into diffs. Can you give an overview of what you are trying to achieve?

-Anand.

On 04-Jul-2013, at 1:39 AM, Maxwell Morais <ma…@gmail.com> wrote:


Rushabh, one more question.

If we have 2 doclist, the stored in database and the updated data.
webnotes lib, provide a good form to evaluate the diference between these doclist?



2013/7/3 Rushabh Mehta <rm…@gmail.com>

Max,

The price data is in the "doclist" of the Item "bean" object.

# get the item bean object
item = webnotes.bean("Item", item_id)

# get the price list record
item_price = item.doclist.get({"doctype": "Item Price", "price_list_name": "My Price List"})

# set a new price
if item_price:
item_price[0].ref_rate = product_cost
item.save()


To get a better idea, just do a print on item.doclist - you will get an idea, its a collection of records (one parent + many children)


best,

Rushabh



On 03-Jul-2013, at 8:07 PM, Maxwell Morais <ma...@gmail.com> wrote:

Hello All, we developing the integration of our CAD Software and the ERPNext Sales Order, and have some questions.

The code below, parse the CAD file, and create each item described on project scope, and append the material list to item (Sales BOM), but:

If we can get one saved item to update your content, we don't can refresh the price data, we obtain the price list, but do not understand what to do after this point to update the price of the item.

If we create a new item based on template using the webnotes.bean(copy=args) method, on call item.doc.fields.update(*args) this update all fields, but does not update the brand, and the brand is defined on args.

For now we are with these difficulties, could anyone shed some light?

@webnotes.whitelist()
def get_project_costs(filenames):
    from ParsePromob import PromobReader  # The file parse
    from webnotes.model.bean import getlist
    # The Item, Sales BOM and Price templates
enviroment_template = [
    <span style="color:rgb(153,153,136);font-style:italic"># The Item</span>
    {
        <span style="color:rgb(221,17,68)">&#39;doctype&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Item&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;item_code&#39;</span>: <span style="color:rgb(221,17,68)">&#39;_Item Template_Code&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;item_name&#39;</span>: <span style="color:rgb(221,17,68)">&#39;_Item Template_Name&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;description&#39;</span>: <span style="color:rgb(221,17,68)">&#39;__Item Template_Description&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;brand&#39;</span>: <span style="color:rgb(221,17,68)">&#39;New&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;item_group&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Itens Projetados&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;stock_uom&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Un&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;is_stock_item&#39;</span>: <span style="color:rgb(221,17,68)">&#39;No&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;is_purchase_item&#39;</span>: <span style="color:rgb(221,17,68)">&#39;No&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;is_sales_item&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Yes&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;is_service_item&#39;</span>: <span style="color:rgb(221,17,68)">&#39;No&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;is_sample_item&#39;</span>: <span style="color:rgb(221,17,68)">&#39;No&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;max_discount&#39;</span>: <span style="color:rgb(0,153,153)">65</span>,
        <span style="color:rgb(221,17,68)">&#39;default_income_account&#39;</span>: <span style="color:rgb(221,17,68)">u&#39;Vendas - Grupo Realize Móveis&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;default_sales_cost_center&#39;</span>: <span style="color:rgb(221,17,68)">u&#39;Auto Inventory Accounting - Grupo Realize Móveis&#39;</span>,    
    }, 
    <span style="color:rgb(153,153,136);font-style:italic"># The Price</span>
    {
        <span style="color:rgb(221,17,68)">&#39;doctype&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Item Price&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;parentfield&#39;</span>: <span style="color:rgb(221,17,68)">&#39;ref_rate_details&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;price_list_name&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Itens Projetados&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;ref_rate&#39;</span>: <span style="color:rgb(221,17,68)">&#39;_Item Template_Price&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;ref_currency&#39;</span>: <span style="color:rgb(221,17,68)">&#39;BRL&#39;</span>,
        <span style="color:rgb(221,17,68)">&#39;buying_or_selling&#39;</span>: <span style="color:rgb(221,17,68)">&#39;Selling&#39;</span>
    }
]

sales_bom_template = [
    <span style="color:rgb(153,153,136);font-style:italic">#nothing</span>
]

cost, increase = <span style="color:rgb(0,153,153)">0</span>, <span style="color:rgb(0,153,153)">0</span>
items = []

<span style="color:rgb(51,51,51);font-weight:bold">for</span> project_files <span style="color:rgb(51,51,51);font-weight:bold">in</span> filenames.split(<span style="color:rgb(221,17,68)">&#39;;&#39;</span>):
    reader = PromobReader(project_files)              <span style="color:rgb(153,153,136);font-style:italic"># Init the parse</span>
    project = reader.getProject()                     <span style="color:rgb(153,153,136);font-style:italic"># Get the xml root element </span>
    data = project.toDict()                           <span style="color:rgb(153,153,136);font-style:italic"># Get the item and subitems to compose the sales bom</span>
    cost += data.get(<span style="color:rgb(221,17,68)">&#39;project_cost&#39;</span>, <span style="color:rgb(0,153,153)">0</span>)               <span style="color:rgb(153,153,136);font-style:italic"># Get the raw price of the item</span>
    increase += data.get(<span style="color:rgb(221,17,68)">&#39;project_increase&#39;</span>, <span style="color:rgb(0,153,153)">0</span>)       <span style="color:rgb(153,153,136);font-style:italic"># Get the project increase</span>

    <span style="color:rgb(51,51,51);font-weight:bold">for</span> i <span style="color:rgb(51,51,51);font-weight:bold">in</span> data.get(<span style="color:rgb(221,17,68)">&#39;items&#39;</span>, []):                                                    <span style="color:rgb(153,153,136);font-style:italic"># Process each item for CAD File</span>
        price = i.pop(<span style="color:rgb(221,17,68)">&#39;price&#39;</span>)                                                        <span style="color:rgb(153,153,136);font-style:italic"># Pop the price to append this on your doctype</span>
        <span style="color:rgb(51,51,51);font-weight:bold">try</span>:
            item = webnotes.bean(<span style="color:rgb(221,17,68)">&#39;Item&#39;</span>, i[<span style="color:rgb(221,17,68)">&#39;item_code&#39;</span>])                            <span style="color:rgb(153,153,136);font-style:italic"># First can get the doctype from db</span>
            item.doc.fields.update(i)                                                <span style="color:rgb(153,153,136);font-style:italic"># Update the item data based on CAD data</span>
            pricelist = getlist(item.doclist, <span style="color:rgb(221,17,68)">&#39;ref_rate_details&#39;</span>)                   <span style="color:rgb(153,153,136);font-style:italic"># Get the price list</span>
            item.save()                                                             <span style="color:rgb(153,153,136);font-style:italic"># Save the item</span>
        <span style="color:rgb(51,51,51);font-weight:bold">except</span>:
            item = webnotes.bean(copy=enviroment_template)                          <span style="color:rgb(153,153,136);font-style:italic"># Make a new item based on template</span>
            item.doc.fields.update(i)                                               <span style="color:rgb(153,153,136);font-style:italic"># Update the item data based on CAD data</span>
            item.doclist[<span style="color:rgb(0,153,153)">1</span>].fields.update({<span style="color:rgb(221,17,68)">&#39;ref_rate&#39;</span>: price})                      <span style="color:rgb(153,153,136);font-style:italic"># Update the price</span>
            item.insert()                                                           <span style="color:rgb(153,153,136);font-style:italic"># Save the item</span>
        items.append(i[<span style="color:rgb(221,17,68)">&#39;item_code&#39;</span>]) <span style="color:rgb(153,153,136);font-style:italic"># Append item code to response</span>

<span style="color:rgb(51,51,51);font-weight:bold">return</span> {
    <span style="color:rgb(221,17,68)">&#39;project_cost&#39;</span>: cost,
    <span style="color:rgb(221,17,68)">&#39;project_increase&#39;</span>: increase,
    <span style="color:rgb(221,17,68)">&#39;project_cost_net&#39;</span>: cost-increase,
    <span style="color:rgb(221,17,68)">&#39;items&#39;</span>: items
}</code></pre>
--


Maxwell Morais
(+55 11) 3931-1412 Ramal 31

www.realizemodulados.com.br




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CABK1YkMVUtSsSwzZLHPt1pC7H-Fie%3DvPKLVuQ7BXSUu%3DnDW1GQ%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.








You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/6917FF67-EA75-488C-B8D3-D984C7526F91%40erpnext.com.


For more options, visit https://groups.google.com/groups/opt_out.





--


Maxwell Morais

(+55 11) 3931-1412 Ramal 31
www.realizemodulados.com.br




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CABK1YkM4_Qf8dX6Tc%2BLZix6ZxA5F1WdepRvyJ7Kr5FBJhB%3DnrA%40mail.gmail.com.


For more options, visit https://groups.google.com/groups/opt_out.





You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/365BE2A7-8384-4E01-9204-0FDB16DCC36A%40erpnext.com.


For more options, visit https://groups.google.com/groups/opt_out.





--


Maxwell Morais

(+55 11) 3931-1412 Ramal 31
www.realizemodulados.com.br



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CABK1YkN2EtddBJaAN7vUrVeOGpMWnrXq8jHR%2BW3Q7Lh4B80QTg%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Hi Max,

We had experimented with version control for each document a few months back.

You should get an idea about how the diff was done to write your own diff functions.

Thanks,
Anand.

On 04-Jul-2013, at 6:32 PM, Maxwell Morais <ma...@gmail.com> wrote:

Hello Anand!

In a basic way, I just want to be able to compare 2 DocList, from left to right, why, I have a method that I just list all the items that will be included in a “good” sales.

ex:

dl1 = [....] # These are the items that are in the database, counting 33
DL2 = [....] # These items are updated, counting 28

dldiff = diff (DL1, DL2)
toinsert = dldiff.new_docs # These docs are in DL2 and not in dl1
toupdate = dldiff.updated_docs = # These docs are in dl1 and are modified in DL2
todelete = dldiff.removed_docs = # These docs are in dl1 not in DL2
unchanged = dldiff.unchanged_docs = # These docs existing in both dl’s



2013/7/4 Anand Doshi <an...@iwebnotes.com>
Hi Max,

As of now, there is no method to find a diff between two doclists.

What kind of diff do you want? Something like "if doc with item_code=something" exists in old and not in new? and/or "what fields have changed in the doc between old and new", etc.

Maybe there could be an easier solution without going into diffs. Can you give an overview of what you are trying to achieve?

-Anand.

On 04-Jul-2013, at 1:39 AM, Maxwell Morais <ma…@gmail.com> wrote:


Rushabh, one more question.

If we have 2 doclist, the stored in database and the updated data.
webnotes lib, provide a good form to evaluate the diference between these doclist?



2013/7/3 Rushabh Mehta <rm…@gmail.com>

Max,

The price data is in the "doclist" of the Item "bean" object.

# get the item bean object
item = webnotes.bean("Item", item_id)

# get the price list record
item_price = item.doclist.get({"doctype": "Item Price", "price_list_name": "My Price List"})

# set a new price
if item_price:
  item_price[0].ref_rate = product_cost
  item.save()


To get a better idea, just do a print on item.doclist - you will get an idea, its a collection of records (one parent + many children)


best,

Rushabh



On 03-Jul-2013, at 8:07 PM, Maxwell Morais <ma...@gmail.com> wrote:

Hello All, we developing the integration of our CAD Software and the ERPNext Sales Order, and have some questions.

The code below, parse the CAD file, and create each item described on project scope, and append the material list to item (Sales BOM), but:

If we can get one saved item to update your content, we don’t can refresh the price data, we obtain the price list, but do not understand what to do after this point to update the price of the item.

If we create a new item based on template using the webnotes.bean(copy=args) method, on call item.doc.fields.update(*args) this update all fields, but does not update the brand, and the brand is defined on args.

For now we are with these difficulties, could anyone shed some light?

@webnotes.whitelist()
def get_project_costs(filenames):
    from ParsePromob import PromobReader  # The file parse
    from webnotes.model.bean import getlist
    # The Item, Sales BOM and Price templates

    enviroment_template = [
        # The Item
        {
            'doctype': 'Item',
            'item_code': '_Item Template_Code',
            'item_name': '_Item Template_Name',
            'description': '__Item Template_Description',
            'brand': 'New',
            'item_group': 'Itens Projetados',
            'stock_uom': 'Un',
            'is_stock_item': 'No',
            'is_purchase_item': 'No',
            'is_sales_item': 'Yes',
            'is_service_item': 'No',
            'is_sample_item': 'No',
            'max_discount': 65,
            'default_income_account': u'Vendas - Grupo Realize Móveis',
            'default_sales_cost_center': u'Auto Inventory Accounting - Grupo Realize Móveis',    
        }, 
        # The Price
        {
            'doctype': 'Item Price',
            'parentfield': 'ref_rate_details',
            'price_list_name': 'Itens Projetados',
            'ref_rate': '_Item Template_Price',
            'ref_currency': 'BRL',
            'buying_or_selling': 'Selling'
        }
    ]

    sales_bom_template = [
        #nothing
    ]

    cost, increase = 0, 0
    items = []

    for project_files in filenames.split(';'):
        reader = PromobReader(project_files)              # Init the parse
        project = reader.getProject()                     # Get the xml root element 
        data = project.toDict()                           # Get the item and subitems to compose the sales bom
        cost += data.get('project_cost', 0)               # Get the raw price of the item
        increase += data.get('project_increase', 0)       # Get the project increase

        for i in data.get('items', []):                                                    # Process each item for CAD File
            price = i.pop('price')                                                        # Pop the price to append this on your doctype
            try:
                item = webnotes.bean('Item', i['item_code'])                            # First can get the doctype from db
                item.doc.fields.update(i)                                                # Update the item data based on CAD data
                pricelist = getlist(item.doclist, 'ref_rate_details')                   # Get the price list
                item.save()                                                             # Save the item
            except:
                item = webnotes.bean(copy=enviroment_template)                          # Make a new item based on template
                item.doc.fields.update(i)                                               # Update the item data based on CAD data
                item.doclist[1].fields.update({'ref_rate': price})                      # Update the price
                item.insert()                                                           # Save the item
            items.append(i['item_code']) # Append item code to response

    return {
        'project_cost': cost,
        'project_increase': increase,
        'project_cost_net': cost-increase,
        'items': items
    }
--


Maxwell Morais
(+55 11) 3931-1412 Ramal 31

 www.realizemodulados.com.br




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CABK1YkMVUtSsSwzZLHPt1pC7H-Fie%3DvPKLVuQ7BXSUu%3DnDW1GQ%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/6917FF67-EA75-488C-B8D3-D984C7526F91%40erpnext.com.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--


Maxwell Morais

(+55 11) 3931-1412 Ramal 31
 www.realizemodulados.com.br




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CABK1YkM4_Qf8dX6Tc%2BLZix6ZxA5F1WdepRvyJ7Kr5FBJhB%3DnrA%40mail.gmail.com.


For more options, visit https://groups.google.com/groups/opt_out.
 
 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/365BE2A7-8384-4E01-9204-0FDB16DCC36A%40erpnext.com.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--


Maxwell Morais

(+55 11) 3931-1412 Ramal 31
 www.realizemodulados.com.br




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CABK1YkN2EtddBJaAN7vUrVeOGpMWnrXq8jHR%2BW3Q7Lh4B80QTg%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/37BE8671-0314-4B14-9424-4372024513F8%40erpnext.com.

For more options, visit https://groups.google.com/groups/opt_out.