diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index b459b64d69a..50fa82dec84 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -300,18 +300,14 @@ class DocType(TransactionBase): supplier = '' if d.purchase_order and not d.purchase_order in self.po_list: supplier = sql("select supplier from `tabPurchase Order` where name = '%s'" % d.purchase_order)[0][0] - doctype = 'purchase order' - doctype_no = cstr(d.purchase_order) if supplier and not cstr(self.doc.supplier) == cstr(supplier): - msgprint("Supplier name %s do not match with supplier name of %s %s." %(self.doc.supplier,doctype,doctype_no)) + msgprint("Supplier name %s do not match with supplier name of purhase order: %s." %(self.doc.supplier,cstr(d.purchase_order))) raise Exception , " Validation Error " if d.purchase_receipt and not d.purchase_receipt in self.pr_list: supplier = sql("select supplier from `tabPurchase Receipt` where name = '%s'" % d.purchase_receipt)[0][0] - doctype = 'purchase receipt' - doctype_no = cstr(d.purchase_receipt) if supplier and not cstr(self.doc.supplier) == cstr(supplier): - msgprint("Supplier name %s do not match with supplier name of %s %s." %(self.doc.supplier,doctype,doctype_no)) + msgprint("Supplier name %s do not match with supplier name of %s %s." %(self.doc.supplier,cstr(d.purchase_receipt))) raise Exception , " Validation Error " # Validate values with reference document @@ -325,7 +321,7 @@ class DocType(TransactionBase): def validate_po_pr(self, d): # check po / pr for qty and rates and currency and conversion rate - # always import_rate must be equal to import_rate of purchase order + # currency, import_rate must be equal to currency, import_rate of purchase order if d.purchase_order and not d.purchase_order in self.po_list: # currency currency = cstr(sql("select currency from `tabPurchase Order` where name = '%s'" % d.purchase_order)[0][0]) @@ -334,7 +330,7 @@ class DocType(TransactionBase): raise Exception # import_rate rate = flt(sql('select import_rate from `tabPurchase Order Item` where item_code=%s and parent=%s and name = %s', (d.item_code, d.purchase_order, d.po_detail))[0][0]) - if abs(rate - flt(d.import_rate)) > 1: + if abs(rate - flt(d.import_rate)) > 1 and cint(get_defaults('maintain_same_rate')): msgprint("Import Rate for %s in the Purchase Order is %s. Rate must be same as Purchase Order Rate" % (d.item_code,rate)) raise Exception diff --git a/erpnext/patches/may_2012/same_purchase_rate_patch.py b/erpnext/patches/may_2012/same_purchase_rate_patch.py new file mode 100644 index 00000000000..44c0b3f6e82 --- /dev/null +++ b/erpnext/patches/may_2012/same_purchase_rate_patch.py @@ -0,0 +1,7 @@ +def execute(): + import webnotes + gd = webnotes.model.code.get_obj('Global Defaults') + gd.doc.maintain_same_rate = 1 + gd.doc.save() + gd.on_update() + \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index d1df7de7368..32149d5d925 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -372,5 +372,9 @@ patch_list = [ 'patch_file': 'clear_session_cache', 'description': 'clears session cache as shifting to json format' }, - + { + 'patch_module': 'patches.may_2012', + 'patch_file': 'same_purchase_rate_patch', + 'description': 'Main same rate throughout pur cycle: in global defaults, by default set true' + }, ] \ No newline at end of file diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.py b/erpnext/setup/doctype/global_defaults/global_defaults.py index 04276407c1d..9d308852fdb 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.py +++ b/erpnext/setup/doctype/global_defaults/global_defaults.py @@ -35,7 +35,8 @@ keydict = { 'date_format': 'date_format', 'currency_format':'default_currency_format', 'account_url':'account_url', - 'allow_negative_stock' : 'allow_negative_stock' + 'allow_negative_stock' : 'allow_negative_stock', + 'maintain_same_rate' : 'maintain_same_rate' } class DocType: diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.txt b/erpnext/setup/doctype/global_defaults/global_defaults.txt index 5355c1008fb..d1175b7c19b 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.txt +++ b/erpnext/setup/doctype/global_defaults/global_defaults.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-04-18 17:00:50', + 'creation': '2012-04-20 14:02:53', 'docstatus': 0, - 'modified': '2012-04-19 17:24:45', + 'modified': '2012-05-22 14:11:21', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -224,8 +224,8 @@ 'fieldtype': u'Select', 'label': u'Default Valuation Method', 'options': u'FIFO\nMoving Average' - }, - + }, + # DocField { 'colour': u'White:FFF', @@ -508,6 +508,14 @@ 'options': u'No\nYes' }, + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'maintain_same_rate', + 'fieldtype': u'Check', + 'label': u'Maintain same rate throughout purchase cycle' + }, + # DocField { 'doctype': u'DocField', @@ -543,4 +551,4 @@ 'fieldtype': u'Data', 'label': u'SMS Sender Name' } -] +] \ No newline at end of file