diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 956867d7abc..23114f0d78b 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -558,13 +558,14 @@ class DocType(SellingController): def validate_rate_with_refdoc(self): """Validate values with reference document with previous document""" - for d in self.doclist.get({"parentfield": "entries"}): - if d.so_detail: - self.check_value("Sales Order", d.sales_order, d.so_detail, - d.export_rate, d.item_code) - if d.dn_detail: - self.check_value("Delivery Note", d.delivery_note, d.dn_detail, - d.export_rate, d.item_code) + if cint(webnotes.defaults.get_global_default('maintain_same_sales_rate')): + for d in self.doclist.get({"parentfield": "entries"}): + if d.so_detail: + self.check_value("Sales Order", d.sales_order, d.so_detail, + d.export_rate, d.item_code) + if d.dn_detail: + self.check_value("Delivery Note", d.delivery_note, d.dn_detail, + d.export_rate, d.item_code) def check_value(self, ref_dt, ref_dn, ref_item_dn, val, item_code): ref_val = webnotes.conn.get_value(ref_dt + " Item", ref_item_dn, "export_rate") diff --git a/patches/july_2013/p01_same_sales_rate_patch.py b/patches/july_2013/p01_same_sales_rate_patch.py new file mode 100644 index 00000000000..cc1f6daa998 --- /dev/null +++ b/patches/july_2013/p01_same_sales_rate_patch.py @@ -0,0 +1,9 @@ +def execute(): + import webnotes + webnotes.reload_doc("setup", "doctype", "global_defaults") + + from webnotes.model.code import get_obj + gd = get_obj('Global Defaults') + gd.doc.maintain_same_sales_rate = 1 + gd.doc.save() + gd.on_update() \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 812f641fcb2..d15602d7993 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -246,4 +246,5 @@ patch_list = [ "execute:webnotes.reload_doc('accounts', 'DocType Mapper', 'Purchase Order-Purchase Invoice') # 2013-07-04 3:00", "execute:webnotes.reload_doc('accounts', 'DocType Mapper', 'Purchase Receipt-Purchase Invoice') # 2013-07-04 3:00", "execute:webnotes.delete_doc('Report', 'Sales Orders Pending To Be Delivered')", + "patches.july_2013.p01_same_sales_rate_patch", ] diff --git a/setup/doctype/global_defaults/global_defaults.py b/setup/doctype/global_defaults/global_defaults.py index dc7f6b4b735..a921229a160 100644 --- a/setup/doctype/global_defaults/global_defaults.py +++ b/setup/doctype/global_defaults/global_defaults.py @@ -48,6 +48,7 @@ keydict = { 'disable_rounded_total': 'disable_rounded_total', "update_stock": "update_stock", "auto_inventory_accounting": "auto_inventory_accounting", + 'maintain_same_sales_rate' : 'maintain_same_sales_rate', } class DocType: diff --git a/setup/doctype/global_defaults/global_defaults.txt b/setup/doctype/global_defaults/global_defaults.txt index 175ca9414b6..1e1505a6b16 100644 --- a/setup/doctype/global_defaults/global_defaults.txt +++ b/setup/doctype/global_defaults/global_defaults.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-05-02 17:53:24", + "creation": "2013-07-16 18:18:01", "docstatus": 0, - "modified": "2013-05-22 15:57:26", + "modified": "2013-07-16 18:23:52", "modified_by": "Administrator", "owner": "Administrator" }, @@ -27,8 +27,6 @@ "permlevel": 0 }, { - "amend": 0, - "cancel": 0, "create": 1, "doctype": "DocPerm", "name": "__common__", @@ -439,6 +437,12 @@ "label": "Disable Rounded Total", "read_only": 0 }, + { + "doctype": "DocField", + "fieldname": "maintain_same_sales_rate", + "fieldtype": "Check", + "label": "Maintain same rate throughout sales cycle" + }, { "doctype": "DocField", "fieldname": "buying", @@ -526,6 +530,11 @@ "label": "SMS Sender Name", "read_only": 0 }, + { + "amend": 0, + "cancel": 0, + "doctype": "DocPerm" + }, { "doctype": "DocPerm" }