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
commit 44279f87b4
2 changed files with 192 additions and 217 deletions

View File

@ -91,40 +91,27 @@ class DocType:
i.is_stock_item = 'No' i.is_stock_item = 'No'
i.save(1) 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 # Update Rate
# -----------
def update_ref_rate(self, i): def update_ref_rate(self, i):
ref_rate,count, p, currency = 0,0, self.doc.price_list, self.doc.currency ref_rate = 0
if not cstr(self.doc.price_list): if self.doc.price_list:
msgprint("Please enter Price List.")
raise Exception
if not cstr(self.doc.currency): if not cstr(self.doc.currency):
msgprint("Please enter Currency.") msgprint("Please enter Currency.")
raise Exception raise Exception
for d in getlist(self.doclist, "sales_bom_items"): 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)) 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))
if not item_rate: ref_rate += flt(d.qty) * (item_rate and flt(item_rate[0][0]) or 0)
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 ref_rate:
# if count == 0 : currency = cstr(item_rate[0][1]) # clear old rates
if not cstr(currency) == cstr(item_rate[0][1]): sql("delete from `tabItem Price` where parent=%s and price_list_name = %s", (i.name, self.doc.price_list))
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]))
pld = addchild(i,"ref_rate_details", "Item Price") 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_rate = flt(ref_rate)
pld.ref_currency = currency pld.ref_currency = self.doc.currency
pld.save() pld.save()
# Update Items # Update Items
# ------------ # ------------
def update_item(self): def update_item(self):
@ -135,25 +122,10 @@ class DocType:
i.stock_uom = self.doc.stock_uom i.stock_uom = self.doc.stock_uom
i.item_group = self.doc.item_group i.item_group = self.doc.item_group
# clear old rates
sql("delete from `tabItem Price` where parent=%s", i.name)
# update rates # update rates
new_rates = {} new_rates = {}
# pl_list = self.get_price_lists()
#for p in self.get_price_lists():
self.update_ref_rate(i) 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.item_name = self.doc.new_item_name
i.description = self.doc.description i.description = self.doc.description

View File

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