From e33d0be32c38485f7705af8ad12e59fe43645f80 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 6 Sep 2013 13:23:33 +0530 Subject: [PATCH 1/9] [fix] [minor] changed uom replace utility message --- stock/doctype/item/item.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index e6c277ee08..f5d50be7a7 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -62,13 +62,12 @@ class DocType(DocListController): def check_stock_uom_with_bin(self): if not self.doc.fields.get("__islocal"): - bin = webnotes.conn.sql("select stock_uom from `tabBin` where item_code = %s", - self.doc.name) - if self.doc.stock_uom and bin and cstr(bin[0][0]) \ - and cstr(bin[0][0]) != cstr(self.doc.stock_uom): - msgprint(_("Please Update Stock UOM with the help of Stock UOM Replace Utility."), - raise_exception=1) - + bin_uom = webnotes.conn.get_value("Bin", {"item_code": self.doc.name}, "stock_uom") + if self.doc.stock_uom and bin_uom and cstr(bin_uom) != cstr(self.doc.stock_uom): + webnotes.throw(_("Default Unit of Measure can not be changed directly \ + because you have already made some transaction(s) with another UOM. \ + To change default UOM, use 'UOM Replace Utility' tool under Stock module.")) + def validate_conversion_factor(self): check_list = [] for d in getlist(self.doclist,'uom_conversion_details'): From a3f6fda0df482b5ce8bf39eefb2d25d261e8d1e6 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 6 Sep 2013 13:37:52 +0530 Subject: [PATCH 2/9] [fix] Hide Make Delivery Note button, if Sales Invoice is made from Delivery Note. Hide Make Invoice Button, if Delivery Note is made from Sales Invoice --- accounts/doctype/sales_invoice/sales_invoice.js | 14 ++++++++++++-- stock/doctype/delivery_note/delivery_note.js | 12 +++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 1378fab51a..f224c352de 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -62,8 +62,18 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); - if(cint(doc.update_stock)!=1) - cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']); + if(cint(doc.update_stock)!=1) { + // show Make Delivery Note button only if Sales Invoice is not created from Delivery Note + var from_delivery_note = false; + from_delivery_note = cur_frm.get_doclist({parentfield: "entries"}) + .some(function(item) { + return item.delivery_note ? true : false; + }); + + if(!from_delivery_note) + cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']); + } + if(doc.outstanding_amount!=0) cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher); diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js index 063b25899d..80c26463ff 100644 --- a/stock/doctype/delivery_note/delivery_note.js +++ b/stock/doctype/delivery_note/delivery_note.js @@ -16,7 +16,17 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( refresh: function(doc, dt, dn) { this._super(); - if(!doc.__billing_complete && doc.docstatus==1) cur_frm.add_custom_button('Make Invoice', this.make_sales_invoice); + if(!doc.__billing_complete && doc.docstatus==1) { + // show Make Invoice button only if Delivery Note is not created from Sales Invoice + var from_sales_invoice = false; + from_sales_invoice = cur_frm.get_doclist({parentfield: "delivery_note_details"}) + .some(function(item) { + return item.prevdoc_doctype==="Sales Invoice" ? true : false; + }); + + if(!from_sales_invoice) + cur_frm.add_custom_button('Make Invoice', this.make_sales_invoice); + } if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Installation Note', this.make_installation_note); From 78fde78405378e15fd93e62d2a6f97a31dd59161 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 6 Sep 2013 14:05:47 +0530 Subject: [PATCH 3/9] [fix] [minor] changed uom replace utility message --- stock/doctype/item/item.py | 12 +++++++++--- .../stock_uom_replace_utility.py | 16 +++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index f5d50be7a7..ac9f18fcd0 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -30,8 +30,8 @@ class DocType(DocListController): self.check_warehouse_is_set_for_stock_item() self.check_stock_uom_with_bin() - self.validate_conversion_factor() self.add_default_uom_in_conversion_factor_table() + self.validate_conversion_factor() self.valiadte_item_type() self.check_for_active_boms() self.validate_price_lists() @@ -59,15 +59,21 @@ class DocType(DocListController): ch = addchild(self.doc, 'uom_conversion_details', 'UOM Conversion Detail', self.doclist) ch.uom = self.doc.stock_uom ch.conversion_factor = 1 + + for d in self.doclist.get({"parentfield": "uom_conversion_details"}): + if d.conversion_factor == 1 and d.uom != self.doc.stock_uom: + self.doclist.remove(d) + def check_stock_uom_with_bin(self): if not self.doc.fields.get("__islocal"): bin_uom = webnotes.conn.get_value("Bin", {"item_code": self.doc.name}, "stock_uom") if self.doc.stock_uom and bin_uom and cstr(bin_uom) != cstr(self.doc.stock_uom): + webnotes.errprint([self.doc.stock_uom, bin_uom]) webnotes.throw(_("Default Unit of Measure can not be changed directly \ - because you have already made some transaction(s) with another UOM. \ + because you have already made some transaction(s) with another UOM.\n \ To change default UOM, use 'UOM Replace Utility' tool under Stock module.")) - + def validate_conversion_factor(self): check_list = [] for d in getlist(self.doclist,'uom_conversion_details'): diff --git a/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py b/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py index 4e69a37803..eff62f6ddf 100644 --- a/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py +++ b/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py @@ -8,7 +8,7 @@ from webnotes.utils import cstr, flt, now, cint from webnotes.model import db_exists from webnotes.model.bean import copy_doclist from webnotes.model.code import get_obj -from webnotes import msgprint +from webnotes import msgprint, _ sql = webnotes.conn.sql @@ -41,11 +41,11 @@ class DocType: raise Exception def update_item_master(self): - # update stock uom in item master - sql("update `tabItem` set stock_uom = '%s' where name = '%s' " % (self.doc.new_stock_uom, self.doc.item_code)) + item_bean = webnotes.bean("Item", self.doc.item_code) + item_bean.doc.stock_uom = self.doc.new_stock_uom + item_bean.save() - # acknowledge user - msgprint("New Stock UOM : " + cstr(self.doc.new_stock_uom) + " updated in Item : " + cstr(self.doc.item_code)) + msgprint(_("Default UOM updated in item ") + self.doc.item_code) def update_bin(self): # update bin @@ -80,20 +80,14 @@ class DocType: # Update Stock UOM def update_stock_uom(self): - # validate mandatory self.validate_mandatory() self.validate_uom_integer_type() - # update item master self.update_item_master() - # update stock ledger entry self.update_stock_ledger_entry() - # update bin self.update_bin() - - get_obj("Item", self.doc.item_code).on_update() def validate_uom_integer_type(self): current_is_integer = webnotes.conn.get_value("UOM", self.doc.current_stock_uom, "must_be_whole_number") From 3d21463a8a929f3f6060f4ee14b199883f2c89d2 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 6 Sep 2013 15:53:04 +0530 Subject: [PATCH 4/9] [fix] [minor] shopping cart enabled --- website/helpers/product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/helpers/product.py b/website/helpers/product.py index 8d817d07cf..031339ab31 100644 --- a/website/helpers/product.py +++ b/website/helpers/product.py @@ -11,7 +11,7 @@ from website.helpers.cart import _get_cart_quotation @webnotes.whitelist(allow_guest=True) def get_product_info(item_code): """get product price / stock info""" - if not webnotes.conn.get_default("shopping_cart_enabled"): + if not cint(webnotes.conn.get_default("shopping_cart_enabled")): return {} cart_quotation = _get_cart_quotation() From a0871cfe6a3987e86ccb11cdb2e06603721eefce Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 6 Sep 2013 16:26:07 +0530 Subject: [PATCH 5/9] [fix] [minor] Fixes for uom validation of item --- stock/doctype/item/item.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index ac9f18fcd0..75e2b034a3 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -67,9 +67,27 @@ class DocType(DocListController): def check_stock_uom_with_bin(self): if not self.doc.fields.get("__islocal"): - bin_uom = webnotes.conn.get_value("Bin", {"item_code": self.doc.name}, "stock_uom") - if self.doc.stock_uom and bin_uom and cstr(bin_uom) != cstr(self.doc.stock_uom): - webnotes.errprint([self.doc.stock_uom, bin_uom]) + matched=True + ref_uom = webnotes.conn.get_value("Stock Ledger Entry", + {"item_code": self.doc.name, "is_cancelled": "No"}, "stock_uom") + + if ref_uom: + if cstr(ref_uom) != cstr(self.doc.stock_uom): + matched = False + else: + bin_list = webnotes.conn.sql("select * from tabBin where item_code=%s", + self.doc.item_code, as_dict=1) + for bin in bin_list: + if bin.reserved_qty > 0 or bin.ordered_qty > 0 or bin.indented_qty > 0 \ + or bin.planned_qty > 0 and cstr(bin.stock_uom) != cstr(self.doc.stock_uom): + matched = False + break + + if matched and bin_list: + webnotes.conn.sql("""update tabBin set stock_uom=%s where item_code=%s""", + (self.doc.stock_uom, self.doc.name)) + + if not matched: webnotes.throw(_("Default Unit of Measure can not be changed directly \ because you have already made some transaction(s) with another UOM.\n \ To change default UOM, use 'UOM Replace Utility' tool under Stock module.")) From 1b2d84db0dd84d04e545a1c43f842b31a8abdd30 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 10 Sep 2013 10:46:56 +0530 Subject: [PATCH 6/9] [fix] [minor] print hide communication table --- selling/doctype/quotation/quotation.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt index 9d47259d80..3f97c980bc 100644 --- a/selling/doctype/quotation/quotation.txt +++ b/selling/doctype/quotation/quotation.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:08", "docstatus": 0, - "modified": "2013-09-02 16:25:01", + "modified": "2013-09-10 10:46:33", "modified_by": "Administrator", "owner": "Administrator" }, @@ -841,7 +841,8 @@ "fieldtype": "Table", "hidden": 1, "label": "Communications", - "options": "Communication" + "options": "Communication", + "print_hide": 1 }, { "amend": 1, From 9686b937bb033e2b787ebf6550d3ecd196b52e77 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 10 Sep 2013 10:54:34 +0530 Subject: [PATCH 7/9] [fix] [minor] print hide communication table --- buying/doctype/supplier/supplier.txt | 11 +++++++---- hr/doctype/job_applicant/job_applicant.txt | 5 +++-- selling/doctype/customer/customer.txt | 11 +++++++---- selling/doctype/lead/lead.txt | 11 +++++++---- selling/doctype/opportunity/opportunity.txt | 7 +++++-- setup/doctype/sales_person/sales_person.txt | 5 +++-- support/doctype/support_ticket/support_ticket.txt | 5 +++-- utilities/doctype/contact/contact.txt | 11 +++++++---- 8 files changed, 42 insertions(+), 24 deletions(-) diff --git a/buying/doctype/supplier/supplier.txt b/buying/doctype/supplier/supplier.txt index 50202dcae2..56336d4846 100644 --- a/buying/doctype/supplier/supplier.txt +++ b/buying/doctype/supplier/supplier.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-10 16:34:11", "docstatus": 0, - "modified": "2013-09-02 16:25:44", + "modified": "2013-09-10 10:53:50", "modified_by": "Administrator", "owner": "Administrator" }, @@ -137,13 +137,15 @@ "fieldname": "communication_history", "fieldtype": "Section Break", "label": "Communication History", - "options": "icon-comments" + "options": "icon-comments", + "print_hide": 1 }, { "doctype": "DocField", "fieldname": "communication_html", "fieldtype": "HTML", - "label": "Communication HTML" + "label": "Communication HTML", + "print_hide": 1 }, { "doctype": "DocField", @@ -210,7 +212,8 @@ "fieldtype": "Table", "hidden": 1, "label": "Communications", - "options": "Communication" + "options": "Communication", + "print_hide": 1 }, { "cancel": 0, diff --git a/hr/doctype/job_applicant/job_applicant.txt b/hr/doctype/job_applicant/job_applicant.txt index 62b1d807bc..d795fa83bc 100644 --- a/hr/doctype/job_applicant/job_applicant.txt +++ b/hr/doctype/job_applicant/job_applicant.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-29 19:25:37", "docstatus": 0, - "modified": "2013-09-02 16:26:23", + "modified": "2013-09-10 10:51:51", "modified_by": "Administrator", "owner": "Administrator" }, @@ -95,7 +95,8 @@ "fieldtype": "Table", "hidden": 1, "label": "Communications", - "options": "Communication" + "options": "Communication", + "print_hide": 1 }, { "doctype": "DocPerm" diff --git a/selling/doctype/customer/customer.txt b/selling/doctype/customer/customer.txt index 94bd8fceb4..b25c0bd32b 100644 --- a/selling/doctype/customer/customer.txt +++ b/selling/doctype/customer/customer.txt @@ -2,7 +2,7 @@ { "creation": "2013-06-11 14:26:44", "docstatus": 0, - "modified": "2013-09-02 16:25:13", + "modified": "2013-09-10 10:50:50", "modified_by": "Administrator", "owner": "Administrator" }, @@ -195,14 +195,16 @@ "fieldtype": "Section Break", "label": "Communication History", "options": "icon-comments", - "permlevel": 0 + "permlevel": 0, + "print_hide": 1 }, { "doctype": "DocField", "fieldname": "communication_html", "fieldtype": "HTML", "label": "Communication HTML", - "permlevel": 0 + "permlevel": 0, + "print_hide": 1 }, { "doctype": "DocField", @@ -355,7 +357,8 @@ "hidden": 1, "label": "Communications", "options": "Communication", - "permlevel": 0 + "permlevel": 0, + "print_hide": 1 }, { "amend": 0, diff --git a/selling/doctype/lead/lead.txt b/selling/doctype/lead/lead.txt index 9402259ac7..a429c967e4 100644 --- a/selling/doctype/lead/lead.txt +++ b/selling/doctype/lead/lead.txt @@ -2,7 +2,7 @@ { "creation": "2013-04-10 11:45:37", "docstatus": 0, - "modified": "2013-09-02 17:25:59", + "modified": "2013-09-10 10:52:20", "modified_by": "Administrator", "owner": "Administrator" }, @@ -159,7 +159,8 @@ "fieldname": "communication_history", "fieldtype": "Section Break", "label": "Communication History", - "options": "icon-comments" + "options": "icon-comments", + "print_hide": 1 }, { "allow_on_submit": 0, @@ -168,7 +169,8 @@ "fieldtype": "HTML", "label": "Communication HTML", "oldfieldname": "follow_up", - "oldfieldtype": "Table" + "oldfieldtype": "Table", + "print_hide": 1 }, { "doctype": "DocField", @@ -416,7 +418,8 @@ "fieldtype": "Table", "hidden": 1, "label": "Communications", - "options": "Communication" + "options": "Communication", + "print_hide": 1 }, { "cancel": 1, diff --git a/selling/doctype/opportunity/opportunity.txt b/selling/doctype/opportunity/opportunity.txt index 4ca1564c7d..a904f56643 100644 --- a/selling/doctype/opportunity/opportunity.txt +++ b/selling/doctype/opportunity/opportunity.txt @@ -2,7 +2,7 @@ { "creation": "2013-03-07 18:50:30", "docstatus": 0, - "modified": "2013-09-02 16:27:33", + "modified": "2013-09-10 10:52:49", "modified_by": "Administrator", "owner": "Administrator" }, @@ -168,6 +168,7 @@ "label": "Communication History", "oldfieldtype": "Section Break", "options": "icon-comments", + "print_hide": 1, "read_only": 0 }, { @@ -178,6 +179,7 @@ "label": "Communication HTML", "oldfieldname": "follow_up", "oldfieldtype": "Table", + "print_hide": 1, "read_only": 0 }, { @@ -448,7 +450,8 @@ "fieldtype": "Table", "hidden": 1, "label": "Communications", - "options": "Communication" + "options": "Communication", + "print_hide": 1 }, { "doctype": "DocPerm", diff --git a/setup/doctype/sales_person/sales_person.txt b/setup/doctype/sales_person/sales_person.txt index d78b5c8d27..037c6de353 100644 --- a/setup/doctype/sales_person/sales_person.txt +++ b/setup/doctype/sales_person/sales_person.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-10 16:34:24", "docstatus": 0, - "modified": "2013-09-02 16:26:54", + "modified": "2013-09-10 10:53:28", "modified_by": "Administrator", "owner": "Administrator" }, @@ -166,7 +166,8 @@ "fieldtype": "Table", "hidden": 1, "label": "Communications", - "options": "Communication" + "options": "Communication", + "print_hide": 1 }, { "cancel": 0, diff --git a/support/doctype/support_ticket/support_ticket.txt b/support/doctype/support_ticket/support_ticket.txt index 01d0e35388..9f385b2d25 100644 --- a/support/doctype/support_ticket/support_ticket.txt +++ b/support/doctype/support_ticket/support_ticket.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-01 10:36:25", "docstatus": 0, - "modified": "2013-09-02 16:24:24", + "modified": "2013-09-10 10:54:02", "modified_by": "Administrator", "owner": "Administrator" }, @@ -267,7 +267,8 @@ "fieldtype": "Table", "hidden": 1, "label": "Communications", - "options": "Communication" + "options": "Communication", + "print_hide": 1 }, { "cancel": 0, diff --git a/utilities/doctype/contact/contact.txt b/utilities/doctype/contact/contact.txt index d3c7d889fd..92dcf2ef02 100644 --- a/utilities/doctype/contact/contact.txt +++ b/utilities/doctype/contact/contact.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-10 16:34:32", "docstatus": 0, - "modified": "2013-09-02 16:26:13", + "modified": "2013-09-10 10:50:27", "modified_by": "Administrator", "owner": "Administrator" }, @@ -101,13 +101,15 @@ "fieldname": "sb00", "fieldtype": "Section Break", "label": "Communication History", - "options": "icon-comments" + "options": "icon-comments", + "print_hide": 1 }, { "doctype": "DocField", "fieldname": "communication_html", "fieldtype": "HTML", - "label": "Communication HTML" + "label": "Communication HTML", + "print_hide": 1 }, { "doctype": "DocField", @@ -231,7 +233,8 @@ "fieldtype": "Table", "hidden": 1, "label": "Communications", - "options": "Communication" + "options": "Communication", + "print_hide": 1 }, { "cancel": 1, From ee93ee3cb5a1692346aa73a804d73f5748316ccb Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 10 Sep 2013 14:59:58 +0530 Subject: [PATCH 8/9] [minor] allow import for journal voucher --- accounts/doctype/journal_voucher/journal_voucher.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accounts/doctype/journal_voucher/journal_voucher.txt b/accounts/doctype/journal_voucher/journal_voucher.txt index 4fba94afac..fdc27ead9b 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.txt +++ b/accounts/doctype/journal_voucher/journal_voucher.txt @@ -2,11 +2,12 @@ { "creation": "2013-03-25 10:53:52", "docstatus": 0, - "modified": "2013-08-08 14:21:56", + "modified": "2013-09-10 14:59:41", "modified_by": "Administrator", "owner": "Administrator" }, { + "allow_import": 1, "autoname": "naming_series:", "doctype": "DocType", "icon": "icon-file-text", From 563662916aef86a7b34830eec8d7fa3a982b8063 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 10 Sep 2013 17:15:01 +0530 Subject: [PATCH 9/9] [fix] [minor] pos setting link validation --- accounts/doctype/pos_setting/pos_setting.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/accounts/doctype/pos_setting/pos_setting.py b/accounts/doctype/pos_setting/pos_setting.py index f805518124..183ebbe1d7 100755 --- a/accounts/doctype/pos_setting/pos_setting.py +++ b/accounts/doctype/pos_setting/pos_setting.py @@ -40,13 +40,15 @@ class DocType: msgprint(_("Expense Account is mandatory"), raise_exception=1) def validate_all_link_fields(self): - accounts = {"Account": [self.doc.cash_bank_account, self.doc.income_account, self.doc.expense_account], \ - "Cost Center": [self.doc.cost_center], "Warehouse": [self.doc.warehouse]} + accounts = {"Account": [self.doc.cash_bank_account, self.doc.income_account, + self.doc.expense_account], "Cost Center": [self.doc.cost_center], + "Warehouse": [self.doc.warehouse]} for link_dt, dn_list in accounts.items(): for link_dn in dn_list: - if not webnotes.conn.exists({"doctype": link_dt, "company": self.doc.company, "name": link_dn}): - msgprint(link_dn +_(" does not belong to ") + self.doc.company) + if link_dn and not webnotes.conn.exists({"doctype": link_dt, + "company": self.doc.company, "name": link_dn}): + webnotes.throw(link_dn +_(" does not belong to ") + self.doc.company) def on_update(self): webnotes.defaults.clear_default("is_pos")