Merge branch 'shf_rename' of github.com:webnotes/erpnext into shf_rename

This commit is contained in:
Rushabh Mehta
2012-04-25 18:25:29 +05:30
2 changed files with 192 additions and 217 deletions

View File

@@ -91,40 +91,27 @@ class DocType:
i.is_stock_item = 'No'
i.save(1)
# This function is deprecated as we will see only pricelist which is selected
# def get_price_lists(self):
# return [i[0] for i in sql("select name from `tabPrice List` where docstatus != 2")]
# Update Rate
# -----------
def update_ref_rate(self, i):
ref_rate,count, p, currency = 0,0, self.doc.price_list, self.doc.currency
if not cstr(self.doc.price_list):
msgprint("Please enter Price List.")
raise Exception
ref_rate = 0
if self.doc.price_list:
if not cstr(self.doc.currency):
msgprint("Please enter Currency.")
raise Exception
for d in getlist(self.doclist, "sales_bom_items"):
item_rate = sql("select ref_rate,ref_currency from `tabItem Price` where price_list_name=%s and parent=%s", (p, d.item_code))
if not item_rate:
msgprint("Item %s does not have a rate for Price List %s. Did not update rates for this Price List" % (d.item_code, p))
raise Exception
# if count == 0 : currency = cstr(item_rate[0][1])
if not cstr(currency) == cstr(item_rate[0][1]):
msgprint("Item %s currency %s does not match with other items currency i.e. %s " %(d.item_code,item_rate[0][1],currency))
raise Exception
count += 1
ref_rate += (flt(d.qty) * flt(item_rate[0][0]))
item_rate = sql("select ref_rate,ref_currency from `tabItem Price` where price_list_name=%s and parent=%s", (self.doc.price_list, d.item_code))
ref_rate += flt(d.qty) * (item_rate and flt(item_rate[0][0]) or 0)
if ref_rate:
# clear old rates
sql("delete from `tabItem Price` where parent=%s and price_list_name = %s", (i.name, self.doc.price_list))
pld = addchild(i,"ref_rate_details", "Item Price")
pld.price_list_name = p
pld.price_list_name = self.doc.price_List
pld.ref_rate = flt(ref_rate)
pld.ref_currency = currency
pld.ref_currency = self.doc.currency
pld.save()
# Update Items
# ------------
def update_item(self):
@@ -135,25 +122,10 @@ class DocType:
i.stock_uom = self.doc.stock_uom
i.item_group = self.doc.item_group
# clear old rates
sql("delete from `tabItem Price` where parent=%s", i.name)
# update rates
new_rates = {}
# pl_list = self.get_price_lists()
#for p in self.get_price_lists():
self.update_ref_rate(i)
# update description and item name
n1, n2 = [], []
for d in getlist(self.doclist, "sales_bom_items"):
n, desc = sql("select item_name, description from tabItem where name=%s", d.item_code)[0]
n1.append(n)
n2.append(desc)
self.doc.new_item_name = (' ').join(n1)
self.doc.description = ("\n" + "\n").join(n2)
i.item_name = self.doc.new_item_name
i.description = self.doc.description

View File

@@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:36',
'creation': '2012-04-23 16:00:21',
'docstatus': 0,
'modified': '2012-03-27 14:45:51',
'modified': '2012-04-24 15:07:42',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@@ -24,7 +24,7 @@
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 40
'version': 1
},
# These values are common for all DocField
@@ -52,30 +52,6 @@
'name': u'Sales BOM'
},
# DocPerm
{
'amend': 0,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Sales User',
'submit': 0,
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Sales User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
@@ -124,15 +100,28 @@
'write': 0
},
# DocField
# DocPerm
{
'doctype': u'DocField',
'fieldname': u'trash_reason',
'fieldtype': u'Small Text',
'label': u'Trash Reason',
'oldfieldname': u'trash_reason',
'oldfieldtype': u'Small Text',
'permlevel': 1
'amend': 0,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Sales User',
'submit': 0,
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Sales User',
'submit': 0,
'write': 0
},
# DocField
@@ -145,7 +134,7 @@
'oldfieldname': u'new_item_code',
'oldfieldtype': u'Data',
'permlevel': 1,
'reqd': 0
'reqd': 1
},
# DocField
@@ -156,7 +145,8 @@
'label': u'New Item Name',
'oldfieldname': u'new_item_name',
'oldfieldtype': u'Data',
'permlevel': 0
'permlevel': 0,
'reqd': 1
},
# DocField
@@ -167,7 +157,7 @@
'label': u'New Item Brand',
'oldfieldname': u'new_item_brand',
'oldfieldtype': u'Data',
'permlevel': 1
'permlevel': 0
},
# DocField
@@ -178,7 +168,8 @@
'label': u'New Description',
'oldfieldname': u'description',
'oldfieldtype': u'Text',
'permlevel': 1,
'permlevel': 0,
'reqd': 1,
'width': u'300px'
},
@@ -191,7 +182,8 @@
'oldfieldname': u'item_group',
'oldfieldtype': u'Link',
'options': u'Item Group',
'permlevel': 0
'permlevel': 0,
'reqd': 1
},
# DocField
@@ -267,7 +259,7 @@
'fieldtype': u'Date',
'label': u'Amendment Date',
'no_copy': 1,
'permlevel': 0,
'permlevel': 1,
'print_hide': 1
},
@@ -281,5 +273,16 @@
'options': u'Sales Invoice',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'trash_reason',
'fieldtype': u'Small Text',
'label': u'Trash Reason',
'oldfieldname': u'trash_reason',
'oldfieldtype': u'Small Text',
'permlevel': 1
}
]