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
}
--
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...@googlegroups.com.
To post to this group, send email to erpnext-dev...@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.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/6917FF67-EA75-488C-B8D3-D984C7526F91%40erpnext.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.
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
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/365BE2A7-8384-4E01-9204-0FDB16DCC36A%40erpnext.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CABK1YkN2EtddBJaAN7vUrVeOGpMWnrXq8jHR%2BW3Q7Lh4B80QTg%40mail.gmail.com.