From 6a3b9513524039bd5b99ca9ffcf25790db677138 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 16 Jul 2013 18:34:35 +0530 Subject: [PATCH] [accounts] [feature] optional checkbox for same rate validation in sales cycle --- accounts/doctype/sales_invoice/sales_invoice.py | 15 ++++++++------- patches/july_2013/p01_same_sales_rate_patch.py | 9 +++++++++ patches/patch_list.py | 1 + .../doctype/global_defaults/global_defaults.py | 1 + .../doctype/global_defaults/global_defaults.txt | 17 +++++++++++++---- 5 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 patches/july_2013/p01_same_sales_rate_patch.py diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 956867d7ab..23114f0d78 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 0000000000..cc1f6daa99 --- /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 812f641fcb..d15602d799 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 dc7f6b4b73..a921229a16 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 175ca9414b..1e1505a6b1 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" }