From f870527e7cc3cc08b0db5dc55b9642967267aa9b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 16 Dec 2014 17:19:36 +0530 Subject: [PATCH 1/8] [design] wip --- .../doctype/cost_center/cost_center.js | 2 +- .../journal_voucher/journal_voucher.js | 2 +- .../purchase_invoice/purchase_invoice.js | 2 +- .../doctype/sales_invoice/sales_invoice.js | 8 +-- .../hr/doctype/expense_claim/expense_claim.js | 5 +- .../leave_application/leave_application.js | 3 - .../public/js/controllers/stock_controller.js | 4 +- erpnext/selling/doctype/lead/lead.js | 2 +- .../selling/doctype/quotation/quotation.js | 2 +- .../setup/doctype/item_group/item_group.js | 2 +- .../doctype/delivery_note/delivery_note.js | 2 +- erpnext/templates/form_grid/item_grid.html | 61 ++++++++++--------- 12 files changed, 45 insertions(+), 50 deletions(-) diff --git a/erpnext/accounts/doctype/cost_center/cost_center.js b/erpnext/accounts/doctype/cost_center/cost_center.js index d9e71d98ed..1ed0ab6136 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.js +++ b/erpnext/accounts/doctype/cost_center/cost_center.js @@ -51,7 +51,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.toggle_display('sb1', doc.group_or_ledger=='Ledger') cur_frm.set_intro(intro_txt); - cur_frm.appframe.add_button(__('Chart of Cost Centers'), + cur_frm.add_custom_button(__('Chart of Cost Centers'), function() { frappe.set_route("Accounts Browser", "Cost Center"); }, 'icon-sitemap') } diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js index b1d4af0d10..21fbf1a0b8 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js @@ -139,7 +139,7 @@ cur_frm.cscript.refresh = function(doc) { erpnext.toggle_naming_series(); cur_frm.cscript.voucher_type(doc); if(doc.docstatus==1) { - cur_frm.appframe.add_button(__('View Ledger'), function() { + cur_frm.add_custom_button(__('View Ledger'), function() { frappe.route_options = { "voucher_no": doc.name, "from_date": doc.posting_date, diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 1f4218e427..69e5873de6 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -31,7 +31,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ frappe.boot.doctype_icons["Journal Voucher"]); if(doc.docstatus==1) { - cur_frm.appframe.add_button(__('View Ledger'), function() { + cur_frm.add_custom_button(__('View Ledger'), function() { frappe.route_options = { "voucher_no": doc.name, "from_date": doc.posting_date, diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 03d9d03724..f376126eef 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -49,7 +49,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte cur_frm.dashboard.reset(); if(doc.docstatus==1) { - cur_frm.appframe.add_button('View Ledger', function() { + cur_frm.add_custom_button('View Ledger', function() { frappe.route_options = { "voucher_no": doc.name, "from_date": doc.posting_date, @@ -60,10 +60,10 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte frappe.set_route("query-report", "General Ledger"); }, "icon-table"); - var percent_paid = cint(flt(doc.grand_total - doc.outstanding_amount) / flt(doc.grand_total) * 100); - cur_frm.dashboard.add_progress(percent_paid + "% Paid", percent_paid); + // var percent_paid = cint(flt(doc.grand_total - doc.outstanding_amount) / flt(doc.grand_total) * 100); + // cur_frm.dashboard.add_progress(percent_paid + "% Paid", percent_paid); - cur_frm.appframe.add_button(__('Send SMS'), cur_frm.cscript.send_sms, 'icon-mobile-phone'); + cur_frm.add_custom_button(__('Send SMS'), cur_frm.cscript.send_sms, 'icon-mobile-phone'); if(cint(doc.update_stock)!=1) { // show Make Delivery Note button only if Sales Invoice is not created from Delivery Note diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js index ba45928ede..05e486688c 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.js +++ b/erpnext/hr/doctype/expense_claim/expense_claim.js @@ -85,9 +85,6 @@ cur_frm.cscript.refresh = function(doc,cdt,cdn){ cur_frm.toggle_enable("exp_approver", doc.approval_status=="Draft"); cur_frm.toggle_enable("approval_status", (doc.exp_approver==user && doc.docstatus==0)); - if(!doc.__islocal && user!=doc.exp_approver) - cur_frm.frm_head.appframe.set_title_right(""); - if(doc.docstatus==0 && doc.exp_approver==user && doc.approval_status=="Approved") cur_frm.savesubmit(); @@ -159,4 +156,4 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { if(cint(frappe.boot.notification_settings && frappe.boot.notification_settings.expense_claim)) { cur_frm.email_doc(frappe.boot.notification_settings.expense_claim_message); } -} \ No newline at end of file +} diff --git a/erpnext/hr/doctype/leave_application/leave_application.js b/erpnext/hr/doctype/leave_application/leave_application.js index ecaac4ac37..1b6186fa89 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.js +++ b/erpnext/hr/doctype/leave_application/leave_application.js @@ -35,9 +35,6 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { } else { cur_frm.set_intro(__("This Leave Application is pending approval. Only the Leave Apporver can update status.")) cur_frm.toggle_enable("status", false); - if(!doc.__islocal) { - cur_frm.frm_head.appframe.set_title_right(""); - } } } else { if(doc.status=="Approved") { diff --git a/erpnext/public/js/controllers/stock_controller.js b/erpnext/public/js/controllers/stock_controller.js index 1b472f1d34..98caf435bb 100644 --- a/erpnext/public/js/controllers/stock_controller.js +++ b/erpnext/public/js/controllers/stock_controller.js @@ -43,7 +43,7 @@ erpnext.stock.StockController = frappe.ui.form.Controller.extend({ show_stock_ledger: function() { var me = this; if(this.frm.doc.docstatus===1) { - this.frm.appframe.add_button(__("Stock Ledger"), function() { + cur_frm.add_custom_button(__("Stock Ledger"), function() { frappe.route_options = { voucher_no: me.frm.doc.name, from_date: me.frm.doc.posting_date, @@ -59,7 +59,7 @@ erpnext.stock.StockController = frappe.ui.form.Controller.extend({ show_general_ledger: function() { var me = this; if(this.frm.doc.docstatus===1 && cint(frappe.defaults.get_default("auto_accounting_for_stock"))) { - cur_frm.appframe.add_button(__('Accounting Ledger'), function() { + cur_frm.add_custom_button(__('Accounting Ledger'), function() { frappe.route_options = { voucher_no: me.frm.doc.name, from_date: me.frm.doc.posting_date, diff --git a/erpnext/selling/doctype/lead/lead.js b/erpnext/selling/doctype/lead/lead.js index 0dae099e83..170e718654 100644 --- a/erpnext/selling/doctype/lead/lead.js +++ b/erpnext/selling/doctype/lead/lead.js @@ -31,7 +31,7 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({ frappe.boot.doctype_icons["Customer"], "btn-default"); this.frm.add_custom_button(__("Create Opportunity"), this.create_opportunity, frappe.boot.doctype_icons["Opportunity"], "btn-default"); - this.frm.appframe.add_button(__("Send SMS"), this.frm.cscript.send_sms, "icon-mobile-phone"); + cur_frm.add_custom_button(__("Send SMS"), this.frm.cscript.send_sms, "icon-mobile-phone"); } if(!this.frm.doc.__islocal) { diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 857a259129..0026582967 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -32,7 +32,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ cur_frm.add_custom_button(__('Set as Lost'), cur_frm.cscript['Declare Order Lost'], "icon-exclamation", "btn-default"); } - cur_frm.appframe.add_button(__('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone"); + cur_frm.add_custom_button(__('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone"); } if (this.frm.doc.docstatus===0) { diff --git a/erpnext/setup/doctype/item_group/item_group.js b/erpnext/setup/doctype/item_group/item_group.js index f7ffe5ee49..3bb6c1767f 100644 --- a/erpnext/setup/doctype/item_group/item_group.js +++ b/erpnext/setup/doctype/item_group/item_group.js @@ -5,7 +5,7 @@ cur_frm.list_route = "Sales Browser/Item Group"; cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.set_root_readonly(doc); - cur_frm.appframe.add_button(__("Item Group Tree"), function() { + cur_frm.add_custom_button(__("Item Group Tree"), function() { frappe.set_route("Sales Browser", "Item Group"); }, "icon-sitemap") } diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 009ac4c764..6abc268f4a 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -32,7 +32,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( cur_frm.add_custom_button(__('Make Installation Note'), this.make_installation_note); if (doc.docstatus==1) { - cur_frm.appframe.add_button(__('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone"); + cur_frm.add_custom_button(__('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone"); this.show_stock_ledger(); this.show_general_ledger(); } diff --git a/erpnext/templates/form_grid/item_grid.html b/erpnext/templates/form_grid/item_grid.html index 21903c03d0..2803550484 100644 --- a/erpnext/templates/form_grid/item_grid.html +++ b/erpnext/templates/form_grid/item_grid.html @@ -2,7 +2,7 @@ {% if(!doc) { %}
-
{%= __("Item") %}
+
{%= __("Items") %}
{%= __("Qty") %}
{%= __("Rate") %}
{%= __("Amount") %}
@@ -14,13 +14,36 @@
{%= doc.item_name %}{% } %} {% if(doc.item_name != doc.description) { %}

{%= doc.description %}

{% } %} - {% if(doc.sales_order || doc.against_sales_order) { %} -

- - {%= doc.sales_order || doc.against_sales_order %} -

- {% } %} +
+ {% if(doc.sales_order || doc.against_sales_order) { %} + + + {%= doc.sales_order || doc.against_sales_order %} + + {% } %} + {% if(doc.warehouse) { + var label_class = "label-default", + title = "Warehouse", + actual_qty = (doc.doctype==="Sales Order" + ? doc.projected_qty : doc.actual_qty); + if(actual_qty != undefined) { + if(actual_qty > doc.qty) { + var label_class = "label-success"; + var title = "In Stock" + } else { + var title = "Not In Stock" + } + } + %} + + + {%= doc.warehouse %} + + + {% } %} +
{% include "templates/form_grid/includes/visible_cols.html" %} {% if(doc.schedule_date) { %}
doc.qty) { - var label_class = "label-success"; - var title = "In Stock" - } else { - var title = "Not In Stock" - } - } - %} -
- - {%= doc.warehouse %} - -
- {% } %}
From a9ba5eff992da3e4c9d9164dac3a26e06b09c89f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 19 Dec 2014 16:20:32 +0530 Subject: [PATCH 2/8] [design] pos --- .../purchase_invoice/purchase_invoice.js | 1 - .../doctype/sales_invoice/sales_invoice.js | 1 - .../page/accounts_browser/accounts_browser.js | 2 +- .../financial_analytics.js | 2 +- .../doctype/purchase_order/purchase_order.js | 1 - .../supplier_quotation/supplier_quotation.js | 1 - .../purchase_analytics/purchase_analytics.js | 2 +- erpnext/controllers/status_updater.py | 6 +- erpnext/public/build.json | 5 +- erpnext/public/css/erpnext.css | 67 ++++++- erpnext/public/js/conf.js | 9 +- erpnext/public/js/pos/pos.html | 55 +++++ .../sales_invoice => public/js/pos}/pos.js | 189 ++++-------------- erpnext/public/js/pos/pos_bill_item.html | 16 ++ erpnext/public/js/transaction.js | 10 +- .../selling/doctype/quotation/quotation.js | 1 - .../doctype/sales_order/sales_order.js | 1 - .../page/sales_analytics/sales_analytics.js | 2 +- .../page/sales_browser/sales_browser.js | 2 +- .../selling/page/sales_funnel/sales_funnel.js | 80 ++++---- .../doctype/delivery_note/delivery_note.js | 1 - .../purchase_receipt/purchase_receipt.js | 1 - .../page/stock_analytics/stock_analytics.js | 2 +- .../stock/page/stock_ledger/stock_ledger.js | 2 +- erpnext/stock/page/stock_level/stock_level.js | 2 +- .../support_analytics/support_analytics.js | 2 +- 26 files changed, 228 insertions(+), 235 deletions(-) create mode 100644 erpnext/public/js/pos/pos.html rename erpnext/{accounts/doctype/sales_invoice => public/js/pos}/pos.js (70%) create mode 100644 erpnext/public/js/pos/pos_bill_item.html diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 69e5873de6..658cc52634 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -8,7 +8,6 @@ cur_frm.cscript.other_fname = "other_charges"; frappe.provide("erpnext.accounts"); {% include 'buying/doctype/purchase_common/purchase_common.js' %}; {% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ onload: function() { diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index f376126eef..2061fb198c 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -11,7 +11,6 @@ cur_frm.pformat.print_heading = 'Invoice'; {% include 'selling/sales_common.js' %}; {% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} frappe.provide("erpnext.accounts"); erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({ diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js index c927596d51..dc0dd7a95e 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.js +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js @@ -13,7 +13,7 @@ pscript['onload_Accounts Browser'] = function(wrapper){ single_column: true }) - wrapper.appframe.add_module_icon("Accounts"); + frappe.add_breadcrumbs("Accounts"); var main = $(wrapper).find(".layout-main"), chart_area = $("
") diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.js b/erpnext/accounts/page/financial_analytics/financial_analytics.js index 2da93813e9..f0fdffecd2 100644 --- a/erpnext/accounts/page/financial_analytics/financial_analytics.js +++ b/erpnext/accounts/page/financial_analytics/financial_analytics.js @@ -10,7 +10,7 @@ frappe.pages['financial-analytics'].onload = function(wrapper) { single_column: true }); erpnext.trial_balance = new erpnext.FinancialAnalytics(wrapper, 'Financial Analytics'); - wrapper.appframe.add_module_icon("Accounts") + frappe.add_breadcrumbs("Accounts") } diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index e712995c55..ed7e2c2ac4 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -9,7 +9,6 @@ cur_frm.cscript.other_fname = "other_charges"; {% include 'buying/doctype/purchase_common/purchase_common.js' %}; {% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({ refresh: function(doc, cdt, cdn) { diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index b9286a1c24..dda0632aa8 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -9,7 +9,6 @@ cur_frm.cscript.other_fname = "other_charges"; // attach required files {% include 'buying/doctype/purchase_common/purchase_common.js' %}; {% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({ refresh: function() { diff --git a/erpnext/buying/page/purchase_analytics/purchase_analytics.js b/erpnext/buying/page/purchase_analytics/purchase_analytics.js index f1c050d1ff..e1d6294d6f 100644 --- a/erpnext/buying/page/purchase_analytics/purchase_analytics.js +++ b/erpnext/buying/page/purchase_analytics/purchase_analytics.js @@ -11,7 +11,7 @@ frappe.pages['purchase-analytics'].onload = function(wrapper) { new erpnext.PurchaseAnalytics(wrapper); - wrapper.appframe.add_module_icon("Buying") + frappe.add_breadcrumbs("Buying") } diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 247d4ffbda..0ec8bf0941 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -73,9 +73,7 @@ class StatusUpdater(Document): frappe.db.set_value(self.doctype, self.name, "status", self.status) def validate_qty(self): - """ - Validates qty at row level - """ + """Validates qty at row level""" self.tolerance = {} self.global_tolerance = None @@ -153,7 +151,7 @@ class StatusUpdater(Document): args['second_source_condition'] = "" if args.get('second_source_dt') and args.get('second_source_field') \ and args.get('second_join_field'): - if not args.get("second_source_extra_cond"): + if not args.get("second_source_extra_cond"): args["second_source_extra_cond"] = "" args['second_source_condition'] = """ + ifnull((select sum(%(second_source_field)s) diff --git a/erpnext/public/build.json b/erpnext/public/build.json index 49b09071fb..588f4ec86b 100644 --- a/erpnext/public/build.json +++ b/erpnext/public/build.json @@ -13,7 +13,10 @@ "public/js/queries.js", "public/js/utils/party.js", "public/js/templates/address_list.html", - "public/js/templates/contact_list.html" + "public/js/templates/contact_list.html", + "public/js/pos/pos.html", + "public/js/pos/pos_bill_item.html", + "public/js/pos/pos.js" ], "css/shopping-cart-web.css": [ "public/css/shopping_cart.css" diff --git a/erpnext/public/css/erpnext.css b/erpnext/public/css/erpnext.css index 6d3f4750fe..7a93757944 100644 --- a/erpnext/public/css/erpnext.css +++ b/erpnext/public/css/erpnext.css @@ -20,6 +20,9 @@ } /* pos */ +.pos { +} + .pos-item { height: 200px; overflow: hidden; @@ -28,10 +31,62 @@ padding-right: 5px !important; } -.pos-bill { - margin-left: -30px; - margin-top: -10px; - padding: 20px 10px; - border-right: 1px solid #c7c7c7; - border-bottom: 1px solid #c7c7c7; +.pos-item-area { + border: 1px solid #d1d8dd; + border-top: none; +} + +.pos-item-toolbar { + padding: 10px 0px; + border-bottom: 1px solid #d1d8dd; +} + +.item-list-area { + padding: 15px; +} + +.pos-toolbar, .pos-bill-toolbar { + padding: 10px 0px; + border-bottom: 1px solid #d1d8dd; + height: 55px; +} + +.pos-item-toolbar .form-group { + margin-bottom: 0px; +} + +.pos-bill-wrapper { + border: 1px solid #d1d8dd; + border-top: none; + border-right: none; +} + +.pos-bill { + margin-left: -15px; + margin-right: -15px; +} + +.pos-bill-row { + margin: 0px; + padding: 7px 0px; + border-top: 1px solid #d1d8dd; +} + +.pos-bill-header { + border: none !important; + background-color: #f5f7fa; +} + +.pos-item-qty { + display: inline-block; +} + +.pos-qty-row > div { + padding: 5px 0px; +} + +.pos-qty-btn { + margin-top: 5px; + cursor: pointer; + font-size: 120%; } diff --git a/erpnext/public/js/conf.js b/erpnext/public/js/conf.js index e9c790db10..deb6a2c609 100644 --- a/erpnext/public/js/conf.js +++ b/erpnext/public/js/conf.js @@ -7,14 +7,7 @@ frappe.provide('erpnext'); $(document).bind('toolbar_setup', function() { frappe.app.name = "ERPNext"; - $('.navbar-brand').html('') - .attr("title", "Home") - .addClass("navbar-icon-home") - .css({ - "max-width": "200px", - "text-overflow": "ellipsis", - "white-space": "nowrap" - }); + $('.navbar-brand').html('ERPNext'); $('[data-link="docs"]').attr("href", "https://erpnext.com/user-guide") }); diff --git a/erpnext/public/js/pos/pos.html b/erpnext/public/js/pos/pos.html new file mode 100644 index 0000000000..dd323bcc41 --- /dev/null +++ b/erpnext/public/js/pos/pos.html @@ -0,0 +1,55 @@ +
+
+
+
+
+
+ +
+
+
+
+
+
{%= __("Item") %}
+
{%= __("Quantity") %}
+
{%= __("Rate") %}
+
+
+
+
+
+
{%= __("Net Total") %}
+
+
+
+
{%= __("Taxes") %}
+
+
+
{%= __("Discount Amount") %}
+
+
+
+
{%= __("Grand Total") %}
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.js b/erpnext/public/js/pos/pos.js similarity index 70% rename from erpnext/accounts/doctype/sales_invoice/pos.js rename to erpnext/public/js/pos/pos.js index 8c6e3cdb82..cfae51571d 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.js +++ b/erpnext/public/js/pos/pos.js @@ -5,105 +5,7 @@ erpnext.POS = Class.extend({ init: function(wrapper, frm) { this.wrapper = wrapper; this.frm = frm; - this.wrapper.html('
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
'+__("Item")+'QtyRate
\ -
\ -
\ -
\ -
\ - \ - \ - \ - \ - \ -
'+__("Net Total")+'
\ -
\ - \ -
\ - \ - \ - \ - \ - \ - \ -
'+__("Discount Amount")+'\ - \ -
\ -
\ -
\ - \ - \ - \ - \ - \ -
'+__("Grand Total")+'
\ -
\ - \ -
\ -
\ -

\ -
\ -
\ - \ -
\ -
\ - \ -
\ -
\ -

\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
'); + this.wrapper.html(frappe.render_template("pos", {})); this.check_transaction_type(); this.make(); @@ -271,14 +173,8 @@ erpnext.POS = Class.extend({ // if form is local then allow this function $(me.wrapper).find("div.pos-item").on("click", function() { if(me.frm.doc.docstatus==0) { - if(!me.frm.doc[me.party.toLowerCase()] && ((me.frm.doctype == "Quotation" && - me.frm.doc.quotation_to == "Customer") - || me.frm.doctype != "Quotation")) { - msgprint(__("Please select {0} first.", [me.party])); - return; - } - else - me.add_to_cart($(this).attr("data-item_code")); + console.log($(this).attr("data-item_code")); + me.add_to_cart($(this).attr("data-item_code")); } }); } @@ -288,8 +184,15 @@ erpnext.POS = Class.extend({ var me = this; var caught = false; + if(!me.frm.doc[me.party.toLowerCase()] && ((me.frm.doctype == "Quotation" && + me.frm.doc.quotation_to == "Customer") + || me.frm.doctype != "Quotation")) { + msgprint(__("Please select {0} first.", [me.party])); + return; + } + // get no_of_items - var no_of_items = me.wrapper.find("#cart tbody tr").length; + var no_of_items = me.wrapper.find(".pos-bill-item").length; // check whether the item is already added if (no_of_items != 0) { @@ -333,6 +236,7 @@ erpnext.POS = Class.extend({ } }, update_qty: function(item_code, qty) { + console.log([item_code, qty]); var me = this; $.each(this.frm.doc[this.frm.cscript.fname] || [], function(i, d) { if (d.item_code == item_code) { @@ -368,7 +272,7 @@ erpnext.POS = Class.extend({ // If quotation to is not Customer then remove party if (this.frm.doctype == "Quotation" && this.frm.doc.quotation_to!="Customer") { - this.party_field.$wrapper.remove(); + this.party_field.$input.prop("disabled", true); } }, refresh_item_list: function() { @@ -381,45 +285,20 @@ erpnext.POS = Class.extend({ }, show_items_in_item_cart: function() { var me = this; - var $items = this.wrapper.find("#cart tbody").empty(); + var $items = this.wrapper.find(".items").empty(); $.each(this.frm.doc[this.frm.cscript.fname] || [], function(i, d) { - - $(repl('\ - %(item_code)s%(item_name)s\ - \ -
\ - \ -
\ - \ - \ - \ -
' - +__("Stock: ")+'%(actual_qty)s%(projected_qty)s
\ - \ - \ -
\ - \ -
\ - \ - %(amount)s
%(rate)s\ - ', - { - item_code: d.item_code, - item_name: d.item_name===d.item_code ? "" : ("
" + d.item_name), - qty: d.qty, - actual_qty: d.actual_qty, - projected_qty: d.projected_qty ? (" (" + d.projected_qty + ")") : "", - rate: format_currency(d.rate, me.frm.doc.currency), - amount: format_currency(d.amount, me.frm.doc.currency) - } - )).appendTo($items); + $(frappe.render_template("pos_bill_item", { + item_code: d.item_code, + item_name: d.item_name===d.item_code ? "" : ("
" + d.item_name), + qty: d.qty, + actual_qty: d.actual_qty, + rate: format_currency(d.rate, me.frm.doc.currency), + amount: format_currency(d.amount, me.frm.doc.currency) + })).appendTo($items); }); - this.wrapper.find("input.qty").on("focus", function() { + this.wrapper.find("input.pos-item-qty").on("focus", function() { $(this).select(); }); }, @@ -461,15 +340,15 @@ erpnext.POS = Class.extend({ var me = this; // append quantity to the respective item after change from input box - $(this.wrapper).find("input.qty").on("change", function() { + $(this.wrapper).find("input.pos-item-qty").on("change", function() { var item_code = $(this).closest("tr").attr("id"); me.update_qty(item_code, $(this).val()); }); // increase/decrease qty on plus/minus button - $(this.wrapper).find(".increase-qty, .decrease-qty").on("click", function() { - var tr = $(this).closest("tr"); - me.increase_decrease_qty(tr, $(this).attr("class")); + $(this.wrapper).find(".pos-qty-btn").on("click", function() { + var $item = $(this).parents(".pos-bill-item:first"); + me.increase_decrease_qty($item, $(this).attr("data-action")); }); // on td click toggle the highlighting of row @@ -487,15 +366,19 @@ erpnext.POS = Class.extend({ }); me.refresh_delete_btn(); + //me.focus(); + }, + focus: function() { if(me.frm.doc[this.party]) { this.barcode.$input.focus(); } else { - this.party_field.$input.focus(); + if(!(this.frm.doctype == "Quotation" && this.frm.doc.quotation_to!="Customer")) + this.party_field.$input.focus(); } }, - increase_decrease_qty: function(tr, operation) { - var item_code = tr.attr("id"); - var item_qty = cint(tr.find("input.qty").val()); + increase_decrease_qty: function($item, operation) { + var item_code = $item.attr("data-item-code"); + var item_qty = cint($item.find("input.pos-item-qty").val()); if (operation == "increase-qty") this.update_qty(item_code, item_qty + 1); @@ -506,7 +389,7 @@ erpnext.POS = Class.extend({ var me = this; // if form is submitted & cancelled then disable all input box & buttons $(this.wrapper) - .find(".remove-items, .make-payment, .increase-qty, .decrease-qty") + .find(".remove-items, .make-payment, .pos-qty-btn") .toggle(this.frm.doc.docstatus===0); $(this.wrapper).find('input, button').prop("disabled", !(this.frm.doc.docstatus===0)); diff --git a/erpnext/public/js/pos/pos_bill_item.html b/erpnext/public/js/pos/pos_bill_item.html new file mode 100644 index 0000000000..e45536f9c4 --- /dev/null +++ b/erpnext/public/js/pos/pos_bill_item.html @@ -0,0 +1,16 @@ +
+
{%= item_code %}{%= item_name %}
+
+
+
+
+ +
{%= actual_qty %}
+
+
+
+
+
+
{%= amount %}
{%= rate %}
+
+
diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index a261649813..5bbfae4641 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -105,12 +105,12 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ // make pos if(!this.frm.pos) { - this.frm.layout.add_view("pos"); - this.frm.pos = new erpnext.POS(this.frm.layout.views.pos, this.frm); + var wrapper = this.frm.appframe.add_view("pos", "
"); + this.frm.pos = new erpnext.POS(wrapper, this.frm); } // toggle view - this.frm.layout.set_view(this.pos_active ? "" : "pos"); + this.frm.appframe.set_view(this.pos_active ? "main" : "pos"); this.pos_active = !this.pos_active; // refresh @@ -224,9 +224,9 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ me.frm.script_manager.trigger("currency"); me.apply_pricing_rule(); - } + } } - + if (this.frm.doc.posting_date) var date = this.frm.doc.posting_date; else var date = this.frm.doc.transaction_date; erpnext.get_fiscal_year(this.frm.doc.company, date, fn); diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 0026582967..cad9a8c146 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -10,7 +10,6 @@ cur_frm.cscript.sales_team_fname = "sales_team"; {% include 'selling/sales_common.js' %} {% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ onload: function(doc, dt, dn) { diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 65b91f4bd7..2c196862f1 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -10,7 +10,6 @@ cur_frm.cscript.sales_team_fname = "sales_team"; {% include 'selling/sales_common.js' %} {% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({ refresh: function(doc, dt, dn) { diff --git a/erpnext/selling/page/sales_analytics/sales_analytics.js b/erpnext/selling/page/sales_analytics/sales_analytics.js index 34808662ce..75863533ec 100644 --- a/erpnext/selling/page/sales_analytics/sales_analytics.js +++ b/erpnext/selling/page/sales_analytics/sales_analytics.js @@ -10,7 +10,7 @@ frappe.pages['sales-analytics'].onload = function(wrapper) { new erpnext.SalesAnalytics(wrapper); - wrapper.appframe.add_module_icon("Selling") + frappe.add_breadcrumbs("Selling") } diff --git a/erpnext/selling/page/sales_browser/sales_browser.js b/erpnext/selling/page/sales_browser/sales_browser.js index d254028865..fcbd71ca9d 100644 --- a/erpnext/selling/page/sales_browser/sales_browser.js +++ b/erpnext/selling/page/sales_browser/sales_browser.js @@ -6,7 +6,7 @@ pscript['onload_Sales Browser'] = function(wrapper){ parent: wrapper, }) - wrapper.appframe.add_module_icon("Selling") + frappe.add_breadcrumbs("Selling") wrapper.appframe.set_title_right(__('Refresh'), function() { wrapper.make_tree(); diff --git a/erpnext/selling/page/sales_funnel/sales_funnel.js b/erpnext/selling/page/sales_funnel/sales_funnel.js index 76707629cf..99d3d070b1 100644 --- a/erpnext/selling/page/sales_funnel/sales_funnel.js +++ b/erpnext/selling/page/sales_funnel/sales_funnel.js @@ -1,73 +1,71 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.pages['sales-funnel'].onload = function(wrapper) { +frappe.pages['sales-funnel'].onload = function(wrapper) { frappe.ui.make_app_page({ parent: wrapper, title: __('Sales Funnel'), single_column: true }); - + wrapper.sales_funnel = new erpnext.SalesFunnel(wrapper); - - wrapper.appframe.add_module_icon("Selling", "sales-funnel", function() { - frappe.set_route("selling-home"); - }); + + frappe.add_breadcrumbs("Selling"); } erpnext.SalesFunnel = Class.extend({ init: function(wrapper) { var me = this; // 0 setTimeout hack - this gives time for canvas to get width and height - setTimeout(function() { + setTimeout(function() { me.setup(wrapper); me.get_data(); }, 0); }, - + setup: function(wrapper) { var me = this; - - this.elements = { + + this.elements = { layout: $(wrapper).find(".layout-main"), from_date: wrapper.appframe.add_date(__("From Date")), to_date: wrapper.appframe.add_date(__("To Date")), - refresh_btn: wrapper.appframe.set_title_right(__("Refresh"), + refresh_btn: wrapper.appframe.set_title_right(__("Refresh"), function() { me.get_data(); }, "icon-refresh"), }; - + this.elements.no_data = $('
' + __("No Data") + '
') .toggle(false) .appendTo(this.elements.layout); - + this.elements.funnel_wrapper = $('
') .appendTo(this.elements.layout); - + this.options = { from_date: frappe.datetime.add_months(frappe.datetime.get_today(), -1), to_date: frappe.datetime.get_today() }; - + // set defaults and bind on change - $.each(this.options, function(k, v) { - me.elements[k].val(frappe.datetime.str_to_user(v)); + $.each(this.options, function(k, v) { + me.elements[k].val(frappe.datetime.str_to_user(v)); me.elements[k].on("change", function() { me.options[k] = frappe.datetime.user_to_str($(this).val()); me.get_data(); }); }); - + // bind refresh this.elements.refresh_btn.on("click", function() { me.get_data(this); }); - + // bind resize $(window).resize(function() { me.render(); }); }, - + get_data: function(btn) { var me = this; frappe.call({ @@ -85,72 +83,72 @@ erpnext.SalesFunnel = Class.extend({ } }); }, - + render: function() { var me = this; this.prepare(); - + var context = this.elements.context, x_start = 0.0, x_end = this.options.width, x_mid = (x_end - x_start) / 2.0, y = 0, y_old = 0.0; - + if(this.options.total_value === 0) { this.elements.no_data.toggle(true); return; } - + this.options.data.forEach(function(d) { context.fillStyle = d.color; context.strokeStyle = d.color; me.draw_triangle(x_start, x_mid, x_end, y, me.options.height); - + y_old = y; // new y y = y + d.height; - + // new x var half_side = (me.options.height - y) / Math.sqrt(3); x_start = x_mid - half_side; x_end = x_mid + half_side; - + var y_mid = y_old + (y - y_old) / 2.0; - + me.draw_legend(x_mid, y_mid, me.options.width, me.options.height, d.value + " - " + d.title); }); }, - + prepare: function() { var me = this; - + this.elements.no_data.toggle(false); - + // calculate width and height options this.options.width = $(this.elements.funnel_wrapper).width() * 2.0 / 3.0; this.options.height = (Math.sqrt(3) * this.options.width) / 2.0; - + // calculate total weightage // as height decreases, area decreases by the square of the reduction // hence, compensating by squaring the index value this.options.total_weightage = this.options.data.reduce( function(prev, curr, i) { return prev + Math.pow(i+1, 2) * curr.value; }, 0.0); - + // calculate height for each data $.each(this.options.data, function(i, d) { d.height = me.options.height * d.value * Math.pow(i+1, 2) / me.options.total_weightage; }); - + this.elements.canvas = $('') .appendTo(this.elements.funnel_wrapper.empty()) .attr("width", $(this.elements.funnel_wrapper).width()) .attr("height", this.options.height); - + this.elements.context = this.elements.canvas.get(0).getContext("2d"); }, - + draw_triangle: function(x_start, x_mid, x_end, y, height) { var context = this.elements.context; context.beginPath(); @@ -161,27 +159,27 @@ erpnext.SalesFunnel = Class.extend({ context.closePath(); context.fill(); }, - + draw_legend: function(x_mid, y_mid, width, height, title) { var context = this.elements.context; - + // draw line context.beginPath(); context.moveTo(x_mid, y_mid); context.lineTo(width, y_mid); context.closePath(); context.stroke(); - + // draw circle context.beginPath(); context.arc(width, y_mid, 5, 0, Math.PI * 2, false); context.closePath(); context.fill(); - + // draw text context.fillStyle = "black"; context.textBaseline = "middle"; context.font = "1.1em sans-serif"; context.fillText(title, width + 20, y_mid); } -}); \ No newline at end of file +}); diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 6abc268f4a..354667a02a 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -9,7 +9,6 @@ cur_frm.cscript.sales_team_fname = "sales_team"; {% include 'selling/sales_common.js' %}; {% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} frappe.provide("erpnext.stock"); frappe.provide("erpnext.stock.delivery_note"); diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index fc2d1b30f3..de2d0defce 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -7,7 +7,6 @@ cur_frm.cscript.other_fname = "other_charges"; {% include 'buying/doctype/purchase_common/purchase_common.js' %}; {% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} frappe.provide("erpnext.stock"); erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({ diff --git a/erpnext/stock/page/stock_analytics/stock_analytics.js b/erpnext/stock/page/stock_analytics/stock_analytics.js index 963cff0b75..8fd2d324f6 100644 --- a/erpnext/stock/page/stock_analytics/stock_analytics.js +++ b/erpnext/stock/page/stock_analytics/stock_analytics.js @@ -12,7 +12,7 @@ frappe.pages['stock-analytics'].onload = function(wrapper) { new erpnext.StockAnalytics(wrapper); - wrapper.appframe.add_module_icon("Stock") + frappe.add_breadcrumbs("Stock") } diff --git a/erpnext/stock/page/stock_ledger/stock_ledger.js b/erpnext/stock/page/stock_ledger/stock_ledger.js index b4086dc66e..84e5b9b61f 100644 --- a/erpnext/stock/page/stock_ledger/stock_ledger.js +++ b/erpnext/stock/page/stock_ledger/stock_ledger.js @@ -9,7 +9,7 @@ frappe.pages['stock-ledger'].onload = function(wrapper) { }); new erpnext.StockLedger(wrapper); - wrapper.appframe.add_module_icon("Stock") + frappe.add_breadcrumbs("Stock") } frappe.require("assets/erpnext/js/stock_grid_report.js"); diff --git a/erpnext/stock/page/stock_level/stock_level.js b/erpnext/stock/page/stock_level/stock_level.js index 8659c28729..785ad7fdfd 100644 --- a/erpnext/stock/page/stock_level/stock_level.js +++ b/erpnext/stock/page/stock_level/stock_level.js @@ -11,7 +11,7 @@ frappe.pages['stock-level'].onload = function(wrapper) { new erpnext.StockLevel(wrapper); - wrapper.appframe.add_module_icon("Stock") + frappe.add_breadcrumbs("Stock") ; } diff --git a/erpnext/support/page/support_analytics/support_analytics.js b/erpnext/support/page/support_analytics/support_analytics.js index 9e24f679e1..95c5fc8a72 100644 --- a/erpnext/support/page/support_analytics/support_analytics.js +++ b/erpnext/support/page/support_analytics/support_analytics.js @@ -11,7 +11,7 @@ frappe.pages['support-analytics'].onload = function(wrapper) { new erpnext.SupportAnalytics(wrapper); - wrapper.appframe.add_module_icon("Support") + frappe.add_breadcrumbs("Support") } From 6f7cba8d730bcc3a7ac6d7102cce0a8369419956 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 22 Dec 2014 18:38:06 +0530 Subject: [PATCH 3/8] [patches] removed 4.0 patches --- erpnext/patches/v4_0/__init__.py | 0 .../patches/v4_0/apply_user_permissions.py | 51 -------- erpnext/patches/v4_0/countrywise_coa.py | 29 ----- ...custom_fields_for_india_specific_fields.py | 63 ---------- .../v4_0/create_price_list_if_missing.py | 35 ------ .../v4_0/customer_discount_to_pricing_rule.py | 33 ------ erpnext/patches/v4_0/fields_to_be_renamed.py | 109 ------------------ erpnext/patches/v4_0/fix_address_template.py | 12 -- .../patches/v4_0/fix_case_of_hr_module_def.py | 13 --- erpnext/patches/v4_0/fix_contact_address.py | 12 -- erpnext/patches/v4_0/fix_employee_user_id.py | 23 ---- .../global_defaults_to_system_settings.py | 39 ------- erpnext/patches/v4_0/import_country_codes.py | 13 --- .../v4_0/map_charge_to_taxes_and_charges.py | 16 --- .../move_warehouse_user_to_restrictions.py | 13 --- erpnext/patches/v4_0/new_address_template.py | 13 --- .../patches/v4_0/reload_sales_print_format.py | 8 -- .../remove_employee_role_if_no_employee.py | 18 --- .../patches/v4_0/remove_module_home_pages.py | 10 -- .../patches/v4_0/rename_sitemap_to_route.py | 16 --- .../v4_0/reset_permissions_for_masters.py | 20 ---- .../patches/v4_0/save_default_letterhead.py | 13 --- .../v4_0/set_naming_series_property_setter.py | 98 ---------------- .../set_pricing_rule_for_buying_or_selling.py | 13 --- erpnext/patches/v4_0/split_email_settings.py | 67 ----------- .../patches/v4_0/update_account_root_type.py | 34 ------ ...custom_print_formats_for_renamed_fields.py | 36 ------ ...to_sales_person_in_maintenance_schedule.py | 12 -- ...harges_in_custom_purchase_print_formats.py | 12 -- .../v4_0/update_tax_amount_after_discount.py | 20 ---- .../patches/v4_0/update_user_properties.py | 51 -------- .../v4_0/update_users_report_view_settings.py | 12 -- erpnext/patches/v4_0/validate_v3_patch.py | 11 -- erpnext/patches/v4_1/__init__.py | 0 .../v4_1/fix_delivery_and_billing_status.py | 12 -- erpnext/patches/v4_1/fix_jv_remarks.py | 21 ---- .../v4_1/fix_sales_order_delivered_status.py | 15 --- .../patches/v4_1/set_outgoing_email_footer.py | 12 -- erpnext/patches/v4_2/__init__.py | 0 .../patches/v4_2/add_currency_turkish_lira.py | 11 -- erpnext/patches/v4_2/default_website_style.py | 10 -- .../patches/v4_2/delete_old_print_formats.py | 23 ---- .../patches/v4_2/fix_account_master_type.py | 12 -- .../fix_gl_entries_for_stock_transactions.py | 52 --------- erpnext/patches/v4_2/party_model.py | 97 ---------------- erpnext/patches/v4_2/recalculate_bom_cost.py | 16 --- .../v4_2/repost_stock_reconciliation.py | 31 ----- .../v4_2/seprate_manufacture_and_repack.py | 9 -- erpnext/patches/v4_2/set_company_country.py | 15 --- erpnext/patches/v4_2/toggle_rounded_total.py | 9 -- .../patches/v4_2/update_project_milestones.py | 8 -- .../v4_2/update_requested_and_ordered_qty.py | 24 ---- .../update_sales_order_invoice_field_name.py | 6 - 53 files changed, 1308 deletions(-) delete mode 100644 erpnext/patches/v4_0/__init__.py delete mode 100644 erpnext/patches/v4_0/apply_user_permissions.py delete mode 100644 erpnext/patches/v4_0/countrywise_coa.py delete mode 100644 erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py delete mode 100644 erpnext/patches/v4_0/create_price_list_if_missing.py delete mode 100644 erpnext/patches/v4_0/customer_discount_to_pricing_rule.py delete mode 100644 erpnext/patches/v4_0/fields_to_be_renamed.py delete mode 100644 erpnext/patches/v4_0/fix_address_template.py delete mode 100644 erpnext/patches/v4_0/fix_case_of_hr_module_def.py delete mode 100644 erpnext/patches/v4_0/fix_contact_address.py delete mode 100644 erpnext/patches/v4_0/fix_employee_user_id.py delete mode 100644 erpnext/patches/v4_0/global_defaults_to_system_settings.py delete mode 100644 erpnext/patches/v4_0/import_country_codes.py delete mode 100644 erpnext/patches/v4_0/map_charge_to_taxes_and_charges.py delete mode 100644 erpnext/patches/v4_0/move_warehouse_user_to_restrictions.py delete mode 100644 erpnext/patches/v4_0/new_address_template.py delete mode 100644 erpnext/patches/v4_0/reload_sales_print_format.py delete mode 100644 erpnext/patches/v4_0/remove_employee_role_if_no_employee.py delete mode 100644 erpnext/patches/v4_0/remove_module_home_pages.py delete mode 100644 erpnext/patches/v4_0/rename_sitemap_to_route.py delete mode 100644 erpnext/patches/v4_0/reset_permissions_for_masters.py delete mode 100644 erpnext/patches/v4_0/save_default_letterhead.py delete mode 100644 erpnext/patches/v4_0/set_naming_series_property_setter.py delete mode 100644 erpnext/patches/v4_0/set_pricing_rule_for_buying_or_selling.py delete mode 100644 erpnext/patches/v4_0/split_email_settings.py delete mode 100644 erpnext/patches/v4_0/update_account_root_type.py delete mode 100644 erpnext/patches/v4_0/update_custom_print_formats_for_renamed_fields.py delete mode 100644 erpnext/patches/v4_0/update_incharge_name_to_sales_person_in_maintenance_schedule.py delete mode 100644 erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py delete mode 100644 erpnext/patches/v4_0/update_tax_amount_after_discount.py delete mode 100644 erpnext/patches/v4_0/update_user_properties.py delete mode 100644 erpnext/patches/v4_0/update_users_report_view_settings.py delete mode 100644 erpnext/patches/v4_0/validate_v3_patch.py delete mode 100644 erpnext/patches/v4_1/__init__.py delete mode 100644 erpnext/patches/v4_1/fix_delivery_and_billing_status.py delete mode 100644 erpnext/patches/v4_1/fix_jv_remarks.py delete mode 100644 erpnext/patches/v4_1/fix_sales_order_delivered_status.py delete mode 100644 erpnext/patches/v4_1/set_outgoing_email_footer.py delete mode 100644 erpnext/patches/v4_2/__init__.py delete mode 100644 erpnext/patches/v4_2/add_currency_turkish_lira.py delete mode 100644 erpnext/patches/v4_2/default_website_style.py delete mode 100644 erpnext/patches/v4_2/delete_old_print_formats.py delete mode 100644 erpnext/patches/v4_2/fix_account_master_type.py delete mode 100644 erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py delete mode 100644 erpnext/patches/v4_2/party_model.py delete mode 100644 erpnext/patches/v4_2/recalculate_bom_cost.py delete mode 100644 erpnext/patches/v4_2/repost_stock_reconciliation.py delete mode 100644 erpnext/patches/v4_2/seprate_manufacture_and_repack.py delete mode 100644 erpnext/patches/v4_2/set_company_country.py delete mode 100644 erpnext/patches/v4_2/toggle_rounded_total.py delete mode 100644 erpnext/patches/v4_2/update_project_milestones.py delete mode 100644 erpnext/patches/v4_2/update_requested_and_ordered_qty.py delete mode 100644 erpnext/patches/v4_2/update_sales_order_invoice_field_name.py diff --git a/erpnext/patches/v4_0/__init__.py b/erpnext/patches/v4_0/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/patches/v4_0/apply_user_permissions.py b/erpnext/patches/v4_0/apply_user_permissions.py deleted file mode 100644 index 7dae02f785..0000000000 --- a/erpnext/patches/v4_0/apply_user_permissions.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -from erpnext.hr.doctype.employee.employee import EmployeeUserDisabledError - -def execute(): - update_hr_permissions() - update_permissions() - remove_duplicate_user_permissions() - frappe.clear_cache() - -def update_hr_permissions(): - from frappe.core.page.user_permissions import user_permissions - - # add set user permissions rights to HR Manager - frappe.db.sql("""update `tabDocPerm` set `set_user_permissions`=1 where parent in ('Employee', 'Leave Application') - and role='HR Manager' and permlevel=0 and `read`=1""") - - # apply user permissions on Employee and Leave Application - frappe.db.sql("""update `tabDocPerm` set `apply_user_permissions`=1 where parent in ('Employee', 'Leave Application') - and role in ('Employee', 'Leave Approver') and permlevel=0 and `read`=1""") - - frappe.clear_cache() - - # save employees to run on_update events - for employee in frappe.db.sql_list("""select name from `tabEmployee` where docstatus < 2"""): - try: - emp = frappe.get_doc("Employee", employee) - emp.ignore_mandatory = True - emp.save() - except EmployeeUserDisabledError: - pass - -def update_permissions(): - # clear match conditions other than owner - frappe.db.sql("""update tabDocPerm set `match`='' - where ifnull(`match`,'') not in ('', 'owner')""") - -def remove_duplicate_user_permissions(): - # remove duplicate user_permissions (if they exist) - for d in frappe.db.sql("""select parent, defkey, defvalue, - count(*) as cnt from tabDefaultValue - where parent not in ('__global', '__default') - group by parent, defkey, defvalue""", as_dict=1): - if d.cnt > 1: - # order by parenttype so that user permission does not get removed! - frappe.db.sql("""delete from tabDefaultValue where `parent`=%s and `defkey`=%s and - `defvalue`=%s order by parenttype limit %s""", (d.parent, d.defkey, d.defvalue, d.cnt-1)) - diff --git a/erpnext/patches/v4_0/countrywise_coa.py b/erpnext/patches/v4_0/countrywise_coa.py deleted file mode 100644 index f11bdb7dbd..0000000000 --- a/erpnext/patches/v4_0/countrywise_coa.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - frappe.reload_doc("setup", 'doctype', "company") - frappe.reload_doc("accounts", 'doctype', "account") - - frappe.db.sql("""update tabAccount set account_type='Cash' - where account_type='Bank or Cash' and account_name in ('Cash', 'Cash In Hand')""") - - frappe.db.sql("""update tabAccount set account_type='Stock' - where account_name = 'Stock Assets'""") - - ac_types = {"Fixed Asset Account": "Fixed Asset", "Bank or Cash": "Bank"} - for old, new in ac_types.items(): - frappe.db.sql("""update tabAccount set account_type=%s - where account_type=%s""", (new, old)) - - try: - frappe.db.sql("""update `tabAccount` set report_type = - if(is_pl_account='Yes', 'Profit and Loss', 'Balance Sheet')""") - - frappe.db.sql("""update `tabAccount` set balance_must_be=debit_or_credit - where ifnull(allow_negative_balance, 0) = 0""") - except: - pass diff --git a/erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py b/erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py deleted file mode 100644 index 5bca5e6962..0000000000 --- a/erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -from frappe.custom.doctype.custom_field.custom_field import create_custom_field_if_values_exist - -def execute(): - frappe.reload_doc("stock", "doctype", "purchase_receipt") - frappe.reload_doc("hr", "doctype", "employee") - frappe.reload_doc("hr", "doctype", "salary_slip") - - india_specific_fields = { - "Purchase Receipt": [{ - "label": "Supplier Shipment No", - "fieldname": "challan_no", - "fieldtype": "Data", - "insert_after": "is_subcontracted" - }, { - "label": "Supplier Shipment Date", - "fieldname": "challan_date", - "fieldtype": "Date", - "insert_after": "is_subcontracted" - }], - "Employee": [{ - "label": "PAN Number", - "fieldname": "pan_number", - "fieldtype": "Data", - "insert_after": "company_email" - }, { - "label": "Gratuity LIC Id", - "fieldname": "gratuity_lic_id", - "fieldtype": "Data", - "insert_after": "company_email" - }, { - "label": "Esic Card No", - "fieldname": "esic_card_no", - "fieldtype": "Data", - "insert_after": "bank_ac_no" - }, { - "label": "PF Number", - "fieldname": "pf_number", - "fieldtype": "Data", - "insert_after": "bank_ac_no" - }], - "Salary Slip": [{ - "label": "Esic No", - "fieldname": "esic_no", - "fieldtype": "Data", - "insert_after": "letter_head", - "permlevel": 1 - }, { - "label": "PF Number", - "fieldname": "pf_no", - "fieldtype": "Data", - "insert_after": "letter_head", - "permlevel": 1 - }] - } - - for dt, docfields in india_specific_fields.items(): - for df in docfields: - create_custom_field_if_values_exist(dt, df) diff --git a/erpnext/patches/v4_0/create_price_list_if_missing.py b/erpnext/patches/v4_0/create_price_list_if_missing.py deleted file mode 100644 index f65b7cb571..0000000000 --- a/erpnext/patches/v4_0/create_price_list_if_missing.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -from frappe import _ -from frappe.utils.nestedset import get_root_of - -def execute(): - # setup not complete - if not frappe.db.sql("""select name from tabCompany limit 1"""): - return - - if "shopping_cart" in frappe.get_installed_apps(): - frappe.reload_doc("shopping_cart", "doctype", "shopping_cart_settings") - - if not frappe.db.sql("select name from `tabPrice List` where buying=1"): - create_price_list(_("Standard Buying"), buying=1) - - if not frappe.db.sql("select name from `tabPrice List` where selling=1"): - create_price_list(_("Standard Selling"), selling=1) - -def create_price_list(pl_name, buying=0, selling=0): - price_list = frappe.get_doc({ - "doctype": "Price List", - "price_list_name": pl_name, - "enabled": 1, - "buying": buying, - "selling": selling, - "currency": frappe.db.get_default("currency"), - "valid_for_territories": [{ - "territory": get_root_of("Territory") - }] - }) - price_list.insert() diff --git a/erpnext/patches/v4_0/customer_discount_to_pricing_rule.py b/erpnext/patches/v4_0/customer_discount_to_pricing_rule.py deleted file mode 100644 index bd27174a0e..0000000000 --- a/erpnext/patches/v4_0/customer_discount_to_pricing_rule.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -from frappe.utils.nestedset import get_root_of - -def execute(): - frappe.reload_doc("accounts", "doctype", "pricing_rule") - - frappe.db.auto_commit_on_many_writes = True - - default_item_group = get_root_of("Item Group") - - for d in frappe.db.sql("""select * from `tabCustomer Discount` - where ifnull(parent, '') != ''""", as_dict=1): - if not d.discount: - continue - - frappe.get_doc({ - "doctype": "Pricing Rule", - "apply_on": "Item Group", - "item_group": d.item_group or default_item_group, - "applicable_for": "Customer", - "customer": d.parent, - "price_or_discount": "Discount Percentage", - "discount_percentage": d.discount, - "selling": 1 - }).insert() - - frappe.db.auto_commit_on_many_writes = False - - frappe.delete_doc("DocType", "Customer Discount") diff --git a/erpnext/patches/v4_0/fields_to_be_renamed.py b/erpnext/patches/v4_0/fields_to_be_renamed.py deleted file mode 100644 index 642a0b49aa..0000000000 --- a/erpnext/patches/v4_0/fields_to_be_renamed.py +++ /dev/null @@ -1,109 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -from frappe.model import rename_field -from frappe.modules import scrub, get_doctype_module - -rename_map = { - "Quotation Item": [ - ["ref_rate", "price_list_rate"], - ["base_ref_rate", "base_price_list_rate"], - ["adj_rate", "discount_percentage"], - ["export_rate", "rate"], - ["basic_rate", "base_rate"], - ["amount", "base_amount"], - ["export_amount", "amount"] - ], - - "Sales Order Item": [ - ["ref_rate", "price_list_rate"], - ["base_ref_rate", "base_price_list_rate"], - ["adj_rate", "discount_percentage"], - ["export_rate", "rate"], - ["basic_rate", "base_rate"], - ["amount", "base_amount"], - ["export_amount", "amount"], - ["reserved_warehouse", "warehouse"] - ], - - "Delivery Note Item": [ - ["ref_rate", "price_list_rate"], - ["base_ref_rate", "base_price_list_rate"], - ["adj_rate", "discount_percentage"], - ["export_rate", "rate"], - ["basic_rate", "base_rate"], - ["amount", "base_amount"], - ["export_amount", "amount"] - ], - - "Sales Invoice Item": [ - ["ref_rate", "price_list_rate"], - ["base_ref_rate", "base_price_list_rate"], - ["adj_rate", "discount_percentage"], - ["export_rate", "rate"], - ["basic_rate", "base_rate"], - ["amount", "base_amount"], - ["export_amount", "amount"] - ], - - "Supplier Quotation Item": [ - ["import_ref_rate", "price_list_rate"], - ["purchase_ref_rate", "base_price_list_rate"], - ["discount_rate", "discount_percentage"], - ["import_rate", "rate"], - ["purchase_rate", "base_rate"], - ["amount", "base_amount"], - ["import_amount", "amount"] - ], - - "Purchase Order Item": [ - ["import_ref_rate", "price_list_rate"], - ["purchase_ref_rate", "base_price_list_rate"], - ["discount_rate", "discount_percentage"], - ["import_rate", "rate"], - ["purchase_rate", "base_rate"], - ["amount", "base_amount"], - ["import_amount", "amount"] - ], - - "Purchase Receipt Item": [ - ["import_ref_rate", "price_list_rate"], - ["purchase_ref_rate", "base_price_list_rate"], - ["discount_rate", "discount_percentage"], - ["import_rate", "rate"], - ["purchase_rate", "base_rate"], - ["amount", "base_amount"], - ["import_amount", "amount"] - ], - - "Purchase Invoice Item": [ - ["import_ref_rate", "price_list_rate"], - ["purchase_ref_rate", "base_price_list_rate"], - ["discount_rate", "discount_percentage"], - ["import_rate", "rate"], - ["rate", "base_rate"], - ["amount", "base_amount"], - ["import_amount", "amount"], - ["expense_head", "expense_account"] - ], - - "Item": [ - ["purchase_account", "expense_account"], - ["default_sales_cost_center", "selling_cost_center"], - ["cost_center", "buying_cost_center"], - ["default_income_account", "income_account"], - ], - "Item Price": [ - ["ref_rate", "price_list_rate"] - ] -} - -def execute(): - for dn in rename_map: - frappe.reload_doc(get_doctype_module(dn), "doctype", scrub(dn)) - - for dt, field_list in rename_map.items(): - for field in field_list: - rename_field(dt, field[0], field[1]) diff --git a/erpnext/patches/v4_0/fix_address_template.py b/erpnext/patches/v4_0/fix_address_template.py deleted file mode 100644 index 5aed489775..0000000000 --- a/erpnext/patches/v4_0/fix_address_template.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors - -from __future__ import unicode_literals -import frappe - -def execute(): - missing_line = """{{ address_line1 }}
""" - for name, template in frappe.db.sql("select name, template from `tabAddress Template`"): - if missing_line not in template: - d = frappe.get_doc("Address Template", name) - d.template = missing_line + d.template - d.save() diff --git a/erpnext/patches/v4_0/fix_case_of_hr_module_def.py b/erpnext/patches/v4_0/fix_case_of_hr_module_def.py deleted file mode 100644 index 73b4e7f56c..0000000000 --- a/erpnext/patches/v4_0/fix_case_of_hr_module_def.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors - -from __future__ import unicode_literals -import frappe - -def execute(): - hr = frappe.db.get_value("Module Def", "HR") - if hr == "Hr": - frappe.rename_doc("Module Def", "Hr", "HR") - frappe.db.set_value("Module Def", "HR", "module_name", "HR") - - frappe.clear_cache() - frappe.setup_module_map() diff --git a/erpnext/patches/v4_0/fix_contact_address.py b/erpnext/patches/v4_0/fix_contact_address.py deleted file mode 100644 index 91d1a0b0c6..0000000000 --- a/erpnext/patches/v4_0/fix_contact_address.py +++ /dev/null @@ -1,12 +0,0 @@ -import frappe - -def execute(): - frappe.reload_doc("website", "doctype", "contact_us_settings") - address = frappe.db.get_value("Contact Us Settings", None, "address") - if address: - address = frappe.get_doc("Address", address) - contact = frappe.get_doc("Contact Us Settings", "Contact Us Settings") - for f in ("address_title", "address_line1", "address_line2", "city", "state", "country", "pincode"): - contact.set(f, address.get(f)) - - contact.save() \ No newline at end of file diff --git a/erpnext/patches/v4_0/fix_employee_user_id.py b/erpnext/patches/v4_0/fix_employee_user_id.py deleted file mode 100644 index d366fa4448..0000000000 --- a/erpnext/patches/v4_0/fix_employee_user_id.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals - -import frappe -from frappe.utils import get_fullname - -def execute(): - for user_id in frappe.db.sql_list("""select distinct user_id from `tabEmployee` - where ifnull(user_id, '')!='' - group by user_id having count(name) > 1"""): - - fullname = get_fullname(user_id) - employee = frappe.db.get_value("Employee", {"employee_name": fullname, "user_id": user_id}) - - if employee: - frappe.db.sql("""update `tabEmployee` set user_id=null - where user_id=%s and name!=%s""", (user_id, employee)) - else: - count = frappe.db.sql("""select count(*) from `tabEmployee` where user_id=%s""", user_id)[0][0] - frappe.db.sql("""update `tabEmployee` set user_id=null - where user_id=%s limit %s""", (user_id, count - 1)) diff --git a/erpnext/patches/v4_0/global_defaults_to_system_settings.py b/erpnext/patches/v4_0/global_defaults_to_system_settings.py deleted file mode 100644 index 57b21aea41..0000000000 --- a/erpnext/patches/v4_0/global_defaults_to_system_settings.py +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# MIT License. See license.txt - -from __future__ import unicode_literals - -import frappe -from collections import Counter -from frappe.core.doctype.user.user import STANDARD_USERS - -def execute(): - frappe.reload_doc("core", "doctype", "system_settings") - system_settings = frappe.get_doc("System Settings") - - # set values from global_defauls - global_defaults = frappe.db.get_value("Global Defaults", None, - ["time_zone", "date_format", "number_format", "float_precision", "session_expiry"], as_dict=True) - - if global_defaults: - for key, val in global_defaults.items(): - if not system_settings.get(key): - system_settings.set(key, val) - - # language - if not system_settings.get("language"): - # find most common language - lang = frappe.db.sql_list("""select language from `tabUser` - where ifnull(language, '')!='' and language not like "Loading%%" and name not in ({standard_users})""".format( - standard_users=", ".join(["%s"]*len(STANDARD_USERS))), tuple(STANDARD_USERS)) - lang = Counter(lang).most_common(1) - lang = (len(lang) > 0) and lang[0][0] or "english" - - system_settings.language = lang - - system_settings.ignore_mandatory = True - system_settings.save() - - global_defaults = frappe.get_doc("Global Defaults") - global_defaults.ignore_mandatory = True - global_defaults.save() diff --git a/erpnext/patches/v4_0/import_country_codes.py b/erpnext/patches/v4_0/import_country_codes.py deleted file mode 100644 index e2e9f9d1f4..0000000000 --- a/erpnext/patches/v4_0/import_country_codes.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# MIT License. See license.txt - -from __future__ import unicode_literals -import frappe -from frappe.geo.country_info import get_all -from erpnext.setup.install import import_country_and_currency - -def execute(): - frappe.reload_doc("setup", "doctype", "country") - import_country_and_currency() - for name, country in get_all().iteritems(): - frappe.set_value("Country", name, "code", country.get("code")) \ No newline at end of file diff --git a/erpnext/patches/v4_0/map_charge_to_taxes_and_charges.py b/erpnext/patches/v4_0/map_charge_to_taxes_and_charges.py deleted file mode 100644 index a814245179..0000000000 --- a/erpnext/patches/v4_0/map_charge_to_taxes_and_charges.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - # udpate sales cycle - for d in ['Sales Invoice', 'Sales Order', 'Quotation', 'Delivery Note']: - frappe.db.sql("""update `tab%s` set taxes_and_charges=charge""" % d) - - # udpate purchase cycle - for d in ['Purchase Invoice', 'Purchase Order', 'Supplier Quotation', 'Purchase Receipt']: - frappe.db.sql("""update `tab%s` set taxes_and_charges=purchase_other_charges""" % d) - - frappe.db.sql("""update `tabPurchase Taxes and Charges` set parentfield='other_charges'""") diff --git a/erpnext/patches/v4_0/move_warehouse_user_to_restrictions.py b/erpnext/patches/v4_0/move_warehouse_user_to_restrictions.py deleted file mode 100644 index 35b3c8661d..0000000000 --- a/erpnext/patches/v4_0/move_warehouse_user_to_restrictions.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -import frappe.permissions - -def execute(): - for warehouse, user in frappe.db.sql("""select parent, user from `tabWarehouse User`"""): - frappe.permissions.add_user_permission("Warehouse", warehouse, user) - - frappe.delete_doc_if_exists("DocType", "Warehouse User") - frappe.reload_doc("stock", "doctype", "warehouse") diff --git a/erpnext/patches/v4_0/new_address_template.py b/erpnext/patches/v4_0/new_address_template.py deleted file mode 100644 index 7a5dabc006..0000000000 --- a/erpnext/patches/v4_0/new_address_template.py +++ /dev/null @@ -1,13 +0,0 @@ -import frappe - -def execute(): - frappe.reload_doc("utilities", "doctype", "address_template") - if not frappe.db.sql("select name from `tabAddress Template`"): - try: - d = frappe.new_doc("Address Template") - d.update({"country":frappe.db.get_default("country") or - frappe.db.get_value("Global Defaults", "Global Defaults", "country")}) - d.insert() - except: - print frappe.get_traceback() - diff --git a/erpnext/patches/v4_0/reload_sales_print_format.py b/erpnext/patches/v4_0/reload_sales_print_format.py deleted file mode 100644 index 99184e36ef..0000000000 --- a/erpnext/patches/v4_0/reload_sales_print_format.py +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - frappe.reload_doc('accounts', 'Print Format', 'POS Invoice') diff --git a/erpnext/patches/v4_0/remove_employee_role_if_no_employee.py b/erpnext/patches/v4_0/remove_employee_role_if_no_employee.py deleted file mode 100644 index c1f368949f..0000000000 --- a/erpnext/patches/v4_0/remove_employee_role_if_no_employee.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -import frappe.permissions - -def execute(): - for user in frappe.db.sql_list("select distinct parent from `tabUserRole` where role='Employee'"): - # if employee record does not exists, remove employee role! - if not frappe.db.get_value("Employee", {"user_id": user}): - try: - user = frappe.get_doc("User", user) - for role in user.get("user_roles", {"role": "Employee"}): - user.get("user_roles").remove(role) - user.save() - except frappe.DoesNotExistError: - pass diff --git a/erpnext/patches/v4_0/remove_module_home_pages.py b/erpnext/patches/v4_0/remove_module_home_pages.py deleted file mode 100644 index f7407a6c05..0000000000 --- a/erpnext/patches/v4_0/remove_module_home_pages.py +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - for page in ("accounts-home", "website-home", "support-home", "stock-home", "selling-home", "projects-home", - "manufacturing-home", "hr-home", "buying-home"): - frappe.delete_doc("Page", page) \ No newline at end of file diff --git a/erpnext/patches/v4_0/rename_sitemap_to_route.py b/erpnext/patches/v4_0/rename_sitemap_to_route.py deleted file mode 100644 index b933e364b4..0000000000 --- a/erpnext/patches/v4_0/rename_sitemap_to_route.py +++ /dev/null @@ -1,16 +0,0 @@ -import frappe -import frappe.model - -def execute(): - frappe.reload_doc("setup", "doctype", "item_group") - frappe.reload_doc("stock", "doctype", "item") - frappe.reload_doc("setup", "doctype", "sales_partner") - - try: - frappe.model.rename_field("Item Group", "parent_website_sitemap", "parent_website_route") - frappe.model.rename_field("Item", "parent_website_sitemap", "parent_website_route") - frappe.model.rename_field("Sales Partner", "parent_website_sitemap", - "parent_website_route") - except Exception, e: - if e.args[0]!=1054: - raise \ No newline at end of file diff --git a/erpnext/patches/v4_0/reset_permissions_for_masters.py b/erpnext/patches/v4_0/reset_permissions_for_masters.py deleted file mode 100644 index b0bc1230b0..0000000000 --- a/erpnext/patches/v4_0/reset_permissions_for_masters.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -from frappe.permissions import reset_perms - -def execute(): - for doctype in ("About Us Settings", "Accounts Settings", "Activity Type", - "Blog Category", "Blog Settings", "Blogger", "Branch", "Brand", "Buying Settings", - "Comment", "Communication", "Company", "Contact Us Settings", - "Country", "Currency", "Currency Exchange", "Deduction Type", "Department", - "Designation", "Earning Type", "Event", "Feed", "File Data", "Fiscal Year", - "HR Settings", "Industry Type", "Leave Type", "Letter Head", - "Mode of Payment", "Module Def", "Naming Series", "POS Setting", "Print Heading", - "Report", "Role", "Selling Settings", "Stock Settings", "Supplier Type", "UOM"): - try: - reset_perms(doctype) - except: - print "Error resetting perms for", doctype - raise diff --git a/erpnext/patches/v4_0/save_default_letterhead.py b/erpnext/patches/v4_0/save_default_letterhead.py deleted file mode 100644 index a6db0cdece..0000000000 --- a/erpnext/patches/v4_0/save_default_letterhead.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - """save default letterhead to set default_letter_head_content""" - try: - letter_head = frappe.get_doc("Letter Head", {"is_default": 1}) - letter_head.save() - except frappe.DoesNotExistError: - pass diff --git a/erpnext/patches/v4_0/set_naming_series_property_setter.py b/erpnext/patches/v4_0/set_naming_series_property_setter.py deleted file mode 100644 index 7ebcc1e1f0..0000000000 --- a/erpnext/patches/v4_0/set_naming_series_property_setter.py +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals - -import frappe -from frappe.custom.doctype.property_setter.property_setter import make_property_setter - -doctype_series_map = { - 'Attendance': 'ATT-', - 'C-Form': 'C-FORM-', - 'Customer': 'CUST-', - 'Customer Issue': 'CI-', - 'Delivery Note': 'DN-', - 'Installation Note': 'IN-', - 'Item': 'ITEM-', - 'Journal Voucher': 'JV-', - 'Lead': 'LEAD-', - 'Opportunity': 'OPTY-', - 'Packing Slip': 'PS-', - 'Production Order': 'PRO-', - 'Purchase Invoice': 'PINV-', - 'Purchase Order': 'PO-', - 'Purchase Receipt': 'PREC-', - 'Quality Inspection': 'QI-', - 'Quotation': 'QTN-', - 'Sales Invoice': 'SINV-', - 'Sales Order': 'SO-', - 'Stock Entry': 'STE-', - 'Supplier': 'SUPP-', - 'Supplier Quotation': 'SQTN-', - 'Issue': 'SUP-' -} - -def execute(): - series_to_set = get_series_to_set() - for doctype, opts in series_to_set.items(): - print "Setting naming series", doctype, opts - set_series(doctype, opts["options"], opts["default"]) - -def set_series(doctype, options, default): - make_property_setter(doctype, "naming_series", "options", options, "Text") - make_property_setter(doctype, "naming_series", "default", default, "Text") - -def get_series_to_set(): - series_to_set = {} - - for doctype, new_series in doctype_series_map.items(): - # you can't fix what does not exist :) - if not frappe.db.a_row_exists(doctype): - continue - - series_to_preserve = get_series_to_preserve(doctype, new_series) - - if not series_to_preserve: - continue - - default_series = get_default_series(doctype, new_series) - if not default_series: - continue - - existing_series = (frappe.get_meta(doctype).get_field("naming_series").options or "").split("\n") - existing_series = filter(None, [d.strip() for d in existing_series]) - - if (not (set(existing_series).difference(series_to_preserve) or set(series_to_preserve).difference(existing_series)) - and len(series_to_preserve)==len(existing_series)): - # print "No change for", doctype, ":", existing_series, "=", series_to_preserve - continue - - # set naming series property setter - series_to_preserve = list(set(series_to_preserve + existing_series)) - if new_series in series_to_preserve: - series_to_preserve.remove(new_series) - - if series_to_preserve: - series_to_set[doctype] = {"options": "\n".join(series_to_preserve), "default": default_series} - - return series_to_set - -def get_series_to_preserve(doctype, new_series): - series_to_preserve = frappe.db.sql_list("""select distinct naming_series from `tab{doctype}` - where ifnull(naming_series, '') not in ('', %s)""".format(doctype=doctype), new_series) - - series_to_preserve.sort() - - return series_to_preserve - -def get_default_series(doctype, new_series): - default_series = frappe.db.sql("""select naming_series from `tab{doctype}` where ifnull(naming_series, '') not in ('', %s) - and creation=(select max(creation) from `tab{doctype}` - where ifnull(naming_series, '') not in ('', %s)) order by creation desc limit 1""".format(doctype=doctype), - (new_series, new_series)) - - if not (default_series and default_series[0][0]): - print "[Skipping] Cannot guess which naming series to use for", doctype - return - - return default_series[0][0] diff --git a/erpnext/patches/v4_0/set_pricing_rule_for_buying_or_selling.py b/erpnext/patches/v4_0/set_pricing_rule_for_buying_or_selling.py deleted file mode 100644 index 8be846ff16..0000000000 --- a/erpnext/patches/v4_0/set_pricing_rule_for_buying_or_selling.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - frappe.reload_doc("accounts", "doctype", "pricing_rule") - frappe.db.sql("""update `tabPricing Rule` set selling=1 where ifnull(applicable_for, '') in - ('', 'Customer', 'Customer Group', 'Territory', 'Sales Partner', 'Campaign')""") - - frappe.db.sql("""update `tabPricing Rule` set buying=1 where ifnull(applicable_for, '') in - ('', 'Supplier', 'Supplier Type')""") diff --git a/erpnext/patches/v4_0/split_email_settings.py b/erpnext/patches/v4_0/split_email_settings.py deleted file mode 100644 index c04e1d5246..0000000000 --- a/erpnext/patches/v4_0/split_email_settings.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - print "WARNING!!!! Email Settings not migrated. Please setup your email again." - - # this will happen if you are migrating very old accounts - # comment out this line below and remember to create new Email Accounts - # for incoming and outgoing mails - raise Exception - - return - - - frappe.reload_doc("core", "doctype", "outgoing_email_settings") - frappe.reload_doc("support", "doctype", "support_email_settings") - - email_settings = get_email_settings() - map_outgoing_email_settings(email_settings) - map_support_email_settings(email_settings) - - -def map_outgoing_email_settings(email_settings): - outgoing_email_settings = frappe.get_doc("Outgoing Email Settings") - for fieldname in (("outgoing_mail_server", "mail_server"), - "use_ssl", "mail_port", "mail_login", "mail_password", - "always_use_login_id_as_sender", "auto_email_id"): - - if isinstance(fieldname, tuple): - from_fieldname, to_fieldname = fieldname - else: - from_fieldname = to_fieldname = fieldname - - outgoing_email_settings.set(to_fieldname, email_settings.get(from_fieldname)) - - outgoing_email_settings._fix_numeric_types() - outgoing_email_settings.save() - -def map_support_email_settings(email_settings): - support_email_settings = frappe.get_doc("Support Email Settings") - - for fieldname in ("sync_support_mails", "support_email", - ("support_host", "mail_server"), - ("support_use_ssl", "use_ssl"), - ("support_username", "mail_login"), - ("support_password", "mail_password"), - "support_signature", "send_autoreply", "support_autoreply"): - - if isinstance(fieldname, tuple): - from_fieldname, to_fieldname = fieldname - else: - from_fieldname = to_fieldname = fieldname - - support_email_settings.set(to_fieldname, email_settings.get(from_fieldname)) - - support_email_settings._fix_numeric_types() - support_email_settings.save() - -def get_email_settings(): - ret = {} - for field, value in frappe.db.sql("select field, value from tabSingles where doctype='Email Settings'"): - ret[field] = value - return ret - diff --git a/erpnext/patches/v4_0/update_account_root_type.py b/erpnext/patches/v4_0/update_account_root_type.py deleted file mode 100644 index 10f6cda3c8..0000000000 --- a/erpnext/patches/v4_0/update_account_root_type.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - frappe.reload_doc("accounts", "doctype", "account") - - account_table_columns = frappe.db.get_table_columns("Account") - if "debit_or_credit" in account_table_columns and "is_pl_account" in account_table_columns: - frappe.db.sql("""UPDATE tabAccount - SET root_type = CASE - WHEN (debit_or_credit='Debit' and is_pl_account = 'No') THEN 'Asset' - WHEN (debit_or_credit='Credit' and is_pl_account = 'No') THEN 'Liability' - WHEN (debit_or_credit='Debit' and is_pl_account = 'Yes') THEN 'Expense' - WHEN (debit_or_credit='Credit' and is_pl_account = 'Yes') THEN 'Income' - END - WHERE ifnull(parent_account, '') = '' - """) - - else: - for key, root_type in (("asset", "Asset"), ("liabilities", "Liability"), ("expense", "Expense"), - ("income", "Income")): - frappe.db.sql("""update tabAccount set root_type=%s where name like %s - and ifnull(parent_account, '')=''""", (root_type, "%" + key + "%")) - - for root in frappe.db.sql("""SELECT name, lft, rgt, root_type FROM `tabAccount` - WHERE ifnull(parent_account, '')=''""", as_dict=True): - if root.root_type: - frappe.db.sql("""UPDATE tabAccount SET root_type=%s WHERE lft>%s and rgt<%s""", - (root.root_type, root.lft, root.rgt)) - else: - print b"Root type not found for {0}".format(root.name.encode("utf-8")) diff --git a/erpnext/patches/v4_0/update_custom_print_formats_for_renamed_fields.py b/erpnext/patches/v4_0/update_custom_print_formats_for_renamed_fields.py deleted file mode 100644 index 60d45cf6a6..0000000000 --- a/erpnext/patches/v4_0/update_custom_print_formats_for_renamed_fields.py +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -import re - -def execute(): - # NOTE: sequence is important - fields_list = ( - ("amount", "base_amount"), - ("ref_rate", "price_list_rate"), - ("base_ref_rate", "base_price_list_rate"), - ("adj_rate", "discount_percentage"), - ("export_rate", "rate"), - ("basic_rate", "base_rate"), - ("export_amount", "amount"), - ("reserved_warehouse", "warehouse"), - ("import_ref_rate", "price_list_rate"), - ("purchase_ref_rate", "base_price_list_rate"), - ("discount_rate", "discount_percentage"), - ("import_rate", "rate"), - ("purchase_rate", "base_rate"), - ("import_amount", "amount") - ) - - condition = " or ".join("""html like "%%{}%%" """.format(d[0].replace("_", "\\_")) for d in fields_list - if d[0] != "amount") - - for name, html in frappe.db.sql("""select name, html from `tabPrint Format` - where standard = 'No' and ({}) and html not like '%%frappe.%%'""".format(condition)): - html = html.replace("wn.", "frappe.") - for from_field, to_field in fields_list: - html = re.sub(r"\b{}\b".format(from_field), to_field, html) - - frappe.db.set_value("Print Format", name, "html", html) diff --git a/erpnext/patches/v4_0/update_incharge_name_to_sales_person_in_maintenance_schedule.py b/erpnext/patches/v4_0/update_incharge_name_to_sales_person_in_maintenance_schedule.py deleted file mode 100644 index 11f0090552..0000000000 --- a/erpnext/patches/v4_0/update_incharge_name_to_sales_person_in_maintenance_schedule.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - frappe.reload_doc("support", "doctype", "maintenance_schedule_detail") - frappe.reload_doc("support", "doctype", "maintenance_schedule_item") - - frappe.db.sql("""update `tabMaintenance Schedule Detail` set sales_person=incharge_name""") - frappe.db.sql("""update `tabMaintenance Schedule Item` set sales_person=incharge_name""") \ No newline at end of file diff --git a/erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py b/erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py deleted file mode 100644 index c0f9ee008f..0000000000 --- a/erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -import re - -def execute(): - for name, html in frappe.db.sql("""select name, html from `tabPrint Format` - where standard = 'No' and html like '%%purchase\\_tax\\_details%%'"""): - html = re.sub(r"\bpurchase_tax_details\b", "other_charges", html) - frappe.db.set_value("Print Format", name, "html", html) diff --git a/erpnext/patches/v4_0/update_tax_amount_after_discount.py b/erpnext/patches/v4_0/update_tax_amount_after_discount.py deleted file mode 100644 index e935bc4088..0000000000 --- a/erpnext/patches/v4_0/update_tax_amount_after_discount.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - frappe.reload_doc("accounts", "doctype", "sales_taxes_and_charges") - docs_with_discount_amount = frappe._dict() - for dt in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]: - records = frappe.db.sql_list("""select name from `tab%s` - where ifnull(discount_amount, 0) > 0 and docstatus=1""" % dt) - docs_with_discount_amount[dt] = records - - for dt, discounted_records in docs_with_discount_amount.items(): - frappe.db.sql("""update `tabSales Taxes and Charges` - set tax_amount_after_discount_amount = tax_amount - where parenttype = %s and parent not in (%s)""" % - ('%s', ', '.join(['%s']*(len(discounted_records)+1))), - tuple([dt, ''] + discounted_records)) diff --git a/erpnext/patches/v4_0/update_user_properties.py b/erpnext/patches/v4_0/update_user_properties.py deleted file mode 100644 index a5b7bfd185..0000000000 --- a/erpnext/patches/v4_0/update_user_properties.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -import frappe.permissions -import frappe.defaults - -def execute(): - frappe.reload_doc("core", "doctype", "docfield") - frappe.reload_doc("hr", "doctype", "employee") - - set_print_email_permissions() - migrate_user_properties_to_user_permissions() - - frappe.clear_cache() - -def migrate_user_properties_to_user_permissions(): - for d in frappe.db.sql("""select parent, defkey, defvalue from tabDefaultValue - where parent not in ('__global', '__default')""", as_dict=True): - df = frappe.db.sql("""select options from tabDocField - where fieldname=%s and fieldtype='Link'""", d.defkey, as_dict=True) - - if df: - frappe.db.sql("""update tabDefaultValue - set defkey=%s, parenttype='User Permission' - where defkey=%s and - parent not in ('__global', '__default')""", (df[0].options, d.defkey)) - -def set_print_email_permissions(): - # reset Page perms - from frappe.core.page.permission_manager.permission_manager import reset - reset("Page") - reset("Report") - - if "allow_print" not in frappe.db.get_table_columns("DocType"): - return - - # patch to move print, email into DocPerm - # NOTE: allow_print and allow_email are misnamed. They were used to hide print / hide email - for doctype, hide_print, hide_email in frappe.db.sql("""select name, ifnull(allow_print, 0), ifnull(allow_email, 0) - from `tabDocType` where ifnull(issingle, 0)=0 and ifnull(istable, 0)=0 and - (ifnull(allow_print, 0)=0 or ifnull(allow_email, 0)=0)"""): - - if not hide_print: - frappe.db.sql("""update `tabDocPerm` set `print`=1 - where permlevel=0 and `read`=1 and parent=%s""", doctype) - - if not hide_email: - frappe.db.sql("""update `tabDocPerm` set `email`=1 - where permlevel=0 and `read`=1 and parent=%s""", doctype) diff --git a/erpnext/patches/v4_0/update_users_report_view_settings.py b/erpnext/patches/v4_0/update_users_report_view_settings.py deleted file mode 100644 index 8883dc26f5..0000000000 --- a/erpnext/patches/v4_0/update_users_report_view_settings.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals - -from frappe.model import update_users_report_view_settings -from erpnext.patches.v4_0.fields_to_be_renamed import rename_map - -def execute(): - for dt, field_list in rename_map.items(): - for field in field_list: - update_users_report_view_settings(dt, field[0], field[1]) diff --git a/erpnext/patches/v4_0/validate_v3_patch.py b/erpnext/patches/v4_0/validate_v3_patch.py deleted file mode 100644 index 21258b6d6d..0000000000 --- a/erpnext/patches/v4_0/validate_v3_patch.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - from frappe.modules.patch_handler import executed - last_v3_patch = 'patches.1401.fix_pos_outstanding' - if not executed(last_v3_patch): - raise Exception, "site not ready to migrate to version 4" diff --git a/erpnext/patches/v4_1/__init__.py b/erpnext/patches/v4_1/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/patches/v4_1/fix_delivery_and_billing_status.py b/erpnext/patches/v4_1/fix_delivery_and_billing_status.py deleted file mode 100644 index 2dbc825085..0000000000 --- a/erpnext/patches/v4_1/fix_delivery_and_billing_status.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - frappe.db.sql("""update `tabSales Order` set delivery_status = 'Not Delivered' - where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0 and ifnull(docstatus, 0) in (0, 1)""") - - frappe.db.sql("""update `tabSales Order` set billing_status = 'Not Billed' - where billing_status = 'Billed' and ifnull(per_billed, 0) = 0 and ifnull(docstatus, 0) in (0, 1)""") diff --git a/erpnext/patches/v4_1/fix_jv_remarks.py b/erpnext/patches/v4_1/fix_jv_remarks.py deleted file mode 100644 index 3b2f342231..0000000000 --- a/erpnext/patches/v4_1/fix_jv_remarks.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - reference_date = guess_reference_date() - for name in frappe.db.sql_list("""select name from `tabJournal Voucher` - where date(creation)>=%s""", reference_date): - jv = frappe.get_doc("Journal Voucher", name) - try: - jv.create_remarks() - except frappe.MandatoryError: - pass - else: - frappe.db.set_value("Journal Voucher", jv.name, "remark", jv.remark) - -def guess_reference_date(): - return (frappe.db.get_value("Patch Log", {"patch": "erpnext.patches.v4_0.validate_v3_patch"}, "creation") - or "2014-05-06") diff --git a/erpnext/patches/v4_1/fix_sales_order_delivered_status.py b/erpnext/patches/v4_1/fix_sales_order_delivered_status.py deleted file mode 100644 index f66d85657d..0000000000 --- a/erpnext/patches/v4_1/fix_sales_order_delivered_status.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - for si in frappe.db.sql_list("""select name - from `tabSales Invoice` - where ifnull(update_stock,0) = 1 and docstatus = 1 and exists( - select name from `tabSales Invoice Item` where parent=`tabSales Invoice`.name and - ifnull(so_detail, "") != "")"""): - - invoice = frappe.get_doc("Sales Invoice", si) - invoice.update_qty() diff --git a/erpnext/patches/v4_1/set_outgoing_email_footer.py b/erpnext/patches/v4_1/set_outgoing_email_footer.py deleted file mode 100644 index 73d8d607f2..0000000000 --- a/erpnext/patches/v4_1/set_outgoing_email_footer.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -from erpnext.setup.install import default_mail_footer - -def execute(): - return - mail_footer = frappe.db.get_default('mail_footer') or '' - mail_footer += default_mail_footer - frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "footer", mail_footer) diff --git a/erpnext/patches/v4_2/__init__.py b/erpnext/patches/v4_2/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/patches/v4_2/add_currency_turkish_lira.py b/erpnext/patches/v4_2/add_currency_turkish_lira.py deleted file mode 100644 index d768d58f3b..0000000000 --- a/erpnext/patches/v4_2/add_currency_turkish_lira.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -from frappe.geo.country_info import get_country_info -from erpnext.setup.install import add_country_and_currency - -def execute(): - country = get_country_info(country="Turkey") - add_country_and_currency("Turkey", country) diff --git a/erpnext/patches/v4_2/default_website_style.py b/erpnext/patches/v4_2/default_website_style.py deleted file mode 100644 index 6f375b9ab5..0000000000 --- a/erpnext/patches/v4_2/default_website_style.py +++ /dev/null @@ -1,10 +0,0 @@ -import frappe -from frappe.templates.pages.style_settings import default_properties - -def execute(): - frappe.reload_doc('website', 'doctype', 'style_settings') - style_settings = frappe.get_doc("Style Settings", "Style Settings") - if not style_settings.apply_style: - style_settings.update(default_properties) - style_settings.apply_style = 1 - style_settings.save() diff --git a/erpnext/patches/v4_2/delete_old_print_formats.py b/erpnext/patches/v4_2/delete_old_print_formats.py deleted file mode 100644 index 75c3619ae4..0000000000 --- a/erpnext/patches/v4_2/delete_old_print_formats.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - old_formats = ("Sales Invoice", "Sales Invoice Spartan", "Sales Invoice Modern", - "Sales Invoice Classic", - "Sales Order Spartan", "Sales Order Modern", "Sales Order Classic", - "Purchase Order Spartan", "Purchase Order Modern", "Purchase Order Classic", - "Quotation Spartan", "Quotation Modern", "Quotation Classic", - "Delivery Note Spartan", "Delivery Note Modern", "Delivery Note Classic") - - for fmt in old_formats: - # update property setter - for ps in frappe.db.sql_list("""select name from `tabProperty Setter` - where property='default_print_format' and value=%s""", fmt): - ps = frappe.get_doc("Property Setter", ps) - ps.value = "Standard" - ps.save(ignore_permissions = True) - - frappe.delete_doc_if_exists("Print Format", fmt) diff --git a/erpnext/patches/v4_2/fix_account_master_type.py b/erpnext/patches/v4_2/fix_account_master_type.py deleted file mode 100644 index d4603f24f5..0000000000 --- a/erpnext/patches/v4_2/fix_account_master_type.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - for d in frappe.db.sql("""select name from `tabAccount` - where ifnull(master_type, '') not in ('Customer', 'Supplier', 'Employee', '') and docstatus=0"""): - ac = frappe.get_doc("Account", d[0]) - ac.master_type = None - ac.save() diff --git a/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py b/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py deleted file mode 100644 index a72b95480a..0000000000 --- a/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -from frappe.utils import flt - -def execute(): - from erpnext.utilities.repost_stock import repost - repost(allow_zero_rate=True, only_actual=True) - - warehouse_account = frappe.db.sql("""select name, master_name from tabAccount - where ifnull(account_type, '') = 'Warehouse'""") - if warehouse_account: - warehouses = [d[1] for d in warehouse_account] - accounts = [d[0] for d in warehouse_account] - - stock_vouchers = frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no - from `tabStock Ledger Entry` sle - where sle.warehouse in (%s) - order by sle.posting_date""" % - ', '.join(['%s']*len(warehouses)), tuple(warehouses)) - - rejected = [] - for voucher_type, voucher_no in stock_vouchers: - stock_bal = frappe.db.sql("""select sum(stock_value_difference) from `tabStock Ledger Entry` - where voucher_type=%s and voucher_no =%s and warehouse in (%s)""" % - ('%s', '%s', ', '.join(['%s']*len(warehouses))), tuple([voucher_type, voucher_no] + warehouses)) - - account_bal = frappe.db.sql("""select ifnull(sum(ifnull(debit, 0) - ifnull(credit, 0)), 0) - from `tabGL Entry` - where voucher_type=%s and voucher_no =%s and account in (%s) - group by voucher_type, voucher_no""" % - ('%s', '%s', ', '.join(['%s']*len(accounts))), tuple([voucher_type, voucher_no] + accounts)) - - if stock_bal and account_bal and abs(flt(stock_bal[0][0]) - flt(account_bal[0][0])) > 0.1: - try: - print voucher_type, voucher_no, stock_bal[0][0], account_bal[0][0] - - frappe.db.sql("""delete from `tabGL Entry` - where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no)) - - voucher = frappe.get_doc(voucher_type, voucher_no) - voucher.make_gl_entries(repost_future_gle=False) - frappe.db.commit() - except Exception, e: - print frappe.get_traceback() - rejected.append([voucher_type, voucher_no]) - frappe.db.rollback() - - print "Failed to repost: " - print rejected diff --git a/erpnext/patches/v4_2/party_model.py b/erpnext/patches/v4_2/party_model.py deleted file mode 100644 index 7bcb6ce2fd..0000000000 --- a/erpnext/patches/v4_2/party_model.py +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - frappe.reload_doc("accounts", "doctype", "account") - frappe.reload_doc("setup", "doctype", "company") - frappe.reload_doc("accounts", "doctype", "journal_voucher_detail") - frappe.reload_doc("accounts", "doctype", "gl_entry") - receivable_payable_accounts = create_receivable_payable_account() - if receivable_payable_accounts: - set_party_in_jv_and_gl_entry(receivable_payable_accounts) - delete_individual_party_account() - remove_customer_supplier_account_report() - - -def link_warehouse_account(): - frappe.db.sql("""update tabAccount set warehouse=master_name - where ifnull(account_type, '') = 'Warehouse' and ifnull(master_name, '') != ''""") - -def create_receivable_payable_account(): - receivable_payable_accounts = frappe._dict() - - def _create_account(args): - account = frappe.new_doc("Account") - account.group_or_ledger = "Ledger" - account.update(args) - account.insert() - - frappe.db.set_value("Company", args["company"], ("default_receivable_account" - if args["account_type"]=="Receivable" else "default_payable_account"), account.name) - - receivable_payable_accounts.setdefault(args["company"], {}).setdefault(args["account_type"], account.name) - - for company in frappe.db.sql_list("select name from tabCompany"): - _create_account({ - "account_name": "Debtors", - "account_type": "Receivable", - "company": company, - "parent_account": get_parent_account(company, "Customer") - }) - - _create_account({ - "account_name": "Creditors", - "account_type": "Payable", - "company": company, - "parent_account": get_parent_account(company, "Supplier") - }) - - return receivable_payable_accounts - -def get_parent_account(company, master_type): - parent_account = frappe.db.get_value("Company", company, - "receivables_group" if master_type=="Customer" else "payables_group") - if not parent_account: - parent_account = frappe.db.get_value("Account", {"company": company, - "account_name": "Accounts Receivable" if master_type=="Customer" else "Accounts Payable"}) - - if not parent_account: - parent_account = frappe.db.sql_list("""select parent_account from tabAccount - where company=%s and ifnull(master_type, '')=%s and ifnull(master_name, '')!='' limit 1""", - (company, master_type)) - parent_account = parent_account[0][0] if parent_account else None - - return parent_account - -def set_party_in_jv_and_gl_entry(receivable_payable_accounts): - accounts = frappe.db.sql("""select name, master_type, master_name, company from `tabAccount` - where ifnull(master_type, '') in ('Customer', 'Supplier') and ifnull(master_name, '') != ''""", as_dict=1) - - account_map = frappe._dict() - for d in accounts: - account_map.setdefault(d.name, d) - - if not account_map: - return - - for dt in ["Journal Voucher Detail", "GL Entry"]: - records = frappe.db.sql("""select name, account from `tab%s` where account in (%s)""" % - (dt, ", ".join(['%s']*len(account_map))), tuple(account_map.keys()), as_dict=1) - for d in records: - account_details = account_map.get(d.account, {}) - account_type = "Receivable" if account_details.get("master_type")=="Customer" else "Payable" - new_account = receivable_payable_accounts[account_details.get("company")][account_type] - - frappe.db.sql("update `tab{0}` set account=%s, party_type=%s, party=%s where name=%s".format(dt), - (new_account, account_details.get("master_type"), account_details.get("master_name"), d.name)) - -def delete_individual_party_account(): - frappe.db.sql("""delete from `tabAccount` where ifnull(master_type, '') in ('Customer', 'Supplier') - and ifnull(master_name, '') != ''""") - -def remove_customer_supplier_account_report(): - for d in ["Customer Account Head", "Supplier Account Head"]: - frappe.delete_doc("Report", d) diff --git a/erpnext/patches/v4_2/recalculate_bom_cost.py b/erpnext/patches/v4_2/recalculate_bom_cost.py deleted file mode 100644 index 3a194ff195..0000000000 --- a/erpnext/patches/v4_2/recalculate_bom_cost.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - for d in frappe.db.sql("select name from `tabBOM` where docstatus < 2"): - try: - document = frappe.get_doc('BOM', d[0]) - if document.docstatus == 1: - document.ignore_validate_update_after_submit = True - document.calculate_cost() - document.save() - except: - pass \ No newline at end of file diff --git a/erpnext/patches/v4_2/repost_stock_reconciliation.py b/erpnext/patches/v4_2/repost_stock_reconciliation.py deleted file mode 100644 index 73cb36d487..0000000000 --- a/erpnext/patches/v4_2/repost_stock_reconciliation.py +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -import json - -def execute(): - existing_allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock") - frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1) - - head_row = ["Item Code", "Warehouse", "Quantity", "Valuation Rate"] - stock_reco_to_be_reposted = [] - for d in frappe.db.sql("""select name, reconciliation_json from `tabStock Reconciliation` - where docstatus=1 and creation > '2014-03-01'""", as_dict=1): - data = json.loads(d.reconciliation_json) - for row in data[data.index(head_row)+1:]: - if row[3] in ["", None]: - stock_reco_to_be_reposted.append(d.name) - break - - for dn in stock_reco_to_be_reposted: - reco = frappe.get_doc("Stock Reconciliation", dn) - reco.docstatus = 2 - reco.on_cancel() - - reco.docstatus = 1 - reco.validate() - reco.on_submit() - - frappe.db.set_value("Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock) diff --git a/erpnext/patches/v4_2/seprate_manufacture_and_repack.py b/erpnext/patches/v4_2/seprate_manufacture_and_repack.py deleted file mode 100644 index 5b36289bc9..0000000000 --- a/erpnext/patches/v4_2/seprate_manufacture_and_repack.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - frappe.db.sql("""update `tabStock Entry` set purpose='Manufacture' where purpose='Manufacture/Repack' and ifnull(production_order,"")!="" """) - frappe.db.sql("""update `tabStock Entry` set purpose='Repack' where purpose='Manufacture/Repack' and ifnull(production_order,"")="" """) \ No newline at end of file diff --git a/erpnext/patches/v4_2/set_company_country.py b/erpnext/patches/v4_2/set_company_country.py deleted file mode 100644 index 6992f02202..0000000000 --- a/erpnext/patches/v4_2/set_company_country.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - country = frappe.db.get_single_value("Global Defaults", "country") - if not country: - print "Country not specified in Global Defaults" - return - - for company in frappe.db.sql_list("""select name from `tabCompany` - where ifnull(country, '')=''"""): - frappe.db.set_value("Company", company, "country", country) diff --git a/erpnext/patches/v4_2/toggle_rounded_total.py b/erpnext/patches/v4_2/toggle_rounded_total.py deleted file mode 100644 index aa63fdccd3..0000000000 --- a/erpnext/patches/v4_2/toggle_rounded_total.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - global_defaults = frappe.get_doc("Global Defaults", "Global Defaults") - global_defaults.toggle_rounded_total() diff --git a/erpnext/patches/v4_2/update_project_milestones.py b/erpnext/patches/v4_2/update_project_milestones.py deleted file mode 100644 index 4f93eb9172..0000000000 --- a/erpnext/patches/v4_2/update_project_milestones.py +++ /dev/null @@ -1,8 +0,0 @@ -import frappe - -def execute(): - for project in frappe.db.sql_list("select name from tabProject"): - frappe.reload_doc("projects", "doctype", "project") - p = frappe.get_doc("Project", project) - p.update_milestones_completed() - p.db_set("percent_milestones_completed", p.percent_milestones_completed) diff --git a/erpnext/patches/v4_2/update_requested_and_ordered_qty.py b/erpnext/patches/v4_2/update_requested_and_ordered_qty.py deleted file mode 100644 index d6cabd8c23..0000000000 --- a/erpnext/patches/v4_2/update_requested_and_ordered_qty.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - from erpnext.utilities.repost_stock import update_bin_qty, get_indented_qty, get_ordered_qty - - count=0 - for item_code, warehouse in frappe.db.sql("""select distinct item_code, warehouse from - (select item_code, warehouse from tabBin - union - select item_code, warehouse from `tabStock Ledger Entry`) a"""): - try: - count += 1 - update_bin_qty(item_code, warehouse, { - "indented_qty": get_indented_qty(item_code, warehouse), - "ordered_qty": get_ordered_qty(item_code, warehouse) - }) - if count % 200 == 0: - frappe.db.commit() - except: - frappe.db.rollback() diff --git a/erpnext/patches/v4_2/update_sales_order_invoice_field_name.py b/erpnext/patches/v4_2/update_sales_order_invoice_field_name.py deleted file mode 100644 index a8303a0aae..0000000000 --- a/erpnext/patches/v4_2/update_sales_order_invoice_field_name.py +++ /dev/null @@ -1,6 +0,0 @@ -import frappe - -def execute(): - frappe.reload_doc('accounts', 'doctype', 'sales_invoice') - frappe.db.sql("""update `tabSales Invoice` set from_date = invoice_period_from_date, - to_date = invoice_period_to_date, is_recurring = convert_into_recurring_invoice""") From 4096a3ab2b5421301f046399cf609232134ab1ff Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 23 Dec 2014 17:56:47 +0530 Subject: [PATCH 4/8] [design] form toolbar --- .../accounts/doctype/sales_invoice/sales_invoice.js | 8 ++++---- .../accounts/page/accounts_browser/accounts_browser.js | 10 +++++----- .../page/purchase_analytics/purchase_analytics.js | 2 +- erpnext/projects/doctype/time_log/time_log_list.js | 2 +- erpnext/public/js/account_tree_grid.js | 2 +- erpnext/public/js/stock_analytics.js | 2 +- erpnext/public/js/transaction.js | 8 ++++---- .../selling/page/sales_analytics/sales_analytics.js | 2 +- erpnext/selling/page/sales_browser/sales_browser.js | 4 ++-- erpnext/selling/page/sales_funnel/sales_funnel.js | 6 +++--- erpnext/stock/page/stock_ledger/stock_ledger.js | 2 +- erpnext/stock/page/stock_level/stock_level.js | 2 +- .../page/support_analytics/support_analytics.js | 2 +- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 2061fb198c..c059702e95 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -73,12 +73,12 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte }); if(!from_delivery_note) { - cur_frm.appframe.add_primary_action(__('Make Delivery'), cur_frm.cscript['Make Delivery Note'], "icon-truck") + cur_frm.page.add_menu_item(__('Make Delivery'), cur_frm.cscript['Make Delivery Note'], "icon-truck") } } if(doc.outstanding_amount!=0) { - cur_frm.appframe.add_primary_action(__('Make Payment Entry'), cur_frm.cscript.make_bank_voucher, "icon-money"); + cur_frm.page.add_menu_item(__('Make Payment Entry'), cur_frm.cscript.make_bank_voucher, "icon-money"); } } @@ -90,7 +90,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte }, sales_order_btn: function() { - this.$sales_order_btn = cur_frm.appframe.add_primary_action(__('From Sales Order'), + this.$sales_order_btn = cur_frm.page.add_menu_item(__('From Sales Order'), function() { frappe.model.map_current_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice", @@ -107,7 +107,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte }, delivery_note_btn: function() { - this.$delivery_note_btn = cur_frm.appframe.add_primary_action(__('From Delivery Note'), + this.$delivery_note_btn = cur_frm.page.add_menu_item(__('From Delivery Note'), function() { frappe.model.map_current_doc({ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice", diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js index dc0dd7a95e..cfdc2b4954 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.js +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js @@ -41,16 +41,16 @@ pscript['onload_Accounts Browser'] = function(wrapper){ '

'+__('Please setup your chart of accounts before you start Accounting Entries')+'

').appendTo(main); if (frappe.boot.user.can_create.indexOf("Company") !== -1) { - wrapper.appframe.add_button(__('New Company'), function() { newdoc('Company'); }, + wrapper.page.add_button(__('New Company'), function() { newdoc('Company'); }, 'icon-plus'); } - wrapper.appframe.set_title_right(__('Refresh'), function() { + wrapper.page.set_primary_action(__('Refresh'), function() { wrapper.$company_select.change(); }); // company-select - wrapper.$company_select = wrapper.appframe.add_select("Company", []) + wrapper.$company_select = wrapper.page.add_select("Company", []) .change(function() { var ctype = frappe.get_route()[1] || 'Account'; erpnext.account_chart = new erpnext.AccountsChart(ctype, $(this).val(), @@ -73,9 +73,9 @@ pscript['onload_Accounts Browser'] = function(wrapper){ pscript.set_title = function(wrapper, ctype, val) { if(val) { - wrapper.appframe.set_title('Chart of '+ctype+'s' + " - " + cstr(val)); + wrapper.page.set_title('Chart of '+ctype+'s' + " - " + cstr(val)); } else { - wrapper.appframe.set_title('Chart of '+ctype+'s'); + wrapper.page.set_title('Chart of '+ctype+'s'); } } diff --git a/erpnext/buying/page/purchase_analytics/purchase_analytics.js b/erpnext/buying/page/purchase_analytics/purchase_analytics.js index e1d6294d6f..2cc5b7a69e 100644 --- a/erpnext/buying/page/purchase_analytics/purchase_analytics.js +++ b/erpnext/buying/page/purchase_analytics/purchase_analytics.js @@ -21,7 +21,7 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({ title: __("Purchase Analytics"), page: wrapper, parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, + page: wrapper.page, doctypes: ["Item", "Item Group", "Supplier", "Supplier Type", "Company", "Fiscal Year", "Purchase Invoice", "Purchase Invoice Item", "Purchase Order", "Purchase Order Item[Purchase Analytics]", diff --git a/erpnext/projects/doctype/time_log/time_log_list.js b/erpnext/projects/doctype/time_log/time_log_list.js index 6115607ade..e9a7c767ce 100644 --- a/erpnext/projects/doctype/time_log/time_log_list.js +++ b/erpnext/projects/doctype/time_log/time_log_list.js @@ -6,7 +6,7 @@ frappe.listview_settings['Time Log'] = { add_fields: ["status", "billable", "activity_type", "task", "project", "hours", "time_log_for"], selectable: true, onload: function(me) { - me.appframe.add_primary_action(__("Make Time Log Batch"), function() { + me.page.add_menu_item(__("Make Time Log Batch"), function() { var selected = me.get_checked_items() || []; if(!selected.length) { diff --git a/erpnext/public/js/account_tree_grid.js b/erpnext/public/js/account_tree_grid.js index 87fb7a986b..4bc93ea50a 100644 --- a/erpnext/public/js/account_tree_grid.js +++ b/erpnext/public/js/account_tree_grid.js @@ -20,7 +20,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ title: title, page: wrapper, parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, + page: wrapper.page, doctypes: ["Company", "Fiscal Year", "Account", "GL Entry", "Cost Center"], tree_grid: { show: true, diff --git a/erpnext/public/js/stock_analytics.js b/erpnext/public/js/stock_analytics.js index 091836f95e..d32afebeab 100644 --- a/erpnext/public/js/stock_analytics.js +++ b/erpnext/public/js/stock_analytics.js @@ -9,7 +9,7 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ title: __("Stock Analytics"), page: wrapper, parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, + page: wrapper.page, doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", "Fiscal Year", "Serial No"], tree_grid: { diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 5bbfae4641..ab1f7d22c9 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -82,9 +82,9 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ this.$pos_btn && this.$pos_btn.remove(); - this.$pos_btn = this.frm.appframe.add_primary_action(btn_label, function() { + this.$pos_btn = this.frm.page.add_menu_item(btn_label, function() { me.toggle_pos(); - }, icon, "btn-default"); + }); } else { // hack: will avoid calling refresh from refresh setTimeout(function() { me.toggle_pos(false); }, 100); @@ -105,12 +105,12 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ // make pos if(!this.frm.pos) { - var wrapper = this.frm.appframe.add_view("pos", "
"); + var wrapper = this.frm.page.add_view("pos", "
"); this.frm.pos = new erpnext.POS(wrapper, this.frm); } // toggle view - this.frm.appframe.set_view(this.pos_active ? "main" : "pos"); + this.frm.page.set_view(this.pos_active ? "main" : "pos"); this.pos_active = !this.pos_active; // refresh diff --git a/erpnext/selling/page/sales_analytics/sales_analytics.js b/erpnext/selling/page/sales_analytics/sales_analytics.js index 75863533ec..8e5ca96634 100644 --- a/erpnext/selling/page/sales_analytics/sales_analytics.js +++ b/erpnext/selling/page/sales_analytics/sales_analytics.js @@ -20,7 +20,7 @@ erpnext.SalesAnalytics = frappe.views.TreeGridReport.extend({ title: __("Sales Analytics"), page: wrapper, parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, + page: wrapper.page, doctypes: ["Item", "Item Group", "Customer", "Customer Group", "Company", "Territory", "Fiscal Year", "Sales Invoice", "Sales Invoice Item", "Sales Order", "Sales Order Item[Sales Analytics]", diff --git a/erpnext/selling/page/sales_browser/sales_browser.js b/erpnext/selling/page/sales_browser/sales_browser.js index fcbd71ca9d..3f8f6cba28 100644 --- a/erpnext/selling/page/sales_browser/sales_browser.js +++ b/erpnext/selling/page/sales_browser/sales_browser.js @@ -8,7 +8,7 @@ pscript['onload_Sales Browser'] = function(wrapper){ frappe.add_breadcrumbs("Selling") - wrapper.appframe.set_title_right(__('Refresh'), function() { + wrapper.page.set_primary_action(__('Refresh'), function() { wrapper.make_tree(); }); @@ -44,7 +44,7 @@ pscript['onshow_Sales Browser'] = function(wrapper){ // set route var ctype = frappe.get_route()[1] || 'Territory'; - wrapper.appframe.set_title(__('{0} Tree',[__(ctype)])); + wrapper.page.set_title(__('{0} Tree',[__(ctype)])); if(erpnext.sales_chart && erpnext.sales_chart.ctype != ctype) { wrapper.make_tree(); diff --git a/erpnext/selling/page/sales_funnel/sales_funnel.js b/erpnext/selling/page/sales_funnel/sales_funnel.js index 99d3d070b1..47b6a14e45 100644 --- a/erpnext/selling/page/sales_funnel/sales_funnel.js +++ b/erpnext/selling/page/sales_funnel/sales_funnel.js @@ -28,9 +28,9 @@ erpnext.SalesFunnel = Class.extend({ this.elements = { layout: $(wrapper).find(".layout-main"), - from_date: wrapper.appframe.add_date(__("From Date")), - to_date: wrapper.appframe.add_date(__("To Date")), - refresh_btn: wrapper.appframe.set_title_right(__("Refresh"), + from_date: wrapper.page.add_date(__("From Date")), + to_date: wrapper.page.add_date(__("To Date")), + refresh_btn: wrapper.page.set_primary_action(__("Refresh"), function() { me.get_data(); }, "icon-refresh"), }; diff --git a/erpnext/stock/page/stock_ledger/stock_ledger.js b/erpnext/stock/page/stock_ledger/stock_ledger.js index 84e5b9b61f..af0eba26a9 100644 --- a/erpnext/stock/page/stock_ledger/stock_ledger.js +++ b/erpnext/stock/page/stock_ledger/stock_ledger.js @@ -20,7 +20,7 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({ title: __("Stock Ledger"), page: wrapper, parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, + page: wrapper.page, doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", "Serial No"], }) }, diff --git a/erpnext/stock/page/stock_level/stock_level.js b/erpnext/stock/page/stock_level/stock_level.js index 785ad7fdfd..e54c518822 100644 --- a/erpnext/stock/page/stock_level/stock_level.js +++ b/erpnext/stock/page/stock_level/stock_level.js @@ -25,7 +25,7 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({ title: __("Stock Level"), page: wrapper, parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, + page: wrapper.page, doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Production Order", "Material Request Item", "Purchase Order Item", "Sales Order Item", "Brand", "Serial No"], }); diff --git a/erpnext/support/page/support_analytics/support_analytics.js b/erpnext/support/page/support_analytics/support_analytics.js index 95c5fc8a72..54e6d68722 100644 --- a/erpnext/support/page/support_analytics/support_analytics.js +++ b/erpnext/support/page/support_analytics/support_analytics.js @@ -21,7 +21,7 @@ erpnext.SupportAnalytics = frappe.views.GridReportWithPlot.extend({ title: __("Support Analtyics"), page: wrapper, parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, + page: wrapper.page, doctypes: ["Issue", "Fiscal Year"], }); }, From a5b149c061dd72e86bb2bdd53ba51285f59bad50 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 25 Dec 2014 17:17:32 +0530 Subject: [PATCH 5/8] [design] module pages, messages, timelines --- erpnext/accounts/page/accounts_browser/accounts_browser.js | 2 +- erpnext/public/css/erpnext.css | 4 ---- erpnext/public/js/account_tree_grid.js | 2 +- erpnext/templates/includes/cart.js | 4 ++-- erpnext/utilities/doctype/rename_tool/rename_tool.js | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js index cfdc2b4954..61e66970d4 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.js +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js @@ -19,7 +19,7 @@ pscript['onload_Accounts Browser'] = function(wrapper){ chart_area = $("
") .css({"margin-bottom": "15px", "min-height": "200px"}) .appendTo(main), - help_area = $('
'+ + help_area = $('
'+ '

'+__('Quick Help')+'

'+ '
    '+ '
  1. '+__('To add child nodes, explore tree and click on the node under which you want to add more nodes.')+'
  2. '+ diff --git a/erpnext/public/css/erpnext.css b/erpnext/public/css/erpnext.css index 7a93757944..91d1da23b8 100644 --- a/erpnext/public/css/erpnext.css +++ b/erpnext/public/css/erpnext.css @@ -1,7 +1,3 @@ -.small { - font-size: 11.5px; -} - .erpnext-footer { margin: 11px auto; text-align: center; diff --git a/erpnext/public/js/account_tree_grid.js b/erpnext/public/js/account_tree_grid.js index 4bc93ea50a..3b11345d9d 100644 --- a/erpnext/public/js/account_tree_grid.js +++ b/erpnext/public/js/account_tree_grid.js @@ -69,7 +69,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ {fieldtype: "Label", label: __("To")}, {fieldtype: "Date", label: __("To Date"), fieldname: "to_date"}, {fieldtype: "Button", label: __("Refresh"), icon:"icon-refresh icon-white", - cssClass:"btn-info"}, + cssClass:"btn-primary"}, {fieldtype: "Button", label: __("Reset Filters"), icon: "icon-filter"}, ], setup_filters: function() { diff --git a/erpnext/templates/includes/cart.js b/erpnext/templates/includes/cart.js index 90cfea59da..20b86ba325 100644 --- a/erpnext/templates/includes/cart.js +++ b/erpnext/templates/includes/cart.js @@ -8,7 +8,7 @@ frappe.provide("shopping_cart"); $.extend(shopping_cart, { show_error: function(title, text) { - $("#cart-container").html('

    ' + title + '

    ' + text + '
    '); + $("#cart-container").html('

    ' + title + '

    ' + text + '
    '); }, bind_events: function() { @@ -96,7 +96,7 @@ $.extend(shopping_cart, { }); if(!(addresses && addresses.length)) { - $cart_shipping_address.html('
    '+frappe._("Hey! Go ahead and add an address")+'
    '); + $cart_shipping_address.html('
    '+frappe._("Hey! Go ahead and add an address")+'
    '); } else { shopping_cart.render_address($cart_shipping_address, addresses, doc.shipping_address_name); shopping_cart.render_address($cart_billing_address, addresses, doc.customer_address); diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.js b/erpnext/utilities/doctype/rename_tool/rename_tool.js index 32b6cd4990..5a33b2bf5b 100644 --- a/erpnext/utilities/doctype/rename_tool/rename_tool.js +++ b/erpnext/utilities/doctype/rename_tool/rename_tool.js @@ -44,7 +44,7 @@ cur_frm.cscript.setup_upload = function() { .click(function() { $log.html("Working..."); }) - .addClass("btn-info") + .addClass("btn-primary") .attr('value', 'Upload and Rename') } From afbfdcf5522f3757b281fca23710de0534912594 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 30 Dec 2014 18:09:40 +0530 Subject: [PATCH 6/8] [ui] minor fixes --- erpnext/config/setup.py | 2 +- erpnext/public/js/utils.js | 4 ++-- erpnext/setup/doctype/naming_series/naming_series.py | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/erpnext/config/setup.py b/erpnext/config/setup.py index f3c0cecf62..8fce33e790 100644 --- a/erpnext/config/setup.py +++ b/erpnext/config/setup.py @@ -17,7 +17,7 @@ def get_data(): ] }, { - "label": _("Printing and Branding"), + "label": _("Printing"), "icon": "icon-print", "items": [ { diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 5528322b1a..58e512235a 100644 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -120,7 +120,7 @@ $.extend(erpnext.utils, { render_address_and_contact: function(frm) { // render address $(frm.fields_dict['address_html'].wrapper) - .html(frappe.render(frappe.templates.address_list, + .html(frappe.render_template("address_list", cur_frm.doc.__onload)) .find(".btn-address").on("click", function() { new_doc("Address"); @@ -129,7 +129,7 @@ $.extend(erpnext.utils, { // render contact if(frm.fields_dict['contact_html']) { $(frm.fields_dict['contact_html'].wrapper) - .html(frappe.render(frappe.templates.contact_list, + .html(frappe.render_template("contact_list", cur_frm.doc.__onload)) .find(".btn-contact").on("click", function() { new_doc("Contact"); diff --git a/erpnext/setup/doctype/naming_series/naming_series.py b/erpnext/setup/doctype/naming_series/naming_series.py index 56be00661e..6d1b7e9f2b 100644 --- a/erpnext/setup/doctype/naming_series/naming_series.py +++ b/erpnext/setup/doctype/naming_series/naming_series.py @@ -19,7 +19,6 @@ class NamingSeries(Document): prefixes = "" for d in doctypes: - print d try: options = self.get_options(d) except frappe.DoesNotExistError: From 7b822abcd65963afb861b8eb875f6f0f37f465e6 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 31 Dec 2014 14:42:23 +0530 Subject: [PATCH 7/8] [desktop] new icons --- erpnext/config/desktop.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/erpnext/config/desktop.py b/erpnext/config/desktop.py index ce9b25503b..94d784172d 100644 --- a/erpnext/config/desktop.py +++ b/erpnext/config/desktop.py @@ -4,54 +4,63 @@ def get_data(): return { "Accounts": { "color": "#3498db", - "icon": "icon-money", + "icon": "octicon octicon-repo", "type": "module" }, "Buying": { "color": "#c0392b", "icon": "icon-shopping-cart", + "icon": "octicon octicon-briefcase", "type": "module" }, "HR": { "color": "#2ecc71", "icon": "icon-group", + "icon": "octicon octicon-organization", "label": _("Human Resources"), "type": "module" }, "Manufacturing": { "color": "#7f8c8d", "icon": "icon-cogs", + "icon": "octicon octicon-gear", "type": "module" }, "POS": { "color": "#589494", "icon": "icon-th", + "icon": "octicon octicon-credit-card", "type": "page", "link": "pos" }, "Projects": { "color": "#8e44ad", "icon": "icon-puzzle-piece", + "icon": "octicon octicon-rocket", "type": "module" }, "Selling": { "color": "#1abc9c", "icon": "icon-tag", + "icon": "octicon octicon-tag", "type": "module" }, "Stock": { "color": "#f39c12", "icon": "icon-truck", + "icon": "octicon octicon-package", "type": "module" }, "Support": { "color": "#2c3e50", "icon": "icon-phone", + "icon": "octicon octicon-issue-opened", "type": "module" }, "Shopping Cart": { "color": "#B7E090", "icon": "icon-shopping-cart", + "icon": "octicon octicon-gear", "label": _("Shopping Cart"), "link": "Form/Shopping Cart Settings", "type": "module" From ee4b8bee338b9b582f59b28ad68a67cd970ff962 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 31 Dec 2014 15:01:48 +0530 Subject: [PATCH 8/8] Revert "[patches] removed 4.0 patches" This reverts commit 6f7cba8d730bcc3a7ac6d7102cce0a8369419956. --- erpnext/patches/v4_0/__init__.py | 0 .../patches/v4_0/apply_user_permissions.py | 51 ++++++++ erpnext/patches/v4_0/countrywise_coa.py | 29 +++++ ...custom_fields_for_india_specific_fields.py | 63 ++++++++++ .../v4_0/create_price_list_if_missing.py | 35 ++++++ .../v4_0/customer_discount_to_pricing_rule.py | 33 ++++++ erpnext/patches/v4_0/fields_to_be_renamed.py | 109 ++++++++++++++++++ erpnext/patches/v4_0/fix_address_template.py | 12 ++ .../patches/v4_0/fix_case_of_hr_module_def.py | 13 +++ erpnext/patches/v4_0/fix_contact_address.py | 12 ++ erpnext/patches/v4_0/fix_employee_user_id.py | 23 ++++ .../global_defaults_to_system_settings.py | 39 +++++++ erpnext/patches/v4_0/import_country_codes.py | 13 +++ .../v4_0/map_charge_to_taxes_and_charges.py | 16 +++ .../move_warehouse_user_to_restrictions.py | 13 +++ erpnext/patches/v4_0/new_address_template.py | 13 +++ .../patches/v4_0/reload_sales_print_format.py | 8 ++ .../remove_employee_role_if_no_employee.py | 18 +++ .../patches/v4_0/remove_module_home_pages.py | 10 ++ .../patches/v4_0/rename_sitemap_to_route.py | 16 +++ .../v4_0/reset_permissions_for_masters.py | 20 ++++ .../patches/v4_0/save_default_letterhead.py | 13 +++ .../v4_0/set_naming_series_property_setter.py | 98 ++++++++++++++++ .../set_pricing_rule_for_buying_or_selling.py | 13 +++ erpnext/patches/v4_0/split_email_settings.py | 67 +++++++++++ .../patches/v4_0/update_account_root_type.py | 34 ++++++ ...custom_print_formats_for_renamed_fields.py | 36 ++++++ ...to_sales_person_in_maintenance_schedule.py | 12 ++ ...harges_in_custom_purchase_print_formats.py | 12 ++ .../v4_0/update_tax_amount_after_discount.py | 20 ++++ .../patches/v4_0/update_user_properties.py | 51 ++++++++ .../v4_0/update_users_report_view_settings.py | 12 ++ erpnext/patches/v4_0/validate_v3_patch.py | 11 ++ erpnext/patches/v4_1/__init__.py | 0 .../v4_1/fix_delivery_and_billing_status.py | 12 ++ erpnext/patches/v4_1/fix_jv_remarks.py | 21 ++++ .../v4_1/fix_sales_order_delivered_status.py | 15 +++ .../patches/v4_1/set_outgoing_email_footer.py | 12 ++ erpnext/patches/v4_2/__init__.py | 0 .../patches/v4_2/add_currency_turkish_lira.py | 11 ++ erpnext/patches/v4_2/default_website_style.py | 10 ++ .../patches/v4_2/delete_old_print_formats.py | 23 ++++ .../patches/v4_2/fix_account_master_type.py | 12 ++ .../fix_gl_entries_for_stock_transactions.py | 52 +++++++++ erpnext/patches/v4_2/party_model.py | 97 ++++++++++++++++ erpnext/patches/v4_2/recalculate_bom_cost.py | 16 +++ .../v4_2/repost_stock_reconciliation.py | 31 +++++ .../v4_2/seprate_manufacture_and_repack.py | 9 ++ erpnext/patches/v4_2/set_company_country.py | 15 +++ erpnext/patches/v4_2/toggle_rounded_total.py | 9 ++ .../patches/v4_2/update_project_milestones.py | 8 ++ .../v4_2/update_requested_and_ordered_qty.py | 24 ++++ .../update_sales_order_invoice_field_name.py | 6 + 53 files changed, 1308 insertions(+) create mode 100644 erpnext/patches/v4_0/__init__.py create mode 100644 erpnext/patches/v4_0/apply_user_permissions.py create mode 100644 erpnext/patches/v4_0/countrywise_coa.py create mode 100644 erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py create mode 100644 erpnext/patches/v4_0/create_price_list_if_missing.py create mode 100644 erpnext/patches/v4_0/customer_discount_to_pricing_rule.py create mode 100644 erpnext/patches/v4_0/fields_to_be_renamed.py create mode 100644 erpnext/patches/v4_0/fix_address_template.py create mode 100644 erpnext/patches/v4_0/fix_case_of_hr_module_def.py create mode 100644 erpnext/patches/v4_0/fix_contact_address.py create mode 100644 erpnext/patches/v4_0/fix_employee_user_id.py create mode 100644 erpnext/patches/v4_0/global_defaults_to_system_settings.py create mode 100644 erpnext/patches/v4_0/import_country_codes.py create mode 100644 erpnext/patches/v4_0/map_charge_to_taxes_and_charges.py create mode 100644 erpnext/patches/v4_0/move_warehouse_user_to_restrictions.py create mode 100644 erpnext/patches/v4_0/new_address_template.py create mode 100644 erpnext/patches/v4_0/reload_sales_print_format.py create mode 100644 erpnext/patches/v4_0/remove_employee_role_if_no_employee.py create mode 100644 erpnext/patches/v4_0/remove_module_home_pages.py create mode 100644 erpnext/patches/v4_0/rename_sitemap_to_route.py create mode 100644 erpnext/patches/v4_0/reset_permissions_for_masters.py create mode 100644 erpnext/patches/v4_0/save_default_letterhead.py create mode 100644 erpnext/patches/v4_0/set_naming_series_property_setter.py create mode 100644 erpnext/patches/v4_0/set_pricing_rule_for_buying_or_selling.py create mode 100644 erpnext/patches/v4_0/split_email_settings.py create mode 100644 erpnext/patches/v4_0/update_account_root_type.py create mode 100644 erpnext/patches/v4_0/update_custom_print_formats_for_renamed_fields.py create mode 100644 erpnext/patches/v4_0/update_incharge_name_to_sales_person_in_maintenance_schedule.py create mode 100644 erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py create mode 100644 erpnext/patches/v4_0/update_tax_amount_after_discount.py create mode 100644 erpnext/patches/v4_0/update_user_properties.py create mode 100644 erpnext/patches/v4_0/update_users_report_view_settings.py create mode 100644 erpnext/patches/v4_0/validate_v3_patch.py create mode 100644 erpnext/patches/v4_1/__init__.py create mode 100644 erpnext/patches/v4_1/fix_delivery_and_billing_status.py create mode 100644 erpnext/patches/v4_1/fix_jv_remarks.py create mode 100644 erpnext/patches/v4_1/fix_sales_order_delivered_status.py create mode 100644 erpnext/patches/v4_1/set_outgoing_email_footer.py create mode 100644 erpnext/patches/v4_2/__init__.py create mode 100644 erpnext/patches/v4_2/add_currency_turkish_lira.py create mode 100644 erpnext/patches/v4_2/default_website_style.py create mode 100644 erpnext/patches/v4_2/delete_old_print_formats.py create mode 100644 erpnext/patches/v4_2/fix_account_master_type.py create mode 100644 erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py create mode 100644 erpnext/patches/v4_2/party_model.py create mode 100644 erpnext/patches/v4_2/recalculate_bom_cost.py create mode 100644 erpnext/patches/v4_2/repost_stock_reconciliation.py create mode 100644 erpnext/patches/v4_2/seprate_manufacture_and_repack.py create mode 100644 erpnext/patches/v4_2/set_company_country.py create mode 100644 erpnext/patches/v4_2/toggle_rounded_total.py create mode 100644 erpnext/patches/v4_2/update_project_milestones.py create mode 100644 erpnext/patches/v4_2/update_requested_and_ordered_qty.py create mode 100644 erpnext/patches/v4_2/update_sales_order_invoice_field_name.py diff --git a/erpnext/patches/v4_0/__init__.py b/erpnext/patches/v4_0/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/patches/v4_0/apply_user_permissions.py b/erpnext/patches/v4_0/apply_user_permissions.py new file mode 100644 index 0000000000..7dae02f785 --- /dev/null +++ b/erpnext/patches/v4_0/apply_user_permissions.py @@ -0,0 +1,51 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +from erpnext.hr.doctype.employee.employee import EmployeeUserDisabledError + +def execute(): + update_hr_permissions() + update_permissions() + remove_duplicate_user_permissions() + frappe.clear_cache() + +def update_hr_permissions(): + from frappe.core.page.user_permissions import user_permissions + + # add set user permissions rights to HR Manager + frappe.db.sql("""update `tabDocPerm` set `set_user_permissions`=1 where parent in ('Employee', 'Leave Application') + and role='HR Manager' and permlevel=0 and `read`=1""") + + # apply user permissions on Employee and Leave Application + frappe.db.sql("""update `tabDocPerm` set `apply_user_permissions`=1 where parent in ('Employee', 'Leave Application') + and role in ('Employee', 'Leave Approver') and permlevel=0 and `read`=1""") + + frappe.clear_cache() + + # save employees to run on_update events + for employee in frappe.db.sql_list("""select name from `tabEmployee` where docstatus < 2"""): + try: + emp = frappe.get_doc("Employee", employee) + emp.ignore_mandatory = True + emp.save() + except EmployeeUserDisabledError: + pass + +def update_permissions(): + # clear match conditions other than owner + frappe.db.sql("""update tabDocPerm set `match`='' + where ifnull(`match`,'') not in ('', 'owner')""") + +def remove_duplicate_user_permissions(): + # remove duplicate user_permissions (if they exist) + for d in frappe.db.sql("""select parent, defkey, defvalue, + count(*) as cnt from tabDefaultValue + where parent not in ('__global', '__default') + group by parent, defkey, defvalue""", as_dict=1): + if d.cnt > 1: + # order by parenttype so that user permission does not get removed! + frappe.db.sql("""delete from tabDefaultValue where `parent`=%s and `defkey`=%s and + `defvalue`=%s order by parenttype limit %s""", (d.parent, d.defkey, d.defvalue, d.cnt-1)) + diff --git a/erpnext/patches/v4_0/countrywise_coa.py b/erpnext/patches/v4_0/countrywise_coa.py new file mode 100644 index 0000000000..f11bdb7dbd --- /dev/null +++ b/erpnext/patches/v4_0/countrywise_coa.py @@ -0,0 +1,29 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.reload_doc("setup", 'doctype', "company") + frappe.reload_doc("accounts", 'doctype', "account") + + frappe.db.sql("""update tabAccount set account_type='Cash' + where account_type='Bank or Cash' and account_name in ('Cash', 'Cash In Hand')""") + + frappe.db.sql("""update tabAccount set account_type='Stock' + where account_name = 'Stock Assets'""") + + ac_types = {"Fixed Asset Account": "Fixed Asset", "Bank or Cash": "Bank"} + for old, new in ac_types.items(): + frappe.db.sql("""update tabAccount set account_type=%s + where account_type=%s""", (new, old)) + + try: + frappe.db.sql("""update `tabAccount` set report_type = + if(is_pl_account='Yes', 'Profit and Loss', 'Balance Sheet')""") + + frappe.db.sql("""update `tabAccount` set balance_must_be=debit_or_credit + where ifnull(allow_negative_balance, 0) = 0""") + except: + pass diff --git a/erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py b/erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py new file mode 100644 index 0000000000..5bca5e6962 --- /dev/null +++ b/erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py @@ -0,0 +1,63 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +from frappe.custom.doctype.custom_field.custom_field import create_custom_field_if_values_exist + +def execute(): + frappe.reload_doc("stock", "doctype", "purchase_receipt") + frappe.reload_doc("hr", "doctype", "employee") + frappe.reload_doc("hr", "doctype", "salary_slip") + + india_specific_fields = { + "Purchase Receipt": [{ + "label": "Supplier Shipment No", + "fieldname": "challan_no", + "fieldtype": "Data", + "insert_after": "is_subcontracted" + }, { + "label": "Supplier Shipment Date", + "fieldname": "challan_date", + "fieldtype": "Date", + "insert_after": "is_subcontracted" + }], + "Employee": [{ + "label": "PAN Number", + "fieldname": "pan_number", + "fieldtype": "Data", + "insert_after": "company_email" + }, { + "label": "Gratuity LIC Id", + "fieldname": "gratuity_lic_id", + "fieldtype": "Data", + "insert_after": "company_email" + }, { + "label": "Esic Card No", + "fieldname": "esic_card_no", + "fieldtype": "Data", + "insert_after": "bank_ac_no" + }, { + "label": "PF Number", + "fieldname": "pf_number", + "fieldtype": "Data", + "insert_after": "bank_ac_no" + }], + "Salary Slip": [{ + "label": "Esic No", + "fieldname": "esic_no", + "fieldtype": "Data", + "insert_after": "letter_head", + "permlevel": 1 + }, { + "label": "PF Number", + "fieldname": "pf_no", + "fieldtype": "Data", + "insert_after": "letter_head", + "permlevel": 1 + }] + } + + for dt, docfields in india_specific_fields.items(): + for df in docfields: + create_custom_field_if_values_exist(dt, df) diff --git a/erpnext/patches/v4_0/create_price_list_if_missing.py b/erpnext/patches/v4_0/create_price_list_if_missing.py new file mode 100644 index 0000000000..f65b7cb571 --- /dev/null +++ b/erpnext/patches/v4_0/create_price_list_if_missing.py @@ -0,0 +1,35 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +from frappe import _ +from frappe.utils.nestedset import get_root_of + +def execute(): + # setup not complete + if not frappe.db.sql("""select name from tabCompany limit 1"""): + return + + if "shopping_cart" in frappe.get_installed_apps(): + frappe.reload_doc("shopping_cart", "doctype", "shopping_cart_settings") + + if not frappe.db.sql("select name from `tabPrice List` where buying=1"): + create_price_list(_("Standard Buying"), buying=1) + + if not frappe.db.sql("select name from `tabPrice List` where selling=1"): + create_price_list(_("Standard Selling"), selling=1) + +def create_price_list(pl_name, buying=0, selling=0): + price_list = frappe.get_doc({ + "doctype": "Price List", + "price_list_name": pl_name, + "enabled": 1, + "buying": buying, + "selling": selling, + "currency": frappe.db.get_default("currency"), + "valid_for_territories": [{ + "territory": get_root_of("Territory") + }] + }) + price_list.insert() diff --git a/erpnext/patches/v4_0/customer_discount_to_pricing_rule.py b/erpnext/patches/v4_0/customer_discount_to_pricing_rule.py new file mode 100644 index 0000000000..bd27174a0e --- /dev/null +++ b/erpnext/patches/v4_0/customer_discount_to_pricing_rule.py @@ -0,0 +1,33 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +from frappe.utils.nestedset import get_root_of + +def execute(): + frappe.reload_doc("accounts", "doctype", "pricing_rule") + + frappe.db.auto_commit_on_many_writes = True + + default_item_group = get_root_of("Item Group") + + for d in frappe.db.sql("""select * from `tabCustomer Discount` + where ifnull(parent, '') != ''""", as_dict=1): + if not d.discount: + continue + + frappe.get_doc({ + "doctype": "Pricing Rule", + "apply_on": "Item Group", + "item_group": d.item_group or default_item_group, + "applicable_for": "Customer", + "customer": d.parent, + "price_or_discount": "Discount Percentage", + "discount_percentage": d.discount, + "selling": 1 + }).insert() + + frappe.db.auto_commit_on_many_writes = False + + frappe.delete_doc("DocType", "Customer Discount") diff --git a/erpnext/patches/v4_0/fields_to_be_renamed.py b/erpnext/patches/v4_0/fields_to_be_renamed.py new file mode 100644 index 0000000000..642a0b49aa --- /dev/null +++ b/erpnext/patches/v4_0/fields_to_be_renamed.py @@ -0,0 +1,109 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model import rename_field +from frappe.modules import scrub, get_doctype_module + +rename_map = { + "Quotation Item": [ + ["ref_rate", "price_list_rate"], + ["base_ref_rate", "base_price_list_rate"], + ["adj_rate", "discount_percentage"], + ["export_rate", "rate"], + ["basic_rate", "base_rate"], + ["amount", "base_amount"], + ["export_amount", "amount"] + ], + + "Sales Order Item": [ + ["ref_rate", "price_list_rate"], + ["base_ref_rate", "base_price_list_rate"], + ["adj_rate", "discount_percentage"], + ["export_rate", "rate"], + ["basic_rate", "base_rate"], + ["amount", "base_amount"], + ["export_amount", "amount"], + ["reserved_warehouse", "warehouse"] + ], + + "Delivery Note Item": [ + ["ref_rate", "price_list_rate"], + ["base_ref_rate", "base_price_list_rate"], + ["adj_rate", "discount_percentage"], + ["export_rate", "rate"], + ["basic_rate", "base_rate"], + ["amount", "base_amount"], + ["export_amount", "amount"] + ], + + "Sales Invoice Item": [ + ["ref_rate", "price_list_rate"], + ["base_ref_rate", "base_price_list_rate"], + ["adj_rate", "discount_percentage"], + ["export_rate", "rate"], + ["basic_rate", "base_rate"], + ["amount", "base_amount"], + ["export_amount", "amount"] + ], + + "Supplier Quotation Item": [ + ["import_ref_rate", "price_list_rate"], + ["purchase_ref_rate", "base_price_list_rate"], + ["discount_rate", "discount_percentage"], + ["import_rate", "rate"], + ["purchase_rate", "base_rate"], + ["amount", "base_amount"], + ["import_amount", "amount"] + ], + + "Purchase Order Item": [ + ["import_ref_rate", "price_list_rate"], + ["purchase_ref_rate", "base_price_list_rate"], + ["discount_rate", "discount_percentage"], + ["import_rate", "rate"], + ["purchase_rate", "base_rate"], + ["amount", "base_amount"], + ["import_amount", "amount"] + ], + + "Purchase Receipt Item": [ + ["import_ref_rate", "price_list_rate"], + ["purchase_ref_rate", "base_price_list_rate"], + ["discount_rate", "discount_percentage"], + ["import_rate", "rate"], + ["purchase_rate", "base_rate"], + ["amount", "base_amount"], + ["import_amount", "amount"] + ], + + "Purchase Invoice Item": [ + ["import_ref_rate", "price_list_rate"], + ["purchase_ref_rate", "base_price_list_rate"], + ["discount_rate", "discount_percentage"], + ["import_rate", "rate"], + ["rate", "base_rate"], + ["amount", "base_amount"], + ["import_amount", "amount"], + ["expense_head", "expense_account"] + ], + + "Item": [ + ["purchase_account", "expense_account"], + ["default_sales_cost_center", "selling_cost_center"], + ["cost_center", "buying_cost_center"], + ["default_income_account", "income_account"], + ], + "Item Price": [ + ["ref_rate", "price_list_rate"] + ] +} + +def execute(): + for dn in rename_map: + frappe.reload_doc(get_doctype_module(dn), "doctype", scrub(dn)) + + for dt, field_list in rename_map.items(): + for field in field_list: + rename_field(dt, field[0], field[1]) diff --git a/erpnext/patches/v4_0/fix_address_template.py b/erpnext/patches/v4_0/fix_address_template.py new file mode 100644 index 0000000000..5aed489775 --- /dev/null +++ b/erpnext/patches/v4_0/fix_address_template.py @@ -0,0 +1,12 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors + +from __future__ import unicode_literals +import frappe + +def execute(): + missing_line = """{{ address_line1 }}
    """ + for name, template in frappe.db.sql("select name, template from `tabAddress Template`"): + if missing_line not in template: + d = frappe.get_doc("Address Template", name) + d.template = missing_line + d.template + d.save() diff --git a/erpnext/patches/v4_0/fix_case_of_hr_module_def.py b/erpnext/patches/v4_0/fix_case_of_hr_module_def.py new file mode 100644 index 0000000000..73b4e7f56c --- /dev/null +++ b/erpnext/patches/v4_0/fix_case_of_hr_module_def.py @@ -0,0 +1,13 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors + +from __future__ import unicode_literals +import frappe + +def execute(): + hr = frappe.db.get_value("Module Def", "HR") + if hr == "Hr": + frappe.rename_doc("Module Def", "Hr", "HR") + frappe.db.set_value("Module Def", "HR", "module_name", "HR") + + frappe.clear_cache() + frappe.setup_module_map() diff --git a/erpnext/patches/v4_0/fix_contact_address.py b/erpnext/patches/v4_0/fix_contact_address.py new file mode 100644 index 0000000000..91d1a0b0c6 --- /dev/null +++ b/erpnext/patches/v4_0/fix_contact_address.py @@ -0,0 +1,12 @@ +import frappe + +def execute(): + frappe.reload_doc("website", "doctype", "contact_us_settings") + address = frappe.db.get_value("Contact Us Settings", None, "address") + if address: + address = frappe.get_doc("Address", address) + contact = frappe.get_doc("Contact Us Settings", "Contact Us Settings") + for f in ("address_title", "address_line1", "address_line2", "city", "state", "country", "pincode"): + contact.set(f, address.get(f)) + + contact.save() \ No newline at end of file diff --git a/erpnext/patches/v4_0/fix_employee_user_id.py b/erpnext/patches/v4_0/fix_employee_user_id.py new file mode 100644 index 0000000000..d366fa4448 --- /dev/null +++ b/erpnext/patches/v4_0/fix_employee_user_id.py @@ -0,0 +1,23 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals + +import frappe +from frappe.utils import get_fullname + +def execute(): + for user_id in frappe.db.sql_list("""select distinct user_id from `tabEmployee` + where ifnull(user_id, '')!='' + group by user_id having count(name) > 1"""): + + fullname = get_fullname(user_id) + employee = frappe.db.get_value("Employee", {"employee_name": fullname, "user_id": user_id}) + + if employee: + frappe.db.sql("""update `tabEmployee` set user_id=null + where user_id=%s and name!=%s""", (user_id, employee)) + else: + count = frappe.db.sql("""select count(*) from `tabEmployee` where user_id=%s""", user_id)[0][0] + frappe.db.sql("""update `tabEmployee` set user_id=null + where user_id=%s limit %s""", (user_id, count - 1)) diff --git a/erpnext/patches/v4_0/global_defaults_to_system_settings.py b/erpnext/patches/v4_0/global_defaults_to_system_settings.py new file mode 100644 index 0000000000..57b21aea41 --- /dev/null +++ b/erpnext/patches/v4_0/global_defaults_to_system_settings.py @@ -0,0 +1,39 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# MIT License. See license.txt + +from __future__ import unicode_literals + +import frappe +from collections import Counter +from frappe.core.doctype.user.user import STANDARD_USERS + +def execute(): + frappe.reload_doc("core", "doctype", "system_settings") + system_settings = frappe.get_doc("System Settings") + + # set values from global_defauls + global_defaults = frappe.db.get_value("Global Defaults", None, + ["time_zone", "date_format", "number_format", "float_precision", "session_expiry"], as_dict=True) + + if global_defaults: + for key, val in global_defaults.items(): + if not system_settings.get(key): + system_settings.set(key, val) + + # language + if not system_settings.get("language"): + # find most common language + lang = frappe.db.sql_list("""select language from `tabUser` + where ifnull(language, '')!='' and language not like "Loading%%" and name not in ({standard_users})""".format( + standard_users=", ".join(["%s"]*len(STANDARD_USERS))), tuple(STANDARD_USERS)) + lang = Counter(lang).most_common(1) + lang = (len(lang) > 0) and lang[0][0] or "english" + + system_settings.language = lang + + system_settings.ignore_mandatory = True + system_settings.save() + + global_defaults = frappe.get_doc("Global Defaults") + global_defaults.ignore_mandatory = True + global_defaults.save() diff --git a/erpnext/patches/v4_0/import_country_codes.py b/erpnext/patches/v4_0/import_country_codes.py new file mode 100644 index 0000000000..e2e9f9d1f4 --- /dev/null +++ b/erpnext/patches/v4_0/import_country_codes.py @@ -0,0 +1,13 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# MIT License. See license.txt + +from __future__ import unicode_literals +import frappe +from frappe.geo.country_info import get_all +from erpnext.setup.install import import_country_and_currency + +def execute(): + frappe.reload_doc("setup", "doctype", "country") + import_country_and_currency() + for name, country in get_all().iteritems(): + frappe.set_value("Country", name, "code", country.get("code")) \ No newline at end of file diff --git a/erpnext/patches/v4_0/map_charge_to_taxes_and_charges.py b/erpnext/patches/v4_0/map_charge_to_taxes_and_charges.py new file mode 100644 index 0000000000..a814245179 --- /dev/null +++ b/erpnext/patches/v4_0/map_charge_to_taxes_and_charges.py @@ -0,0 +1,16 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + # udpate sales cycle + for d in ['Sales Invoice', 'Sales Order', 'Quotation', 'Delivery Note']: + frappe.db.sql("""update `tab%s` set taxes_and_charges=charge""" % d) + + # udpate purchase cycle + for d in ['Purchase Invoice', 'Purchase Order', 'Supplier Quotation', 'Purchase Receipt']: + frappe.db.sql("""update `tab%s` set taxes_and_charges=purchase_other_charges""" % d) + + frappe.db.sql("""update `tabPurchase Taxes and Charges` set parentfield='other_charges'""") diff --git a/erpnext/patches/v4_0/move_warehouse_user_to_restrictions.py b/erpnext/patches/v4_0/move_warehouse_user_to_restrictions.py new file mode 100644 index 0000000000..35b3c8661d --- /dev/null +++ b/erpnext/patches/v4_0/move_warehouse_user_to_restrictions.py @@ -0,0 +1,13 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +import frappe.permissions + +def execute(): + for warehouse, user in frappe.db.sql("""select parent, user from `tabWarehouse User`"""): + frappe.permissions.add_user_permission("Warehouse", warehouse, user) + + frappe.delete_doc_if_exists("DocType", "Warehouse User") + frappe.reload_doc("stock", "doctype", "warehouse") diff --git a/erpnext/patches/v4_0/new_address_template.py b/erpnext/patches/v4_0/new_address_template.py new file mode 100644 index 0000000000..7a5dabc006 --- /dev/null +++ b/erpnext/patches/v4_0/new_address_template.py @@ -0,0 +1,13 @@ +import frappe + +def execute(): + frappe.reload_doc("utilities", "doctype", "address_template") + if not frappe.db.sql("select name from `tabAddress Template`"): + try: + d = frappe.new_doc("Address Template") + d.update({"country":frappe.db.get_default("country") or + frappe.db.get_value("Global Defaults", "Global Defaults", "country")}) + d.insert() + except: + print frappe.get_traceback() + diff --git a/erpnext/patches/v4_0/reload_sales_print_format.py b/erpnext/patches/v4_0/reload_sales_print_format.py new file mode 100644 index 0000000000..99184e36ef --- /dev/null +++ b/erpnext/patches/v4_0/reload_sales_print_format.py @@ -0,0 +1,8 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.reload_doc('accounts', 'Print Format', 'POS Invoice') diff --git a/erpnext/patches/v4_0/remove_employee_role_if_no_employee.py b/erpnext/patches/v4_0/remove_employee_role_if_no_employee.py new file mode 100644 index 0000000000..c1f368949f --- /dev/null +++ b/erpnext/patches/v4_0/remove_employee_role_if_no_employee.py @@ -0,0 +1,18 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +import frappe.permissions + +def execute(): + for user in frappe.db.sql_list("select distinct parent from `tabUserRole` where role='Employee'"): + # if employee record does not exists, remove employee role! + if not frappe.db.get_value("Employee", {"user_id": user}): + try: + user = frappe.get_doc("User", user) + for role in user.get("user_roles", {"role": "Employee"}): + user.get("user_roles").remove(role) + user.save() + except frappe.DoesNotExistError: + pass diff --git a/erpnext/patches/v4_0/remove_module_home_pages.py b/erpnext/patches/v4_0/remove_module_home_pages.py new file mode 100644 index 0000000000..f7407a6c05 --- /dev/null +++ b/erpnext/patches/v4_0/remove_module_home_pages.py @@ -0,0 +1,10 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + for page in ("accounts-home", "website-home", "support-home", "stock-home", "selling-home", "projects-home", + "manufacturing-home", "hr-home", "buying-home"): + frappe.delete_doc("Page", page) \ No newline at end of file diff --git a/erpnext/patches/v4_0/rename_sitemap_to_route.py b/erpnext/patches/v4_0/rename_sitemap_to_route.py new file mode 100644 index 0000000000..b933e364b4 --- /dev/null +++ b/erpnext/patches/v4_0/rename_sitemap_to_route.py @@ -0,0 +1,16 @@ +import frappe +import frappe.model + +def execute(): + frappe.reload_doc("setup", "doctype", "item_group") + frappe.reload_doc("stock", "doctype", "item") + frappe.reload_doc("setup", "doctype", "sales_partner") + + try: + frappe.model.rename_field("Item Group", "parent_website_sitemap", "parent_website_route") + frappe.model.rename_field("Item", "parent_website_sitemap", "parent_website_route") + frappe.model.rename_field("Sales Partner", "parent_website_sitemap", + "parent_website_route") + except Exception, e: + if e.args[0]!=1054: + raise \ No newline at end of file diff --git a/erpnext/patches/v4_0/reset_permissions_for_masters.py b/erpnext/patches/v4_0/reset_permissions_for_masters.py new file mode 100644 index 0000000000..b0bc1230b0 --- /dev/null +++ b/erpnext/patches/v4_0/reset_permissions_for_masters.py @@ -0,0 +1,20 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +from frappe.permissions import reset_perms + +def execute(): + for doctype in ("About Us Settings", "Accounts Settings", "Activity Type", + "Blog Category", "Blog Settings", "Blogger", "Branch", "Brand", "Buying Settings", + "Comment", "Communication", "Company", "Contact Us Settings", + "Country", "Currency", "Currency Exchange", "Deduction Type", "Department", + "Designation", "Earning Type", "Event", "Feed", "File Data", "Fiscal Year", + "HR Settings", "Industry Type", "Leave Type", "Letter Head", + "Mode of Payment", "Module Def", "Naming Series", "POS Setting", "Print Heading", + "Report", "Role", "Selling Settings", "Stock Settings", "Supplier Type", "UOM"): + try: + reset_perms(doctype) + except: + print "Error resetting perms for", doctype + raise diff --git a/erpnext/patches/v4_0/save_default_letterhead.py b/erpnext/patches/v4_0/save_default_letterhead.py new file mode 100644 index 0000000000..a6db0cdece --- /dev/null +++ b/erpnext/patches/v4_0/save_default_letterhead.py @@ -0,0 +1,13 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + """save default letterhead to set default_letter_head_content""" + try: + letter_head = frappe.get_doc("Letter Head", {"is_default": 1}) + letter_head.save() + except frappe.DoesNotExistError: + pass diff --git a/erpnext/patches/v4_0/set_naming_series_property_setter.py b/erpnext/patches/v4_0/set_naming_series_property_setter.py new file mode 100644 index 0000000000..7ebcc1e1f0 --- /dev/null +++ b/erpnext/patches/v4_0/set_naming_series_property_setter.py @@ -0,0 +1,98 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals + +import frappe +from frappe.custom.doctype.property_setter.property_setter import make_property_setter + +doctype_series_map = { + 'Attendance': 'ATT-', + 'C-Form': 'C-FORM-', + 'Customer': 'CUST-', + 'Customer Issue': 'CI-', + 'Delivery Note': 'DN-', + 'Installation Note': 'IN-', + 'Item': 'ITEM-', + 'Journal Voucher': 'JV-', + 'Lead': 'LEAD-', + 'Opportunity': 'OPTY-', + 'Packing Slip': 'PS-', + 'Production Order': 'PRO-', + 'Purchase Invoice': 'PINV-', + 'Purchase Order': 'PO-', + 'Purchase Receipt': 'PREC-', + 'Quality Inspection': 'QI-', + 'Quotation': 'QTN-', + 'Sales Invoice': 'SINV-', + 'Sales Order': 'SO-', + 'Stock Entry': 'STE-', + 'Supplier': 'SUPP-', + 'Supplier Quotation': 'SQTN-', + 'Issue': 'SUP-' +} + +def execute(): + series_to_set = get_series_to_set() + for doctype, opts in series_to_set.items(): + print "Setting naming series", doctype, opts + set_series(doctype, opts["options"], opts["default"]) + +def set_series(doctype, options, default): + make_property_setter(doctype, "naming_series", "options", options, "Text") + make_property_setter(doctype, "naming_series", "default", default, "Text") + +def get_series_to_set(): + series_to_set = {} + + for doctype, new_series in doctype_series_map.items(): + # you can't fix what does not exist :) + if not frappe.db.a_row_exists(doctype): + continue + + series_to_preserve = get_series_to_preserve(doctype, new_series) + + if not series_to_preserve: + continue + + default_series = get_default_series(doctype, new_series) + if not default_series: + continue + + existing_series = (frappe.get_meta(doctype).get_field("naming_series").options or "").split("\n") + existing_series = filter(None, [d.strip() for d in existing_series]) + + if (not (set(existing_series).difference(series_to_preserve) or set(series_to_preserve).difference(existing_series)) + and len(series_to_preserve)==len(existing_series)): + # print "No change for", doctype, ":", existing_series, "=", series_to_preserve + continue + + # set naming series property setter + series_to_preserve = list(set(series_to_preserve + existing_series)) + if new_series in series_to_preserve: + series_to_preserve.remove(new_series) + + if series_to_preserve: + series_to_set[doctype] = {"options": "\n".join(series_to_preserve), "default": default_series} + + return series_to_set + +def get_series_to_preserve(doctype, new_series): + series_to_preserve = frappe.db.sql_list("""select distinct naming_series from `tab{doctype}` + where ifnull(naming_series, '') not in ('', %s)""".format(doctype=doctype), new_series) + + series_to_preserve.sort() + + return series_to_preserve + +def get_default_series(doctype, new_series): + default_series = frappe.db.sql("""select naming_series from `tab{doctype}` where ifnull(naming_series, '') not in ('', %s) + and creation=(select max(creation) from `tab{doctype}` + where ifnull(naming_series, '') not in ('', %s)) order by creation desc limit 1""".format(doctype=doctype), + (new_series, new_series)) + + if not (default_series and default_series[0][0]): + print "[Skipping] Cannot guess which naming series to use for", doctype + return + + return default_series[0][0] diff --git a/erpnext/patches/v4_0/set_pricing_rule_for_buying_or_selling.py b/erpnext/patches/v4_0/set_pricing_rule_for_buying_or_selling.py new file mode 100644 index 0000000000..8be846ff16 --- /dev/null +++ b/erpnext/patches/v4_0/set_pricing_rule_for_buying_or_selling.py @@ -0,0 +1,13 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.reload_doc("accounts", "doctype", "pricing_rule") + frappe.db.sql("""update `tabPricing Rule` set selling=1 where ifnull(applicable_for, '') in + ('', 'Customer', 'Customer Group', 'Territory', 'Sales Partner', 'Campaign')""") + + frappe.db.sql("""update `tabPricing Rule` set buying=1 where ifnull(applicable_for, '') in + ('', 'Supplier', 'Supplier Type')""") diff --git a/erpnext/patches/v4_0/split_email_settings.py b/erpnext/patches/v4_0/split_email_settings.py new file mode 100644 index 0000000000..c04e1d5246 --- /dev/null +++ b/erpnext/patches/v4_0/split_email_settings.py @@ -0,0 +1,67 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + print "WARNING!!!! Email Settings not migrated. Please setup your email again." + + # this will happen if you are migrating very old accounts + # comment out this line below and remember to create new Email Accounts + # for incoming and outgoing mails + raise Exception + + return + + + frappe.reload_doc("core", "doctype", "outgoing_email_settings") + frappe.reload_doc("support", "doctype", "support_email_settings") + + email_settings = get_email_settings() + map_outgoing_email_settings(email_settings) + map_support_email_settings(email_settings) + + +def map_outgoing_email_settings(email_settings): + outgoing_email_settings = frappe.get_doc("Outgoing Email Settings") + for fieldname in (("outgoing_mail_server", "mail_server"), + "use_ssl", "mail_port", "mail_login", "mail_password", + "always_use_login_id_as_sender", "auto_email_id"): + + if isinstance(fieldname, tuple): + from_fieldname, to_fieldname = fieldname + else: + from_fieldname = to_fieldname = fieldname + + outgoing_email_settings.set(to_fieldname, email_settings.get(from_fieldname)) + + outgoing_email_settings._fix_numeric_types() + outgoing_email_settings.save() + +def map_support_email_settings(email_settings): + support_email_settings = frappe.get_doc("Support Email Settings") + + for fieldname in ("sync_support_mails", "support_email", + ("support_host", "mail_server"), + ("support_use_ssl", "use_ssl"), + ("support_username", "mail_login"), + ("support_password", "mail_password"), + "support_signature", "send_autoreply", "support_autoreply"): + + if isinstance(fieldname, tuple): + from_fieldname, to_fieldname = fieldname + else: + from_fieldname = to_fieldname = fieldname + + support_email_settings.set(to_fieldname, email_settings.get(from_fieldname)) + + support_email_settings._fix_numeric_types() + support_email_settings.save() + +def get_email_settings(): + ret = {} + for field, value in frappe.db.sql("select field, value from tabSingles where doctype='Email Settings'"): + ret[field] = value + return ret + diff --git a/erpnext/patches/v4_0/update_account_root_type.py b/erpnext/patches/v4_0/update_account_root_type.py new file mode 100644 index 0000000000..10f6cda3c8 --- /dev/null +++ b/erpnext/patches/v4_0/update_account_root_type.py @@ -0,0 +1,34 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.reload_doc("accounts", "doctype", "account") + + account_table_columns = frappe.db.get_table_columns("Account") + if "debit_or_credit" in account_table_columns and "is_pl_account" in account_table_columns: + frappe.db.sql("""UPDATE tabAccount + SET root_type = CASE + WHEN (debit_or_credit='Debit' and is_pl_account = 'No') THEN 'Asset' + WHEN (debit_or_credit='Credit' and is_pl_account = 'No') THEN 'Liability' + WHEN (debit_or_credit='Debit' and is_pl_account = 'Yes') THEN 'Expense' + WHEN (debit_or_credit='Credit' and is_pl_account = 'Yes') THEN 'Income' + END + WHERE ifnull(parent_account, '') = '' + """) + + else: + for key, root_type in (("asset", "Asset"), ("liabilities", "Liability"), ("expense", "Expense"), + ("income", "Income")): + frappe.db.sql("""update tabAccount set root_type=%s where name like %s + and ifnull(parent_account, '')=''""", (root_type, "%" + key + "%")) + + for root in frappe.db.sql("""SELECT name, lft, rgt, root_type FROM `tabAccount` + WHERE ifnull(parent_account, '')=''""", as_dict=True): + if root.root_type: + frappe.db.sql("""UPDATE tabAccount SET root_type=%s WHERE lft>%s and rgt<%s""", + (root.root_type, root.lft, root.rgt)) + else: + print b"Root type not found for {0}".format(root.name.encode("utf-8")) diff --git a/erpnext/patches/v4_0/update_custom_print_formats_for_renamed_fields.py b/erpnext/patches/v4_0/update_custom_print_formats_for_renamed_fields.py new file mode 100644 index 0000000000..60d45cf6a6 --- /dev/null +++ b/erpnext/patches/v4_0/update_custom_print_formats_for_renamed_fields.py @@ -0,0 +1,36 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +import re + +def execute(): + # NOTE: sequence is important + fields_list = ( + ("amount", "base_amount"), + ("ref_rate", "price_list_rate"), + ("base_ref_rate", "base_price_list_rate"), + ("adj_rate", "discount_percentage"), + ("export_rate", "rate"), + ("basic_rate", "base_rate"), + ("export_amount", "amount"), + ("reserved_warehouse", "warehouse"), + ("import_ref_rate", "price_list_rate"), + ("purchase_ref_rate", "base_price_list_rate"), + ("discount_rate", "discount_percentage"), + ("import_rate", "rate"), + ("purchase_rate", "base_rate"), + ("import_amount", "amount") + ) + + condition = " or ".join("""html like "%%{}%%" """.format(d[0].replace("_", "\\_")) for d in fields_list + if d[0] != "amount") + + for name, html in frappe.db.sql("""select name, html from `tabPrint Format` + where standard = 'No' and ({}) and html not like '%%frappe.%%'""".format(condition)): + html = html.replace("wn.", "frappe.") + for from_field, to_field in fields_list: + html = re.sub(r"\b{}\b".format(from_field), to_field, html) + + frappe.db.set_value("Print Format", name, "html", html) diff --git a/erpnext/patches/v4_0/update_incharge_name_to_sales_person_in_maintenance_schedule.py b/erpnext/patches/v4_0/update_incharge_name_to_sales_person_in_maintenance_schedule.py new file mode 100644 index 0000000000..11f0090552 --- /dev/null +++ b/erpnext/patches/v4_0/update_incharge_name_to_sales_person_in_maintenance_schedule.py @@ -0,0 +1,12 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.reload_doc("support", "doctype", "maintenance_schedule_detail") + frappe.reload_doc("support", "doctype", "maintenance_schedule_item") + + frappe.db.sql("""update `tabMaintenance Schedule Detail` set sales_person=incharge_name""") + frappe.db.sql("""update `tabMaintenance Schedule Item` set sales_person=incharge_name""") \ No newline at end of file diff --git a/erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py b/erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py new file mode 100644 index 0000000000..c0f9ee008f --- /dev/null +++ b/erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py @@ -0,0 +1,12 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +import re + +def execute(): + for name, html in frappe.db.sql("""select name, html from `tabPrint Format` + where standard = 'No' and html like '%%purchase\\_tax\\_details%%'"""): + html = re.sub(r"\bpurchase_tax_details\b", "other_charges", html) + frappe.db.set_value("Print Format", name, "html", html) diff --git a/erpnext/patches/v4_0/update_tax_amount_after_discount.py b/erpnext/patches/v4_0/update_tax_amount_after_discount.py new file mode 100644 index 0000000000..e935bc4088 --- /dev/null +++ b/erpnext/patches/v4_0/update_tax_amount_after_discount.py @@ -0,0 +1,20 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.reload_doc("accounts", "doctype", "sales_taxes_and_charges") + docs_with_discount_amount = frappe._dict() + for dt in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]: + records = frappe.db.sql_list("""select name from `tab%s` + where ifnull(discount_amount, 0) > 0 and docstatus=1""" % dt) + docs_with_discount_amount[dt] = records + + for dt, discounted_records in docs_with_discount_amount.items(): + frappe.db.sql("""update `tabSales Taxes and Charges` + set tax_amount_after_discount_amount = tax_amount + where parenttype = %s and parent not in (%s)""" % + ('%s', ', '.join(['%s']*(len(discounted_records)+1))), + tuple([dt, ''] + discounted_records)) diff --git a/erpnext/patches/v4_0/update_user_properties.py b/erpnext/patches/v4_0/update_user_properties.py new file mode 100644 index 0000000000..a5b7bfd185 --- /dev/null +++ b/erpnext/patches/v4_0/update_user_properties.py @@ -0,0 +1,51 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +import frappe.permissions +import frappe.defaults + +def execute(): + frappe.reload_doc("core", "doctype", "docfield") + frappe.reload_doc("hr", "doctype", "employee") + + set_print_email_permissions() + migrate_user_properties_to_user_permissions() + + frappe.clear_cache() + +def migrate_user_properties_to_user_permissions(): + for d in frappe.db.sql("""select parent, defkey, defvalue from tabDefaultValue + where parent not in ('__global', '__default')""", as_dict=True): + df = frappe.db.sql("""select options from tabDocField + where fieldname=%s and fieldtype='Link'""", d.defkey, as_dict=True) + + if df: + frappe.db.sql("""update tabDefaultValue + set defkey=%s, parenttype='User Permission' + where defkey=%s and + parent not in ('__global', '__default')""", (df[0].options, d.defkey)) + +def set_print_email_permissions(): + # reset Page perms + from frappe.core.page.permission_manager.permission_manager import reset + reset("Page") + reset("Report") + + if "allow_print" not in frappe.db.get_table_columns("DocType"): + return + + # patch to move print, email into DocPerm + # NOTE: allow_print and allow_email are misnamed. They were used to hide print / hide email + for doctype, hide_print, hide_email in frappe.db.sql("""select name, ifnull(allow_print, 0), ifnull(allow_email, 0) + from `tabDocType` where ifnull(issingle, 0)=0 and ifnull(istable, 0)=0 and + (ifnull(allow_print, 0)=0 or ifnull(allow_email, 0)=0)"""): + + if not hide_print: + frappe.db.sql("""update `tabDocPerm` set `print`=1 + where permlevel=0 and `read`=1 and parent=%s""", doctype) + + if not hide_email: + frappe.db.sql("""update `tabDocPerm` set `email`=1 + where permlevel=0 and `read`=1 and parent=%s""", doctype) diff --git a/erpnext/patches/v4_0/update_users_report_view_settings.py b/erpnext/patches/v4_0/update_users_report_view_settings.py new file mode 100644 index 0000000000..8883dc26f5 --- /dev/null +++ b/erpnext/patches/v4_0/update_users_report_view_settings.py @@ -0,0 +1,12 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals + +from frappe.model import update_users_report_view_settings +from erpnext.patches.v4_0.fields_to_be_renamed import rename_map + +def execute(): + for dt, field_list in rename_map.items(): + for field in field_list: + update_users_report_view_settings(dt, field[0], field[1]) diff --git a/erpnext/patches/v4_0/validate_v3_patch.py b/erpnext/patches/v4_0/validate_v3_patch.py new file mode 100644 index 0000000000..21258b6d6d --- /dev/null +++ b/erpnext/patches/v4_0/validate_v3_patch.py @@ -0,0 +1,11 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + from frappe.modules.patch_handler import executed + last_v3_patch = 'patches.1401.fix_pos_outstanding' + if not executed(last_v3_patch): + raise Exception, "site not ready to migrate to version 4" diff --git a/erpnext/patches/v4_1/__init__.py b/erpnext/patches/v4_1/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/patches/v4_1/fix_delivery_and_billing_status.py b/erpnext/patches/v4_1/fix_delivery_and_billing_status.py new file mode 100644 index 0000000000..2dbc825085 --- /dev/null +++ b/erpnext/patches/v4_1/fix_delivery_and_billing_status.py @@ -0,0 +1,12 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.db.sql("""update `tabSales Order` set delivery_status = 'Not Delivered' + where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0 and ifnull(docstatus, 0) in (0, 1)""") + + frappe.db.sql("""update `tabSales Order` set billing_status = 'Not Billed' + where billing_status = 'Billed' and ifnull(per_billed, 0) = 0 and ifnull(docstatus, 0) in (0, 1)""") diff --git a/erpnext/patches/v4_1/fix_jv_remarks.py b/erpnext/patches/v4_1/fix_jv_remarks.py new file mode 100644 index 0000000000..3b2f342231 --- /dev/null +++ b/erpnext/patches/v4_1/fix_jv_remarks.py @@ -0,0 +1,21 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + reference_date = guess_reference_date() + for name in frappe.db.sql_list("""select name from `tabJournal Voucher` + where date(creation)>=%s""", reference_date): + jv = frappe.get_doc("Journal Voucher", name) + try: + jv.create_remarks() + except frappe.MandatoryError: + pass + else: + frappe.db.set_value("Journal Voucher", jv.name, "remark", jv.remark) + +def guess_reference_date(): + return (frappe.db.get_value("Patch Log", {"patch": "erpnext.patches.v4_0.validate_v3_patch"}, "creation") + or "2014-05-06") diff --git a/erpnext/patches/v4_1/fix_sales_order_delivered_status.py b/erpnext/patches/v4_1/fix_sales_order_delivered_status.py new file mode 100644 index 0000000000..f66d85657d --- /dev/null +++ b/erpnext/patches/v4_1/fix_sales_order_delivered_status.py @@ -0,0 +1,15 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + for si in frappe.db.sql_list("""select name + from `tabSales Invoice` + where ifnull(update_stock,0) = 1 and docstatus = 1 and exists( + select name from `tabSales Invoice Item` where parent=`tabSales Invoice`.name and + ifnull(so_detail, "") != "")"""): + + invoice = frappe.get_doc("Sales Invoice", si) + invoice.update_qty() diff --git a/erpnext/patches/v4_1/set_outgoing_email_footer.py b/erpnext/patches/v4_1/set_outgoing_email_footer.py new file mode 100644 index 0000000000..73d8d607f2 --- /dev/null +++ b/erpnext/patches/v4_1/set_outgoing_email_footer.py @@ -0,0 +1,12 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +from erpnext.setup.install import default_mail_footer + +def execute(): + return + mail_footer = frappe.db.get_default('mail_footer') or '' + mail_footer += default_mail_footer + frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "footer", mail_footer) diff --git a/erpnext/patches/v4_2/__init__.py b/erpnext/patches/v4_2/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/patches/v4_2/add_currency_turkish_lira.py b/erpnext/patches/v4_2/add_currency_turkish_lira.py new file mode 100644 index 0000000000..d768d58f3b --- /dev/null +++ b/erpnext/patches/v4_2/add_currency_turkish_lira.py @@ -0,0 +1,11 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +from frappe.geo.country_info import get_country_info +from erpnext.setup.install import add_country_and_currency + +def execute(): + country = get_country_info(country="Turkey") + add_country_and_currency("Turkey", country) diff --git a/erpnext/patches/v4_2/default_website_style.py b/erpnext/patches/v4_2/default_website_style.py new file mode 100644 index 0000000000..6f375b9ab5 --- /dev/null +++ b/erpnext/patches/v4_2/default_website_style.py @@ -0,0 +1,10 @@ +import frappe +from frappe.templates.pages.style_settings import default_properties + +def execute(): + frappe.reload_doc('website', 'doctype', 'style_settings') + style_settings = frappe.get_doc("Style Settings", "Style Settings") + if not style_settings.apply_style: + style_settings.update(default_properties) + style_settings.apply_style = 1 + style_settings.save() diff --git a/erpnext/patches/v4_2/delete_old_print_formats.py b/erpnext/patches/v4_2/delete_old_print_formats.py new file mode 100644 index 0000000000..75c3619ae4 --- /dev/null +++ b/erpnext/patches/v4_2/delete_old_print_formats.py @@ -0,0 +1,23 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + old_formats = ("Sales Invoice", "Sales Invoice Spartan", "Sales Invoice Modern", + "Sales Invoice Classic", + "Sales Order Spartan", "Sales Order Modern", "Sales Order Classic", + "Purchase Order Spartan", "Purchase Order Modern", "Purchase Order Classic", + "Quotation Spartan", "Quotation Modern", "Quotation Classic", + "Delivery Note Spartan", "Delivery Note Modern", "Delivery Note Classic") + + for fmt in old_formats: + # update property setter + for ps in frappe.db.sql_list("""select name from `tabProperty Setter` + where property='default_print_format' and value=%s""", fmt): + ps = frappe.get_doc("Property Setter", ps) + ps.value = "Standard" + ps.save(ignore_permissions = True) + + frappe.delete_doc_if_exists("Print Format", fmt) diff --git a/erpnext/patches/v4_2/fix_account_master_type.py b/erpnext/patches/v4_2/fix_account_master_type.py new file mode 100644 index 0000000000..d4603f24f5 --- /dev/null +++ b/erpnext/patches/v4_2/fix_account_master_type.py @@ -0,0 +1,12 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + for d in frappe.db.sql("""select name from `tabAccount` + where ifnull(master_type, '') not in ('Customer', 'Supplier', 'Employee', '') and docstatus=0"""): + ac = frappe.get_doc("Account", d[0]) + ac.master_type = None + ac.save() diff --git a/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py b/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py new file mode 100644 index 0000000000..a72b95480a --- /dev/null +++ b/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py @@ -0,0 +1,52 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +from frappe.utils import flt + +def execute(): + from erpnext.utilities.repost_stock import repost + repost(allow_zero_rate=True, only_actual=True) + + warehouse_account = frappe.db.sql("""select name, master_name from tabAccount + where ifnull(account_type, '') = 'Warehouse'""") + if warehouse_account: + warehouses = [d[1] for d in warehouse_account] + accounts = [d[0] for d in warehouse_account] + + stock_vouchers = frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no + from `tabStock Ledger Entry` sle + where sle.warehouse in (%s) + order by sle.posting_date""" % + ', '.join(['%s']*len(warehouses)), tuple(warehouses)) + + rejected = [] + for voucher_type, voucher_no in stock_vouchers: + stock_bal = frappe.db.sql("""select sum(stock_value_difference) from `tabStock Ledger Entry` + where voucher_type=%s and voucher_no =%s and warehouse in (%s)""" % + ('%s', '%s', ', '.join(['%s']*len(warehouses))), tuple([voucher_type, voucher_no] + warehouses)) + + account_bal = frappe.db.sql("""select ifnull(sum(ifnull(debit, 0) - ifnull(credit, 0)), 0) + from `tabGL Entry` + where voucher_type=%s and voucher_no =%s and account in (%s) + group by voucher_type, voucher_no""" % + ('%s', '%s', ', '.join(['%s']*len(accounts))), tuple([voucher_type, voucher_no] + accounts)) + + if stock_bal and account_bal and abs(flt(stock_bal[0][0]) - flt(account_bal[0][0])) > 0.1: + try: + print voucher_type, voucher_no, stock_bal[0][0], account_bal[0][0] + + frappe.db.sql("""delete from `tabGL Entry` + where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no)) + + voucher = frappe.get_doc(voucher_type, voucher_no) + voucher.make_gl_entries(repost_future_gle=False) + frappe.db.commit() + except Exception, e: + print frappe.get_traceback() + rejected.append([voucher_type, voucher_no]) + frappe.db.rollback() + + print "Failed to repost: " + print rejected diff --git a/erpnext/patches/v4_2/party_model.py b/erpnext/patches/v4_2/party_model.py new file mode 100644 index 0000000000..7bcb6ce2fd --- /dev/null +++ b/erpnext/patches/v4_2/party_model.py @@ -0,0 +1,97 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.reload_doc("accounts", "doctype", "account") + frappe.reload_doc("setup", "doctype", "company") + frappe.reload_doc("accounts", "doctype", "journal_voucher_detail") + frappe.reload_doc("accounts", "doctype", "gl_entry") + receivable_payable_accounts = create_receivable_payable_account() + if receivable_payable_accounts: + set_party_in_jv_and_gl_entry(receivable_payable_accounts) + delete_individual_party_account() + remove_customer_supplier_account_report() + + +def link_warehouse_account(): + frappe.db.sql("""update tabAccount set warehouse=master_name + where ifnull(account_type, '') = 'Warehouse' and ifnull(master_name, '') != ''""") + +def create_receivable_payable_account(): + receivable_payable_accounts = frappe._dict() + + def _create_account(args): + account = frappe.new_doc("Account") + account.group_or_ledger = "Ledger" + account.update(args) + account.insert() + + frappe.db.set_value("Company", args["company"], ("default_receivable_account" + if args["account_type"]=="Receivable" else "default_payable_account"), account.name) + + receivable_payable_accounts.setdefault(args["company"], {}).setdefault(args["account_type"], account.name) + + for company in frappe.db.sql_list("select name from tabCompany"): + _create_account({ + "account_name": "Debtors", + "account_type": "Receivable", + "company": company, + "parent_account": get_parent_account(company, "Customer") + }) + + _create_account({ + "account_name": "Creditors", + "account_type": "Payable", + "company": company, + "parent_account": get_parent_account(company, "Supplier") + }) + + return receivable_payable_accounts + +def get_parent_account(company, master_type): + parent_account = frappe.db.get_value("Company", company, + "receivables_group" if master_type=="Customer" else "payables_group") + if not parent_account: + parent_account = frappe.db.get_value("Account", {"company": company, + "account_name": "Accounts Receivable" if master_type=="Customer" else "Accounts Payable"}) + + if not parent_account: + parent_account = frappe.db.sql_list("""select parent_account from tabAccount + where company=%s and ifnull(master_type, '')=%s and ifnull(master_name, '')!='' limit 1""", + (company, master_type)) + parent_account = parent_account[0][0] if parent_account else None + + return parent_account + +def set_party_in_jv_and_gl_entry(receivable_payable_accounts): + accounts = frappe.db.sql("""select name, master_type, master_name, company from `tabAccount` + where ifnull(master_type, '') in ('Customer', 'Supplier') and ifnull(master_name, '') != ''""", as_dict=1) + + account_map = frappe._dict() + for d in accounts: + account_map.setdefault(d.name, d) + + if not account_map: + return + + for dt in ["Journal Voucher Detail", "GL Entry"]: + records = frappe.db.sql("""select name, account from `tab%s` where account in (%s)""" % + (dt, ", ".join(['%s']*len(account_map))), tuple(account_map.keys()), as_dict=1) + for d in records: + account_details = account_map.get(d.account, {}) + account_type = "Receivable" if account_details.get("master_type")=="Customer" else "Payable" + new_account = receivable_payable_accounts[account_details.get("company")][account_type] + + frappe.db.sql("update `tab{0}` set account=%s, party_type=%s, party=%s where name=%s".format(dt), + (new_account, account_details.get("master_type"), account_details.get("master_name"), d.name)) + +def delete_individual_party_account(): + frappe.db.sql("""delete from `tabAccount` where ifnull(master_type, '') in ('Customer', 'Supplier') + and ifnull(master_name, '') != ''""") + +def remove_customer_supplier_account_report(): + for d in ["Customer Account Head", "Supplier Account Head"]: + frappe.delete_doc("Report", d) diff --git a/erpnext/patches/v4_2/recalculate_bom_cost.py b/erpnext/patches/v4_2/recalculate_bom_cost.py new file mode 100644 index 0000000000..3a194ff195 --- /dev/null +++ b/erpnext/patches/v4_2/recalculate_bom_cost.py @@ -0,0 +1,16 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + for d in frappe.db.sql("select name from `tabBOM` where docstatus < 2"): + try: + document = frappe.get_doc('BOM', d[0]) + if document.docstatus == 1: + document.ignore_validate_update_after_submit = True + document.calculate_cost() + document.save() + except: + pass \ No newline at end of file diff --git a/erpnext/patches/v4_2/repost_stock_reconciliation.py b/erpnext/patches/v4_2/repost_stock_reconciliation.py new file mode 100644 index 0000000000..73cb36d487 --- /dev/null +++ b/erpnext/patches/v4_2/repost_stock_reconciliation.py @@ -0,0 +1,31 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +import json + +def execute(): + existing_allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock") + frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1) + + head_row = ["Item Code", "Warehouse", "Quantity", "Valuation Rate"] + stock_reco_to_be_reposted = [] + for d in frappe.db.sql("""select name, reconciliation_json from `tabStock Reconciliation` + where docstatus=1 and creation > '2014-03-01'""", as_dict=1): + data = json.loads(d.reconciliation_json) + for row in data[data.index(head_row)+1:]: + if row[3] in ["", None]: + stock_reco_to_be_reposted.append(d.name) + break + + for dn in stock_reco_to_be_reposted: + reco = frappe.get_doc("Stock Reconciliation", dn) + reco.docstatus = 2 + reco.on_cancel() + + reco.docstatus = 1 + reco.validate() + reco.on_submit() + + frappe.db.set_value("Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock) diff --git a/erpnext/patches/v4_2/seprate_manufacture_and_repack.py b/erpnext/patches/v4_2/seprate_manufacture_and_repack.py new file mode 100644 index 0000000000..5b36289bc9 --- /dev/null +++ b/erpnext/patches/v4_2/seprate_manufacture_and_repack.py @@ -0,0 +1,9 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.db.sql("""update `tabStock Entry` set purpose='Manufacture' where purpose='Manufacture/Repack' and ifnull(production_order,"")!="" """) + frappe.db.sql("""update `tabStock Entry` set purpose='Repack' where purpose='Manufacture/Repack' and ifnull(production_order,"")="" """) \ No newline at end of file diff --git a/erpnext/patches/v4_2/set_company_country.py b/erpnext/patches/v4_2/set_company_country.py new file mode 100644 index 0000000000..6992f02202 --- /dev/null +++ b/erpnext/patches/v4_2/set_company_country.py @@ -0,0 +1,15 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + country = frappe.db.get_single_value("Global Defaults", "country") + if not country: + print "Country not specified in Global Defaults" + return + + for company in frappe.db.sql_list("""select name from `tabCompany` + where ifnull(country, '')=''"""): + frappe.db.set_value("Company", company, "country", country) diff --git a/erpnext/patches/v4_2/toggle_rounded_total.py b/erpnext/patches/v4_2/toggle_rounded_total.py new file mode 100644 index 0000000000..aa63fdccd3 --- /dev/null +++ b/erpnext/patches/v4_2/toggle_rounded_total.py @@ -0,0 +1,9 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + global_defaults = frappe.get_doc("Global Defaults", "Global Defaults") + global_defaults.toggle_rounded_total() diff --git a/erpnext/patches/v4_2/update_project_milestones.py b/erpnext/patches/v4_2/update_project_milestones.py new file mode 100644 index 0000000000..4f93eb9172 --- /dev/null +++ b/erpnext/patches/v4_2/update_project_milestones.py @@ -0,0 +1,8 @@ +import frappe + +def execute(): + for project in frappe.db.sql_list("select name from tabProject"): + frappe.reload_doc("projects", "doctype", "project") + p = frappe.get_doc("Project", project) + p.update_milestones_completed() + p.db_set("percent_milestones_completed", p.percent_milestones_completed) diff --git a/erpnext/patches/v4_2/update_requested_and_ordered_qty.py b/erpnext/patches/v4_2/update_requested_and_ordered_qty.py new file mode 100644 index 0000000000..d6cabd8c23 --- /dev/null +++ b/erpnext/patches/v4_2/update_requested_and_ordered_qty.py @@ -0,0 +1,24 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + from erpnext.utilities.repost_stock import update_bin_qty, get_indented_qty, get_ordered_qty + + count=0 + for item_code, warehouse in frappe.db.sql("""select distinct item_code, warehouse from + (select item_code, warehouse from tabBin + union + select item_code, warehouse from `tabStock Ledger Entry`) a"""): + try: + count += 1 + update_bin_qty(item_code, warehouse, { + "indented_qty": get_indented_qty(item_code, warehouse), + "ordered_qty": get_ordered_qty(item_code, warehouse) + }) + if count % 200 == 0: + frappe.db.commit() + except: + frappe.db.rollback() diff --git a/erpnext/patches/v4_2/update_sales_order_invoice_field_name.py b/erpnext/patches/v4_2/update_sales_order_invoice_field_name.py new file mode 100644 index 0000000000..a8303a0aae --- /dev/null +++ b/erpnext/patches/v4_2/update_sales_order_invoice_field_name.py @@ -0,0 +1,6 @@ +import frappe + +def execute(): + frappe.reload_doc('accounts', 'doctype', 'sales_invoice') + frappe.db.sql("""update `tabSales Invoice` set from_date = invoice_period_from_date, + to_date = invoice_period_to_date, is_recurring = convert_into_recurring_invoice""")