From 1ae4b51cb25a55bd2eab7b9b8aad821ec314d87d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 3 May 2013 18:27:23 +0530 Subject: [PATCH 01/24] [report] issued items against production orderr --- .../manufacturing_home/manufacturing_home.js | 11 +++++++++ manufacturing/report/__init__.py | 0 .../__init__.py | 0 .../issued_items_against_production_order.txt | 23 +++++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 manufacturing/report/__init__.py create mode 100644 manufacturing/report/issued_items_against_production_order/__init__.py create mode 100644 manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt diff --git a/manufacturing/page/manufacturing_home/manufacturing_home.js b/manufacturing/page/manufacturing_home/manufacturing_home.js index b7f28edc41..d4841df2fb 100644 --- a/manufacturing/page/manufacturing_home/manufacturing_home.js +++ b/manufacturing/page/manufacturing_home/manufacturing_home.js @@ -58,6 +58,17 @@ wn.module_page["Manufacturing"] = [ }, ] }, + { + title: wn._("Reports"), + right: true, + icon: "icon-list", + items: [ + { + "label":wn._("Issued Items Against Production Order"), + route: "query-report/Issued Items Against Production Order", + }, + ] + } ] pscript['onload_manufacturing-home'] = function(wrapper) { diff --git a/manufacturing/report/__init__.py b/manufacturing/report/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/manufacturing/report/issued_items_against_production_order/__init__.py b/manufacturing/report/issued_items_against_production_order/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt b/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt new file mode 100644 index 0000000000..e00123d592 --- /dev/null +++ b/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt @@ -0,0 +1,23 @@ +[ + { + "creation": "2013-05-03 17:48:46", + "docstatus": 0, + "modified": "2013-05-03 18:24:05", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 0, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "select\n ste.production_order as \"Production Order:Link/Production Order:120\",\n ste.posting_date as \"Issue Date:Date:140\",\n ste_item.item_code as \"Item Code:Link/Item:120\",\n\tste_item.description as \"Description::150\",\n\tste_item.transfer_qty as \"Qty:Currency:100\",\n\tste_item.stock_uom as \"UOM:Link/UOM:80\",\n\tste_item.amount as \"Amount:Currency:120\",\n\tste_item.serial_no as \"Serial No:Link/Serial No:80\",\n\tste_item.s_warehouse as \"Source Warehouse:Link/Warehouse:120\",\n\tste_item.t_warehouse as \"Target Warehouse:Link/Warehouse:120\",\n\tpro.production_item as \"Finished Goods:Link/Item:120\", \n\tste.name as \"Stock Entry:Link/Stock Entry:120\"\nfrom\n\t`tabStock Entry` ste, `tabStock Entry Detail` ste_item, `tabProduction Order` pro\nwhere\n\tifnull(ste.production_order, '') != '' and ste.name = ste_item.parent \n\tand ste.production_order = pro.name and ste.docstatus = 1 \n\tand ste.purpose = 'Manufacture/Repack'\norder by ste.posting_date, ste.production_order, ste_item.item_code", + "ref_doctype": "Production Order", + "report_name": "Issued Items Against Production Order", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Issued Items Against Production Order" + } +] \ No newline at end of file From e23d2a35c4e49cde58ff6ee461dfd1f6a2c69ab9 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 6 May 2013 11:08:21 +0530 Subject: [PATCH 02/24] [fixes] sales/purchase register --- .../report/purchase_register/purchase_register.py | 15 ++++++++++----- accounts/report/sales_register/sales_register.py | 12 ++++++++---- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/accounts/report/purchase_register/purchase_register.py b/accounts/report/purchase_register/purchase_register.py index c131c17b4b..d4f23927d5 100644 --- a/accounts/report/purchase_register/purchase_register.py +++ b/accounts/report/purchase_register/purchase_register.py @@ -20,9 +20,10 @@ from webnotes.utils import flt def execute(filters=None): if not filters: filters = {} - columns, expense_accounts, tax_accounts = get_columns() - + invoice_list = get_invoices(filters) + columns, expense_accounts, tax_accounts = get_columns(invoice_list) + invoice_expense_map = get_invoice_expense_map(invoice_list) invoice_tax_map = get_invoice_tax_map(invoice_list) invoice_po_pr_map = get_invoice_po_pr_map(invoice_list) @@ -55,7 +56,7 @@ def execute(filters=None): return columns, data -def get_columns(): +def get_columns(invoice_list): """return columns based on filters""" columns = [ "Invoice:Link/Purchase Invoice:120", "Posting Date:Date:80", "Supplier:Link/Supplier:120", @@ -66,10 +67,14 @@ def get_columns(): expense_accounts = webnotes.conn.sql_list("""select distinct expense_head from `tabPurchase Invoice Item` where docstatus = 1 and ifnull(expense_head, '') != '' - order by expense_head""") + and parent in (%s) order by expense_head""" % + ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list])) + tax_accounts = webnotes.conn.sql_list("""select distinct account_head from `tabPurchase Taxes and Charges` where parenttype = 'Purchase Invoice' - and docstatus = 1 and ifnull(account_head, '') != '' order by account_head""") + and docstatus = 1 and ifnull(account_head, '') != '' and parent in (%s) + order by account_head""" % + ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list])) columns = columns + [(account + ":Currency:120") for account in expense_accounts] + \ ["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \ diff --git a/accounts/report/sales_register/sales_register.py b/accounts/report/sales_register/sales_register.py index 23d2227fc2..b15097457d 100644 --- a/accounts/report/sales_register/sales_register.py +++ b/accounts/report/sales_register/sales_register.py @@ -20,9 +20,10 @@ from webnotes.utils import flt def execute(filters=None): if not filters: filters = {} - columns, income_accounts, tax_accounts = get_columns() invoice_list = get_invoices(filters) + columns, income_accounts, tax_accounts = get_columns(invoice_list) + invoice_income_map = get_invoice_income_map(invoice_list) invoice_tax_map = get_invoice_tax_map(invoice_list) @@ -59,7 +60,7 @@ def execute(filters=None): return columns, data -def get_columns(): +def get_columns(invoice_list): """return columns based on filters""" columns = [ "Invoice:Link/Sales Invoice:120", "Posting Date:Date:80", "Customer:Link/Customer:120", @@ -69,11 +70,14 @@ def get_columns(): ] income_accounts = webnotes.conn.sql_list("""select distinct income_account - from `tabSales Invoice Item` where docstatus = 1 order by income_account""") + from `tabSales Invoice Item` where docstatus = 1 and parent in (%s) + order by income_account""" % + ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list])) tax_accounts = webnotes.conn.sql_list("""select distinct account_head from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice' - and docstatus = 1 order by account_head""") + and docstatus = 1 and parent in (%s) order by account_head""" % + ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list])) columns = columns + [(account + ":Currency:120") for account in income_accounts] + \ ["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \ From 52f7b6daf86ba5d2f2c5c45cdad54ca830fbad1c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 6 May 2013 12:24:27 +0530 Subject: [PATCH 03/24] [report] purchase in transit in new style --- buying/page/buying_home/buying_home.js | 4 ++++ stock/page/stock_home/stock_home.js | 4 ++++ stock/report/purchase_in_transit/__init__.py | 0 .../purchase_in_transit.txt | 22 +++++++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 stock/report/purchase_in_transit/__init__.py create mode 100644 stock/report/purchase_in_transit/purchase_in_transit.txt diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js index 56328cc574..e7532dda2e 100644 --- a/buying/page/buying_home/buying_home.js +++ b/buying/page/buying_home/buying_home.js @@ -107,6 +107,10 @@ wn.module_page["Buying"] = [ "label":wn._("Item-wise Purchase History"), route: "query-report/Item-wise Purchase History", }, + { + "label":wn._("Purchase In Transit"), + route: "query-report/Purchase In Transit", + }, ] } ] diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js index db77fced0e..bfcaf8acc1 100644 --- a/stock/page/stock_home/stock_home.js +++ b/stock/page/stock_home/stock_home.js @@ -197,6 +197,10 @@ wn.module_page["Stock"] = [ route: "query-report/Item-Wise Price List", doctype: "Item" }, + { + "label":wn._("Purchase In Transit"), + route: "query-report/Purchase In Transit", + }, ] } ] diff --git a/stock/report/purchase_in_transit/__init__.py b/stock/report/purchase_in_transit/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/stock/report/purchase_in_transit/purchase_in_transit.txt b/stock/report/purchase_in_transit/purchase_in_transit.txt new file mode 100644 index 0000000000..60ce0da460 --- /dev/null +++ b/stock/report/purchase_in_transit/purchase_in_transit.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-05-06 12:09:05", + "docstatus": 0, + "modified": "2013-05-06 12:22:52", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "SELECT\n pi.name as \"Purchase Invoice:Link/Purchase Invoice:120\",\n\tpi.posting_date as \"Posting Date:Date:100\",\n\tpi.credit_to as \"Supplier Account:Link/Account:120\",\n\tpi_item.item_code as \"Item Code:Link/Item:120\",\n\tpi_item.description as \"Description:Data:140\",\n\tpi_item.qty as \"Qty:Float:120\",\n\tpi_item.amount as \"Amount:Currency:120\",\n\tpi_item.purchase_order as \"Purchase Order:Link/Purchase Order:120\",\n\tpi_item.purchase_receipt as \"Purchase Receipt:Link/Purchase Receipt:120\",\n\tpr.posting_date as \"PR Posting Date:Date:130\",\n\tpi.company as \"Company:Link/Company:120\"\nFROM\n\t`tabPurchase Invoice` pi, `tabPurchase Invoice Item` pi_item, `tabPurchase Receipt` pr\nWHERE\n\tpi.name = pi_item.parent and pi_item.purchase_receipt = pr.name\n\tand pi.docstatus = 1 and pr.posting_date > pi.posting_date\nORDER BY\n\tpi.name desc", + "ref_doctype": "Purchase Receipt", + "report_name": "Purchase In Transit", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Purchase In Transit" + } +] \ No newline at end of file From a55723bea28ea040101a8ebe3ff3420d916627b2 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 6 May 2013 12:46:07 +0530 Subject: [PATCH 04/24] [report] sales partners commission --- accounts/page/accounts_home/accounts_home.js | 5 +++++ .../sales_partners_commission/__init__.py | 0 .../sales_partners_commission.txt | 22 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 accounts/report/sales_partners_commission/__init__.py create mode 100644 accounts/report/sales_partners_commission/sales_partners_commission.txt diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js index d2b0a0ea0d..c3d4cf18ce 100644 --- a/accounts/page/accounts_home/accounts_home.js +++ b/accounts/page/accounts_home/accounts_home.js @@ -217,6 +217,11 @@ wn.module_page["Accounts"] = [ route: "query-report/Payment Made With Ageing", doctype: "Journal Voucher" }, + { + "label":wn._("Sales Partners Commission"), + route: "query-report/Sales Partners Commission", + doctype: "Sales Invoice" + }, ] } ] diff --git a/accounts/report/sales_partners_commission/__init__.py b/accounts/report/sales_partners_commission/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/accounts/report/sales_partners_commission/sales_partners_commission.txt b/accounts/report/sales_partners_commission/sales_partners_commission.txt new file mode 100644 index 0000000000..52bbf3c751 --- /dev/null +++ b/accounts/report/sales_partners_commission/sales_partners_commission.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-05-06 12:28:23", + "docstatus": 0, + "modified": "2013-05-06 12:41:15", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "SELECT\n sales_partner as \"Sales Partner:Link/Sales Partner:150\",\n\tsum(net_total) as \"Invoiced Amount (Exculsive Tax):Currency:210\",\n\tsum(total_commission) as \"Total Commission:Currency:150\",\n\tsum(total_commission)*100/sum(net_total) as \"Average Commission Rate:Currency:170\"\nFROM\n\t`tabSales Invoice`\nWHERE\n\tdocstatus = 1 and ifnull(net_total, 0) > 0 and ifnull(total_commission, 0) > 0\nGROUP BY\n\tsales_partner\nORDER BY\n\t\"Total Commission:Currency:120\"", + "ref_doctype": "Sales Invoice", + "report_name": "Sales Partners Commission", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Sales Partners Commission" + } +] \ No newline at end of file From 6d309f727f45eef02156bf63f5ec9e64289f6f8b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 6 May 2013 14:34:33 +0530 Subject: [PATCH 05/24] [report] maintenance schedules --- support/page/support_home/support_home.js | 12 ++++++++++ support/report/__init__.py | 0 .../report/maintenance_schedules/__init__.py | 0 .../maintenance_schedules.txt | 22 +++++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 support/report/__init__.py create mode 100644 support/report/maintenance_schedules/__init__.py create mode 100644 support/report/maintenance_schedules/maintenance_schedules.txt diff --git a/support/page/support_home/support_home.js b/support/page/support_home/support_home.js index d397daa6ce..bde5e5c00a 100644 --- a/support/page/support_home/support_home.js +++ b/support/page/support_home/support_home.js @@ -72,6 +72,18 @@ wn.module_page["Support"] = [ }, ] }, + { + title: wn._("Reports"), + right: true, + icon: "icon-list", + items: [ + { + "label":wn._("Maintenance Schedules"), + route: "query-report/Maintenance Schedules", + doctype: "Maintenance Schedule" + } + ] + } ] pscript['onload_support-home'] = function(wrapper) { diff --git a/support/report/__init__.py b/support/report/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/support/report/maintenance_schedules/__init__.py b/support/report/maintenance_schedules/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/support/report/maintenance_schedules/maintenance_schedules.txt b/support/report/maintenance_schedules/maintenance_schedules.txt new file mode 100644 index 0000000000..525f4834ba --- /dev/null +++ b/support/report/maintenance_schedules/maintenance_schedules.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-05-06 14:25:21", + "docstatus": 0, + "modified": "2013-05-06 14:32:47", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "SELECT\n ms_item.scheduled_date as \"Schedule Date:Date:120\",\n\tms_item.item_code as \"Item Code:Link/Item:120\",\n\tms_item.item_name as \"Item Name::120\",\n\tms_item.serial_no as \"Serial No::120\",\n\tms_item.incharge_name as \"Incharge::120\",\n\tms.customer_name as \"Customer:Link/Customer:120\",\n\tms.address_display as \"Customer Address::120\",\n\tms.sales_order_no as \"Sales Order:Link/Sales Order:120\",\n\tms.company as \"Company:Link/Company:120\"\n\t\nFROM\n\t`tabMaintenance Schedule` ms, `tabMaintenance Schedule Detail` ms_item\nWHERE\n\tms.name = ms_item.parent and ms.docstatus = 1\nORDER BY\n\tms_item.scheduled_date asc, ms_item.item_code asc", + "ref_doctype": "Maintenance Schedule", + "report_name": "Maintenance Schedules", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Maintenance Schedules" + } +] \ No newline at end of file From 15697ed93716c97b10699601ca8d7f571d7982be Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 6 May 2013 17:01:19 +0530 Subject: [PATCH 06/24] [fixes] hour_rate fetching in bom --- manufacturing/doctype/bom/bom.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manufacturing/doctype/bom/bom.js b/manufacturing/doctype/bom/bom.js index f0c15fa2a9..b1f43f7620 100644 --- a/manufacturing/doctype/bom/bom.js +++ b/manufacturing/doctype/bom/bom.js @@ -64,9 +64,9 @@ cur_frm.add_fetch("item", "stock_uom", "uom"); cur_frm.cscript.workstation = function(doc,dt,dn) { var d = locals[dt][dn]; - wn.model.with_doc("Workstation", d.workstation, function(i, v) { - d.hour_rate = v.hour_rate; - refresh_field("hour_rate"); + wn.model.with_doc("Workstation", d.workstation, function(i, r) { + d.hour_rate = r.docs[0].hour_rate; + refresh_field("hour_rate", dn, "bom_operations"); calculate_op_cost(doc); calculate_total(doc); }); From 35e7e8f58f9ff5e389f2058d92bd52d93b4f011b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 6 May 2013 18:37:57 +0530 Subject: [PATCH 07/24] [report] employee birthday --- hr/page/hr_home/hr_home.js | 4 ++ hr/report/employee_birthday/__init__.py | 0 .../employee_birthday/employee_birthday.js | 19 +++++++ .../employee_birthday/employee_birthday.py | 50 +++++++++++++++++++ .../employee_birthday/employee_birthday.txt | 21 ++++++++ 5 files changed, 94 insertions(+) create mode 100644 hr/report/employee_birthday/__init__.py create mode 100644 hr/report/employee_birthday/employee_birthday.js create mode 100644 hr/report/employee_birthday/employee_birthday.py create mode 100644 hr/report/employee_birthday/employee_birthday.txt diff --git a/hr/page/hr_home/hr_home.js b/hr/page/hr_home/hr_home.js index df3264501a..1e0e5bc28f 100644 --- a/hr/page/hr_home/hr_home.js +++ b/hr/page/hr_home/hr_home.js @@ -169,6 +169,10 @@ wn.module_page["HR"] = [ "label":wn._("Employee Leave Balance"), route: "query-report/Employee Leave Balance" }, + { + "label":wn._("Employee Birthday"), + route: "query-report/Employee Birthday" + }, ] } ]; diff --git a/hr/report/employee_birthday/__init__.py b/hr/report/employee_birthday/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/hr/report/employee_birthday/employee_birthday.js b/hr/report/employee_birthday/employee_birthday.js new file mode 100644 index 0000000000..f2bc9cbe56 --- /dev/null +++ b/hr/report/employee_birthday/employee_birthday.js @@ -0,0 +1,19 @@ +wn.query_reports["Employee Birthday"] = { + "filters": [ + { + "fieldname":"month", + "label": "Month", + "fieldtype": "Select", + "options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec", + "default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", + "Dec"][wn.datetime.str_to_obj(wn.datetime.get_today()).getMonth()], + }, + { + "fieldname":"company", + "label": "Company", + "fieldtype": "Link", + "options": "Company", + "default": wn.defaults.get_user_default("company") + } + ] +} \ No newline at end of file diff --git a/hr/report/employee_birthday/employee_birthday.py b/hr/report/employee_birthday/employee_birthday.py new file mode 100644 index 0000000000..7268055b72 --- /dev/null +++ b/hr/report/employee_birthday/employee_birthday.py @@ -0,0 +1,50 @@ +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import flt + +def execute(filters=None): + if not filters: filters = {} + + columns = get_columns() + data = get_employees(filters) + + return columns, data + +def get_columns(): + return [ + "Employee:Link/Employee:120", "Date of Birth:Date:100", "Branch:Link/Branch:120", + "Department:Link/Department:120", "Designation:Link/Designation:120", "Gender::60", + "Company:Link/Company:120" + ] + +def get_employees(filters): + conditions = get_conditions(filters) + return webnotes.conn.sql("""select name, date_of_birth, branch, department, designation, + gender, company from tabEmployee where status = 'Active' %s""" % conditions, as_list=1) + +def get_conditions(filters): + conditions = "" + if filters.get("month"): + month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", + "Dec"].index(filters["month"]) + 1 + conditions += " and month(date_of_birth) = '%s'" % month + + if filters.get("company"): conditions += " and company = '%s'" % filters["company"] + + return conditions \ No newline at end of file diff --git a/hr/report/employee_birthday/employee_birthday.txt b/hr/report/employee_birthday/employee_birthday.txt new file mode 100644 index 0000000000..575ae73352 --- /dev/null +++ b/hr/report/employee_birthday/employee_birthday.txt @@ -0,0 +1,21 @@ +[ + { + "creation": "2013-05-06 17:56:03", + "docstatus": 0, + "modified": "2013-05-06 17:56:03", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "ref_doctype": "Employee", + "report_name": "Employee Birthday", + "report_type": "Script Report" + }, + { + "doctype": "Report", + "name": "Employee Birthday" + } +] \ No newline at end of file From 6754dda4a89a469c5f693e0ca5340cc1cd8c21ed Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 6 May 2013 18:50:29 +0530 Subject: [PATCH 08/24] [report] employee information --- hr/page/hr_home/hr_home.js | 4 ++++ hr/report/employee_information/__init__.py | 0 .../employee_information.txt | 22 +++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 hr/report/employee_information/__init__.py create mode 100644 hr/report/employee_information/employee_information.txt diff --git a/hr/page/hr_home/hr_home.js b/hr/page/hr_home/hr_home.js index 1e0e5bc28f..b2cce73f15 100644 --- a/hr/page/hr_home/hr_home.js +++ b/hr/page/hr_home/hr_home.js @@ -173,6 +173,10 @@ wn.module_page["HR"] = [ "label":wn._("Employee Birthday"), route: "query-report/Employee Birthday" }, + { + "label":wn._("Employee Information"), + route: "Report2/Employee/Employee Information" + }, ] } ]; diff --git a/hr/report/employee_information/__init__.py b/hr/report/employee_information/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/hr/report/employee_information/employee_information.txt b/hr/report/employee_information/employee_information.txt new file mode 100644 index 0000000000..b9d190b029 --- /dev/null +++ b/hr/report/employee_information/employee_information.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-05-06 18:43:53", + "docstatus": 0, + "modified": "2013-05-06 18:47:43", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "json": "{\"filters\":[],\"columns\":[[\"name\",\"Employee\"],[\"employee_number\",\"Employee\"],[\"date_of_joining\",\"Employee\"],[\"branch\",\"Employee\"],[\"department\",\"Employee\"],[\"designation\",\"Employee\"],[\"gender\",\"Employee\"],[\"status\",\"Employee\"],[\"company\",\"Employee\"],[\"employment_type\",\"Employee\"],[\"grade\",\"Employee\"],[\"reports_to\",\"Employee\"],[\"company_email\",\"Employee\"]],\"sort_by\":\"Employee.bank_ac_no\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", + "name": "__common__", + "ref_doctype": "Employee", + "report_name": "Employee Information", + "report_type": "Report Builder" + }, + { + "doctype": "Report", + "name": "Employee Information" + } +] \ No newline at end of file From c1b961932186a327d58e2f9fcab23e0d62fbd315 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 7 May 2013 11:16:20 +0530 Subject: [PATCH 09/24] [fixes] company for auto-material request --- stock/doctype/bin/bin.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stock/doctype/bin/bin.py b/stock/doctype/bin/bin.py index be343129bf..2d98c2634f 100644 --- a/stock/doctype/bin/bin.py +++ b/stock/doctype/bin/bin.py @@ -79,7 +79,7 @@ class DocType: if (flt(args.get("actual_qty")) < 0 or flt(args.get("reserved_qty")) > 0) \ and args.get("is_cancelled") == 'No' and args.get("is_amended")=='No': - self.reorder_item(args.get("voucher_type"), args.get("voucher_no")) + self.reorder_item(args.get("voucher_type"), args.get("voucher_no"), args.get("company")) def get_first_sle(self): sle = sql(""" @@ -92,7 +92,7 @@ class DocType: """, (self.doc.item_code, self.doc.warehouse), as_dict=1) return sle and sle[0] or None - def reorder_item(self,doc_type,doc_name): + def reorder_item(self,doc_type,doc_name, company): """ Reorder item if stock reaches reorder level""" if not hasattr(webnotes, "auto_indent"): webnotes.auto_indent = webnotes.conn.get_value('Global Defaults', None, 'auto_indent') @@ -111,10 +111,10 @@ class DocType: material_request_type = "Purchase" if flt(reorder_qty) and flt(self.doc.projected_qty) < flt(reorder_level): - self.create_material_request(doc_type, doc_name, reorder_level, reorder_qty, - material_request_type) + self.create_material_request(doc_type, doc_name, reorder_level, reorder_qty, + company, material_request_type) - def create_material_request(self, doc_type, doc_name, reorder_level, reorder_qty, + def create_material_request(self, doc_type, doc_name, reorder_level, reorder_qty, company, material_request_type="Purchase"): """ Create indent on reaching reorder level """ defaults = webnotes.defaults.get_defaults() @@ -122,7 +122,7 @@ class DocType: mr = webnotes.bean([{ "doctype": "Material Request", - "company": defaults.company, + "company": company or defaults.company, "fiscal_year": defaults.fiscal_year, "transaction_date": nowdate(), "material_request_type": material_request_type, From 620576080a41f16522ed00306589c9ab20d1cfe1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 7 May 2013 12:03:33 +0530 Subject: [PATCH 10/24] [fixes][currency symbol] fieldtype in report --- .../purchase_taxes_and_charges.txt | 23 ++++++++++++++----- .../item_wise_purchase_history.txt | 4 ++-- .../issued_items_against_production_order.txt | 4 ++-- .../item_wise_sales_history.txt | 4 ++-- .../sales_person_wise_transaction_summary.py | 4 ++-- .../item_wise_price_list.txt | 6 ++--- 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt b/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt index 576730779a..619aed1954 100644 --- a/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt +++ b/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-03-26 06:51:12", + "creation": "2013-04-19 11:00:06", "docstatus": 0, - "modified": "2013-04-17 14:05:19", + "modified": "2013-05-07 11:23:56", "modified_by": "Administrator", "owner": "Administrator" }, @@ -35,6 +35,7 @@ "oldfieldname": "category", "oldfieldtype": "Select", "options": "Valuation and Total\nValuation\nTotal", + "read_only": 0, "reqd": 1 }, { @@ -45,6 +46,7 @@ "oldfieldname": "charge_type", "oldfieldtype": "Select", "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total", + "read_only": 0, "reqd": 1 }, { @@ -55,6 +57,7 @@ "oldfieldname": "account_head", "oldfieldtype": "Link", "options": "Account", + "read_only": 0, "reqd": 1 }, { @@ -65,7 +68,8 @@ "label": "Cost Center", "oldfieldname": "cost_center", "oldfieldtype": "Link", - "options": "Cost Center" + "options": "Cost Center", + "read_only": 0 }, { "doctype": "DocField", @@ -75,17 +79,18 @@ "oldfieldname": "description", "oldfieldtype": "Small Text", "print_width": "300px", + "read_only": 0, "reqd": 1, "width": "300px" }, { "doctype": "DocField", "fieldname": "rate", - "fieldtype": "Currency", + "fieldtype": "Float", "label": "Rate", "oldfieldname": "rate", "oldfieldtype": "Currency", - "options": "Company:company:default_currency", + "read_only": 0, "reqd": 0 }, { @@ -96,6 +101,7 @@ "oldfieldname": "tax_amount", "oldfieldtype": "Currency", "options": "Company:company:default_currency", + "read_only": 0, "reqd": 0 }, { @@ -115,7 +121,8 @@ "hidden": 0, "label": "Enter Row", "oldfieldname": "row_id", - "oldfieldtype": "Data" + "oldfieldtype": "Data", + "read_only": 0 }, { "default": "Add", @@ -126,6 +133,7 @@ "oldfieldname": "add_deduct_tax", "oldfieldtype": "Select", "options": "Add\nDeduct", + "read_only": 0, "reqd": 1 }, { @@ -149,6 +157,7 @@ "oldfieldname": "parenttype", "oldfieldtype": "Data", "print_hide": 1, + "read_only": 0, "search_index": 0 }, { @@ -163,6 +172,7 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, + "read_only": 0, "report_hide": 1 }, { @@ -177,6 +187,7 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, + "read_only": 0, "report_hide": 1 } ] \ No newline at end of file diff --git a/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt b/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt index 3f9e702f5f..5d36d9445b 100644 --- a/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt +++ b/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-03 14:55:53", "docstatus": 0, - "modified": "2013-05-03 15:13:34", + "modified": "2013-05-07 11:20:09", "modified_by": "Administrator", "owner": "Administrator" }, @@ -11,7 +11,7 @@ "doctype": "Report", "is_standard": "Yes", "name": "__common__", - "query": "select\n po_item.item_code as \"Item Code:Link/Item:120\",\n\tpo_item.item_name as \"Item Name::120\",\n\tpo_item.description as \"Description::150\",\n\tpo_item.qty as \"Qty:Currency:100\",\n\tpo_item.stock_uom as \"UOM:Link/UOM:80\",\n\tpo_item.purchase_rate as \"Rate:Currency:120\",\n\tpo_item.amount as \"Amount:Currency:120\",\n\tpo.name as \"Purchase Order:Link/Purchase Order:120\",\n\tpo.transaction_date as \"Transaction Date:Date:140\",\n\tpo.supplier as \"Supplier:Link/Supplier:130\",\n\tpo_item.project_name as \"Project:Link/Project:130\",\n\tifnull(po_item.received_qty, 0) as \"Received Qty:Currency:120\",\n\tifnull(po_item.billed_qty, 0) as \"Billed Qty:Currency:120\"\nfrom\n\t`tabPurchase Order` po, `tabPurchase Order Item` po_item\nwhere\n\tpo.name = po_item.parent and po.docstatus = 1\norder by po.name desc", + "query": "select\n po_item.item_code as \"Item Code:Link/Item:120\",\n\tpo_item.item_name as \"Item Name::120\",\n\tpo_item.description as \"Description::150\",\n\tpo_item.qty as \"Qty:Float:100\",\n\tpo_item.stock_uom as \"UOM:Link/UOM:80\",\n\tpo_item.purchase_rate as \"Rate:Currency:120\",\n\tpo_item.amount as \"Amount:Currency:120\",\n\tpo.name as \"Purchase Order:Link/Purchase Order:120\",\n\tpo.transaction_date as \"Transaction Date:Date:140\",\n\tpo.supplier as \"Supplier:Link/Supplier:130\",\n\tpo_item.project_name as \"Project:Link/Project:130\",\n\tifnull(po_item.received_qty, 0) as \"Received Qty:Float:120\",\n\tifnull(po_item.billed_qty, 0) as \"Billed Qty:Float:120\"\nfrom\n\t`tabPurchase Order` po, `tabPurchase Order Item` po_item\nwhere\n\tpo.name = po_item.parent and po.docstatus = 1\norder by po.name desc", "ref_doctype": "Purchase Order", "report_name": "Item-wise Purchase History", "report_type": "Query Report" diff --git a/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt b/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt index e00123d592..a5a03bfa00 100644 --- a/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt +++ b/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-03 17:48:46", "docstatus": 0, - "modified": "2013-05-03 18:24:05", + "modified": "2013-05-07 11:49:56", "modified_by": "Administrator", "owner": "Administrator" }, @@ -11,7 +11,7 @@ "doctype": "Report", "is_standard": "Yes", "name": "__common__", - "query": "select\n ste.production_order as \"Production Order:Link/Production Order:120\",\n ste.posting_date as \"Issue Date:Date:140\",\n ste_item.item_code as \"Item Code:Link/Item:120\",\n\tste_item.description as \"Description::150\",\n\tste_item.transfer_qty as \"Qty:Currency:100\",\n\tste_item.stock_uom as \"UOM:Link/UOM:80\",\n\tste_item.amount as \"Amount:Currency:120\",\n\tste_item.serial_no as \"Serial No:Link/Serial No:80\",\n\tste_item.s_warehouse as \"Source Warehouse:Link/Warehouse:120\",\n\tste_item.t_warehouse as \"Target Warehouse:Link/Warehouse:120\",\n\tpro.production_item as \"Finished Goods:Link/Item:120\", \n\tste.name as \"Stock Entry:Link/Stock Entry:120\"\nfrom\n\t`tabStock Entry` ste, `tabStock Entry Detail` ste_item, `tabProduction Order` pro\nwhere\n\tifnull(ste.production_order, '') != '' and ste.name = ste_item.parent \n\tand ste.production_order = pro.name and ste.docstatus = 1 \n\tand ste.purpose = 'Manufacture/Repack'\norder by ste.posting_date, ste.production_order, ste_item.item_code", + "query": "select\n ste.production_order as \"Production Order:Link/Production Order:120\",\n ste.posting_date as \"Issue Date:Date:140\",\n ste_item.item_code as \"Item Code:Link/Item:120\",\n\tste_item.description as \"Description::150\",\n\tste_item.transfer_qty as \"Qty:Float:100\",\n\tste_item.stock_uom as \"UOM:Link/UOM:80\",\n\tste_item.amount as \"Amount:Currency:120\",\n\tste_item.serial_no as \"Serial No:Link/Serial No:80\",\n\tste_item.s_warehouse as \"Source Warehouse:Link/Warehouse:120\",\n\tste_item.t_warehouse as \"Target Warehouse:Link/Warehouse:120\",\n\tpro.production_item as \"Finished Goods:Link/Item:120\", \n\tste.name as \"Stock Entry:Link/Stock Entry:120\"\nfrom\n\t`tabStock Entry` ste, `tabStock Entry Detail` ste_item, `tabProduction Order` pro\nwhere\n\tifnull(ste.production_order, '') != '' and ste.name = ste_item.parent \n\tand ste.production_order = pro.name and ste.docstatus = 1 \n\tand ste.purpose = 'Manufacture/Repack'\norder by ste.posting_date, ste.production_order, ste_item.item_code", "ref_doctype": "Production Order", "report_name": "Issued Items Against Production Order", "report_type": "Query Report" diff --git a/selling/report/item_wise_sales_history/item_wise_sales_history.txt b/selling/report/item_wise_sales_history/item_wise_sales_history.txt index cf13bdc3ea..6fee050e0d 100644 --- a/selling/report/item_wise_sales_history/item_wise_sales_history.txt +++ b/selling/report/item_wise_sales_history/item_wise_sales_history.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-03 14:38:34", "docstatus": 0, - "modified": "2013-05-03 15:15:11", + "modified": "2013-05-07 11:19:40", "modified_by": "Administrator", "owner": "Administrator" }, @@ -11,7 +11,7 @@ "doctype": "Report", "is_standard": "Yes", "name": "__common__", - "query": "select\n so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Currency:100\",\n\tso_item.stock_uom as \"UOM:Link/UOM:80\",\n\tso_item.basic_rate as \"Rate:Currency:120\",\n\tso_item.amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n\tso.territory as \"Territory:Link/Territory:130\",\n so.project_name as \"Project:Link/Project:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Currency:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item\nwhere\n\tso.name = so_item.parent\n\tand so.docstatus = 1\norder by so.name desc", + "query": "select\n so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Float:100\",\n\tso_item.stock_uom as \"UOM:Link/UOM:80\",\n\tso_item.basic_rate as \"Rate:Currency:120\",\n\tso_item.amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n\tso.territory as \"Territory:Link/Territory:130\",\n so.project_name as \"Project:Link/Project:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Float:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item\nwhere\n\tso.name = so_item.parent\n\tand so.docstatus = 1\norder by so.name desc", "ref_doctype": "Sales Order", "report_name": "Item-wise Sales History", "report_type": "Query Report" diff --git a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py index 612cb7425d..23e8819242 100644 --- a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py +++ b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py @@ -32,8 +32,8 @@ def get_columns(filters): return [filters["doc_type"] + ":Link/" + filters["doc_type"] + ":140", "Customer:Link/Customer:140", "Territory:Link/Territory:100", "Posting Date:Date:100", - "Item Code:Link/Item:120", "Qty:Currency:100", "Amount:Currency:120", - "Sales Person:Link/Sales Person:140", "Contribution %:Currency:110", + "Item Code:Link/Item:120", "Qty:Float:100", "Amount:Currency:120", + "Sales Person:Link/Sales Person:140", "Contribution %:Float:110", "Contribution Amount:Currency:140"] def get_entries(filters): diff --git a/stock/report/item_wise_price_list/item_wise_price_list.txt b/stock/report/item_wise_price_list/item_wise_price_list.txt index 6c2afad897..824c603597 100644 --- a/stock/report/item_wise_price_list/item_wise_price_list.txt +++ b/stock/report/item_wise_price_list/item_wise_price_list.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-01-02 14:22:51", + "creation": "2013-02-22 18:01:55", "docstatus": 0, - "modified": "2013-02-22 15:53:01", + "modified": "2013-05-07 11:50:46", "modified_by": "Administrator", "owner": "Administrator" }, @@ -10,7 +10,7 @@ "doctype": "Report", "is_standard": "Yes", "name": "__common__", - "query": "select\n item.name as \"ID:Link/Item:120\", \n item.item_name as \"Item Name::120\", \n item_price.price_list_name as \"Price List::80\",\n item_price.ref_currency as \"Currency::40\", \n item_price.ref_rate as \"Rate:Currency:80\",\n item.description as \"Description::160\",\n item.item_group as \"Item Group:Link/Item Group:100\",\n item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price\nwhere\n item_price.parent = item.name", + "query": "select\n item.name as \"ID:Link/Item:120\", \n item.item_name as \"Item Name::120\", \n item_price.price_list_name as \"Price List::80\",\n item_price.ref_currency as \"Currency::40\", \n item_price.ref_rate as \"Rate:Float:80\",\n item.description as \"Description::160\",\n item.item_group as \"Item Group:Link/Item Group:100\",\n item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price\nwhere\n item_price.parent = item.name", "ref_doctype": "Item", "report_name": "Item-Wise Price List", "report_type": "Query Report" From f2d4df975ee97fcbf480df6d1a4cfd6ca23a5553 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 7 May 2013 13:12:02 +0530 Subject: [PATCH 11/24] [fixes] floating point issue in buying rate --- controllers/selling_controller.py | 3 ++- stock/doctype/stock_entry/stock_entry.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/controllers/selling_controller.py b/controllers/selling_controller.py index b22042d0fe..80af337031 100644 --- a/controllers/selling_controller.py +++ b/controllers/selling_controller.py @@ -59,7 +59,8 @@ class SellingController(StockController): buying_amount = get_buying_amount(item.item_code, item.warehouse, -1*item.qty, self.doc.doctype, self.doc.name, item.name, stock_ledger_entries, item_sales_bom) - item.buying_amount = buying_amount > 0 and buying_amount or 0 + + item.buying_amount = buying_amount >= 0.01 and buying_amount or 0 webnotes.conn.set_value(item.doctype, item.name, "buying_amount", item.buying_amount) diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index fa60072518..d08deefa2b 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -194,10 +194,10 @@ class DocType(StockController): total_valuation_amount = 0 for item in self.doclist.get({"parentfield": "mtn_details"}): if item.t_warehouse and not item.s_warehouse: - total_valuation_amount += flt(item.incoming_rate) * flt(item.transfer_qty) + total_valuation_amount += flt(item.incoming_rate, 2) * flt(item.transfer_qty) if item.s_warehouse and not item.t_warehouse: - total_valuation_amount -= flt(item.incoming_rate) * flt(item.transfer_qty) + total_valuation_amount -= flt(item.incoming_rate, 2) * flt(item.transfer_qty) return total_valuation_amount @@ -607,7 +607,7 @@ class DocType(StockController): 'voucher_no': self.doc.name, 'voucher_detail_no': d.name, 'actual_qty': qty, - 'incoming_rate': flt(d.incoming_rate) or 0, + 'incoming_rate': flt(d.incoming_rate, 2) or 0, 'stock_uom': d.stock_uom, 'company': self.doc.company, 'is_cancelled': (is_cancelled ==1) and 'Yes' or 'No', From 04f888fa52f13822d23442fd6203363168945ac7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 7 May 2013 16:03:10 +0530 Subject: [PATCH 12/24] [fixes] item_code non-mandatory in item if naming_series --- .../bank_reconciliation.py | 2 +- .../bom_replace_tool/bom_replace_tool.py | 6 +- stock/doctype/item/item.py | 4 +- stock/doctype/item/item.txt | 70 ++++--------------- 4 files changed, 17 insertions(+), 65 deletions(-) diff --git a/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/accounts/doctype/bank_reconciliation/bank_reconciliation.py index 980af5844f..f19df48306 100644 --- a/accounts/doctype/bank_reconciliation/bank_reconciliation.py +++ b/accounts/doctype/bank_reconciliation/bank_reconciliation.py @@ -66,6 +66,6 @@ class DocType: vouchers.append(d.voucher_id) if vouchers: - msgprint("Clearance Date updated in %s" % vouchers) + msgprint("Clearance Date updated in %s" % ", ".join(vouchers)) else: msgprint("Clearance Date not mentioned") \ No newline at end of file diff --git a/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py b/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py index 177adcda83..4c9c42da2e 100644 --- a/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py +++ b/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py @@ -46,11 +46,7 @@ class DocType: webnotes.conn.sql("""update `tabBOM Item` set bom_no=%s, rate=%s, amount=qty*%s where bom_no = %s and docstatus < 2""", (self.doc.new_bom, current_bom_unitcost, current_bom_unitcost, self.doc.current_bom)) - - def get_parent_boms(bom_no): - return [d[0] for d in webnotes.conn.sql("""select distinct parent from - `tabBOM Item` where ifnull(bom_no, '')=%s and docstatus < 2""", bom_no)] - + def get_parent_boms(self): return [d[0] for d in webnotes.conn.sql("""select distinct parent from `tabBOM Item` where ifnull(bom_no, '') = %s and docstatus < 2""", diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index 63275047ad..fde532c96c 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -31,7 +31,9 @@ class DocType(DocListController): if webnotes.conn.get_default("item_naming_by")=="Naming Series": from webnotes.model.doc import make_autoname self.doc.item_code = make_autoname(self.doc.naming_series+'.#####') - + elif not self.doc.item_code: + msgprint(_("Item Code is mandatory"), raise_exception=1) + self.doc.name = self.doc.item_code def validate(self): diff --git a/stock/doctype/item/item.txt b/stock/doctype/item/item.txt index 274719eec5..c799029d95 100644 --- a/stock/doctype/item/item.txt +++ b/stock/doctype/item/item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-04-25 10:56:55", + "creation": "2013-05-03 10:45:46", "docstatus": 0, - "modified": "2013-05-02 15:10:53", + "modified": "2013-05-07 15:58:58", "modified_by": "Administrator", "owner": "Administrator" }, @@ -28,13 +28,14 @@ "permlevel": 0 }, { - "amend": 0, "doctype": "DocPerm", "name": "__common__", "parent": "Item", "parentfield": "permissions", "parenttype": "DocType", + "permlevel": 0, "read": 1, + "report": 1, "submit": 0 }, { @@ -55,7 +56,8 @@ "fieldname": "naming_series", "fieldtype": "Select", "label": "Naming Series", - "options": "\nITEM" + "options": "\nITEM", + "read_only": 0 }, { "description": "Item will be saved by this name in the data base.", @@ -64,10 +66,11 @@ "fieldtype": "Data", "in_filter": 0, "label": "Item Code", + "no_copy": 1, "oldfieldname": "item_code", "oldfieldtype": "Data", "read_only": 0, - "reqd": 1, + "reqd": 0, "search_index": 0 }, { @@ -883,76 +886,27 @@ "label": "Website Description", "read_only": 0 }, - { - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "report": 0, - "role": "Material Manager", - "write": 0 - }, - { - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 0, - "report": 1, - "role": "Material Manager", - "write": 0 - }, - { - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "report": 0, - "role": "Material User", - "write": 0 - }, - { - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 0, - "report": 1, - "role": "Material User", - "write": 0 - }, { "cancel": 1, "create": 1, "doctype": "DocPerm", - "permlevel": 0, - "report": 1, "role": "Material Master Manager", "write": 1 }, { + "amend": 0, "cancel": 0, "create": 0, "doctype": "DocPerm", - "permlevel": 1, - "report": 0, - "role": "Material Master Manager", + "role": "Material Manager", "write": 0 }, { - "cancel": 1, - "create": 1, - "doctype": "DocPerm", - "permlevel": 0, - "report": 1, - "role": "System Manager", - "write": 1 - }, - { + "amend": 0, "cancel": 0, "create": 0, "doctype": "DocPerm", - "permlevel": 1, - "report": 0, - "role": "System Manager", + "role": "Material User", "write": 0 } ] \ No newline at end of file From f7bdf8e05aa80ca00ba96e5af7cd3053d38ca16d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 7 May 2013 16:48:55 +0530 Subject: [PATCH 13/24] [fixes][jv] set clearance date as null on saving document --- accounts/doctype/journal_voucher/journal_voucher.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py index 9b1ca7a105..f7d4035a58 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.py +++ b/accounts/doctype/journal_voucher/journal_voucher.py @@ -43,6 +43,8 @@ class DocType(AccountsController): if not self.doc.is_opening: self.doc.is_opening='No' + self.doc.clearance_date = None + self.validate_debit_credit() self.validate_cheque_info() self.validate_entries_for_advance() From 75eeb010526c035115a5d897bb0ee9e570dad8b4 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 8 May 2013 12:35:33 +0530 Subject: [PATCH 14/24] [attachments] [fix] on adding and removing attachments, update the select fields with options attach_files: --- stock/doctype/item/item.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js index a344ad3ce9..fa42129ce8 100644 --- a/stock/doctype/item/item.js +++ b/stock/doctype/item/item.js @@ -134,11 +134,7 @@ cur_frm.fields_dict.item_supplier_details.grid.get_field("supplier").get_query = erpnext.utils.supplier_query; cur_frm.cscript.on_remove_attachment = function(doc) { - // refresh image list before unsetting image - refresh_field("image"); if(!inList(cur_frm.fields_dict.image.df.options.split("\n"), doc.image)) { - // if the selected image is removed from attachment, unset it - cur_frm.set_value("image", ""); msgprint(wn._("Attachment removed. You may need to update: ") + wn.meta.get_docfield(doc.doctype, "description_html").label); } From 4f8a81ca97790e6ae780a75c8ff2a629f10dad48 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 8 May 2013 17:40:35 +0530 Subject: [PATCH 15/24] [item] [usability] change image view on change of image --- stock/doctype/item/item.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js index fa42129ce8..acc78e77dc 100644 --- a/stock/doctype/item/item.js +++ b/stock/doctype/item/item.js @@ -153,3 +153,7 @@ cur_frm.cscript.copy_from_item_group = function(doc) { cur_frm.refresh(); }); } + +cur_frm.cscript.image = function() { + refresh_field("image_view"); +} \ No newline at end of file From bddd5d9b0c3a761121d41c49457e4b1d4402094f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 9 May 2013 12:45:18 +0530 Subject: [PATCH 16/24] [rename] [fix] merge should be passed to on_rename method of controller for further processing --- accounts/doctype/account/account.py | 2 +- accounts/doctype/cost_center/cost_center.py | 2 +- buying/doctype/supplier/supplier.py | 4 +- selling/doctype/customer/customer.py | 4 +- selling/doctype/customer/test_customer.py | 64 +++++++++++++++++++++ setup/doctype/company/company.py | 2 +- stock/doctype/item/item.py | 2 +- stock/doctype/serial_no/serial_no.py | 2 +- 8 files changed, 73 insertions(+), 9 deletions(-) diff --git a/accounts/doctype/account/account.py b/accounts/doctype/account/account.py index eb65604e02..bdc26e46ce 100644 --- a/accounts/doctype/account/account.py +++ b/accounts/doctype/account/account.py @@ -187,7 +187,7 @@ class DocType: sql("""delete from `tabGL Entry` where account = %s and ifnull(is_cancelled, 'No') = 'Yes'""", self.doc.name) - def on_rename(self, new, old): + def on_rename(self, new, old, merge=False): company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr") parts = new.split(" - ") diff --git a/accounts/doctype/cost_center/cost_center.py b/accounts/doctype/cost_center/cost_center.py index a7672452aa..bf0918879f 100644 --- a/accounts/doctype/cost_center/cost_center.py +++ b/accounts/doctype/cost_center/cost_center.py @@ -87,7 +87,7 @@ class DocType(DocTypeNestedSet): self.validate_mandatory() self.validate_budget_details() - def on_rename(self, new, old): + def on_rename(self, new, old, merge=False): company_abbr = webnotes.conn.get_value("Company", self.doc.company_name, "abbr") parts = new.split(" - ") diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py index 0137504b30..d41b86c32c 100644 --- a/buying/doctype/supplier/supplier.py +++ b/buying/doctype/supplier/supplier.py @@ -168,7 +168,7 @@ class DocType(TransactionBase): self.delete_supplier_communication() self.delete_supplier_account() - def on_rename(self, new, old): + def on_rename(self, new, old, merge=False): #update supplier_name if not naming series if webnotes.defaults.get_global_default('supp_master_name') == 'Supplier Name': update_fields = [ @@ -186,7 +186,7 @@ class DocType(TransactionBase): for account in webnotes.conn.sql("""select name, account_name from tabAccount where master_name=%s and master_type='Supplier'""", old, as_dict=1): if account.account_name != new: - webnotes.rename_doc("Account", account.name, new) + webnotes.rename_doc("Account", account.name, new, merge=merge) #update master_name in doctype account webnotes.conn.sql("""update `tabAccount` set master_name = %s, diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py index 7e16341a4a..6f54ef9641 100644 --- a/selling/doctype/customer/customer.py +++ b/selling/doctype/customer/customer.py @@ -216,7 +216,7 @@ class DocType(TransactionBase): if self.doc.lead_name: sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name) - def on_rename(self, new, old): + def on_rename(self, new, old, merge=False): #update customer_name if not naming series if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name': update_fields = [ @@ -244,7 +244,7 @@ class DocType(TransactionBase): for account in webnotes.conn.sql("""select name, account_name from tabAccount where master_name=%s and master_type='Customer'""", old, as_dict=1): if account.account_name != new: - webnotes.rename_doc("Account", account.name, new) + webnotes.rename_doc("Account", account.name, new, merge=merge) #update master_name in doctype account webnotes.conn.sql("""update `tabAccount` set master_name = %s, diff --git a/selling/doctype/customer/test_customer.py b/selling/doctype/customer/test_customer.py index 551b03f0be..806585f1e1 100644 --- a/selling/doctype/customer/test_customer.py +++ b/selling/doctype/customer/test_customer.py @@ -1,4 +1,60 @@ +from __future__ import unicode_literals +import webnotes +import unittest + +class TestCustomer(unittest.TestCase): + def test_rename(self): + self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"), + (("_Test Customer 1",),)) + + webnotes.rename_doc("Customer", "_Test Customer 1", "_Test Customer 1 Renamed") + + self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1 Renamed"), + (("_Test Customer 1 Renamed",),)) + self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"), ()) + + def test_merge(self): + from webnotes.test_runner import make_test_records + make_test_records("Sales Invoice") + + # clear transactions for new name + webnotes.conn.sql("""delete from `tabSales Invoice` where customer='_Test Customer 1'""") + + # check if they exist + self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"), + (("_Test Customer",),)) + self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"), + (("_Test Customer 1",),)) + self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"), + (("_Test Customer - _TC",),)) + self.assertEqual(webnotes.conn.exists("Account", "_Test Customer 1 - _TC"), + (("_Test Customer 1 - _TC",),)) + + # check if transactions exists + self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice` + where customer='_Test Customer'""", )[0][0], 0) + self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice` + where debit_to='_Test Customer - _TC'""", )[0][0], 0) + + webnotes.rename_doc("Customer", "_Test Customer", "_Test Customer 1", merge=True) + + # check that no transaction exists for old name + self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice` + where customer='_Test Customer 1'""", )[0][0], 0) + self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice` + where debit_to='_Test Customer 1 - _TC'""", )[0][0], 0) + + # check that transactions exist for new name + self.assertEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice` + where customer='_Test Customer'""", )[0][0], 0) + self.assertEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice` + where debit_to='_Test Customer - _TC'""", )[0][0], 0) + + # check that old name doesn't exist + self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"), ()) + self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"), ()) + test_records = [ [{ "doctype": "Customer", @@ -7,5 +63,13 @@ test_records = [ "customer_group": "_Test Customer Group", "territory": "_Test Territory", "company": "_Test Company" + }], + [{ + "doctype": "Customer", + "customer_name": "_Test Customer 1", + "customer_type": "Individual", + "customer_group": "_Test Customer Group", + "territory": "_Test Territory", + "company": "_Test Company" }] ] \ No newline at end of file diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py index 78be5380b2..e383fb1bc8 100644 --- a/setup/doctype/company/company.py +++ b/setup/doctype/company/company.py @@ -287,7 +287,7 @@ class DocType: where doctype='Global Defaults' and field='default_company' and value=%s""", self.doc.name) - def on_rename(self,newdn,olddn): + def on_rename(self,newdn,olddn, merge=False): webnotes.conn.sql("""update `tabCompany` set company_name=%s where name=%s""", (newdn, olddn)) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index fde532c96c..bc438a877a 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -272,7 +272,7 @@ class DocType(DocListController): from webnotes.webutils import clear_cache clear_cache(self.doc.page_name) - def on_rename(self,newdn,olddn): + def on_rename(self,newdn,olddn, merge=False): webnotes.conn.sql("update tabItem set item_code = %s where name = %s", (newdn, olddn)) if self.doc.page_name: from webnotes.webutils import clear_cache diff --git a/stock/doctype/serial_no/serial_no.py b/stock/doctype/serial_no/serial_no.py index bbf55b35e3..e85a947899 100644 --- a/stock/doctype/serial_no/serial_no.py +++ b/stock/doctype/serial_no/serial_no.py @@ -117,7 +117,7 @@ class DocType(StockController): self.make_stock_ledger_entry(1) self.make_gl_entries() - def on_rename(self, new, old): + def on_rename(self, new, old, merge=False): """rename serial_no text fields""" for dt in webnotes.conn.sql("""select parent from tabDocField where fieldname='serial_no' and fieldtype='Text'"""): From 21b854b7cc46723ad44464b61250ea20e864fbff Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 9 May 2013 13:21:13 +0530 Subject: [PATCH 17/24] [rename] [fix] merge related fixes --- setup/doctype/company/company.py | 4 ++++ stock/doctype/serial_no/serial_no.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py index e383fb1bc8..9863d7d28b 100644 --- a/setup/doctype/company/company.py +++ b/setup/doctype/company/company.py @@ -16,6 +16,7 @@ from __future__ import unicode_literals import webnotes +from webnotes import _, msgprint from webnotes.utils import cstr from webnotes.model.doc import Document @@ -288,6 +289,9 @@ class DocType: and value=%s""", self.doc.name) def on_rename(self,newdn,olddn, merge=False): + if merge: + msgprint(_("Sorry. Companies cannot be merged"), raise_exception=True) + webnotes.conn.sql("""update `tabCompany` set company_name=%s where name=%s""", (newdn, olddn)) diff --git a/stock/doctype/serial_no/serial_no.py b/stock/doctype/serial_no/serial_no.py index e85a947899..501b535c6e 100644 --- a/stock/doctype/serial_no/serial_no.py +++ b/stock/doctype/serial_no/serial_no.py @@ -19,7 +19,7 @@ import webnotes from webnotes.utils import cint, getdate, nowdate import datetime -from webnotes import msgprint +from webnotes import msgprint, _ from controllers.stock_controller import StockController @@ -119,6 +119,9 @@ class DocType(StockController): def on_rename(self, new, old, merge=False): """rename serial_no text fields""" + if merge: + msgprint(_("Sorry. Serial Nos. cannot be merged"), raise_exception=True) + for dt in webnotes.conn.sql("""select parent from tabDocField where fieldname='serial_no' and fieldtype='Text'"""): From 5dc5bf9972f9f32ab15e4d5ac79cb865d0180feb Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 9 May 2013 14:15:24 +0530 Subject: [PATCH 18/24] [stock entry] total amount field added --- stock/doctype/stock_entry/stock_entry.py | 6 ++++- stock/doctype/stock_entry/stock_entry.txt | 28 +++++++++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index d08deefa2b..bce0f620d4 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -57,6 +57,7 @@ class DocType(StockController): self.validate_return_reference_doc() self.validate_with_material_request() self.validate_fiscal_year() + self.set_total_amount() def on_submit(self): self.update_serial_no(1) @@ -174,6 +175,9 @@ class DocType(StockController): elif self.doc.purpose != "Material Transfer": self.doc.production_order = None + def set_total_amount(self): + self.doc.total_amount = sum([flt(item.amount) for item in self.doclist.get({"parentfield": "mtn_details"})]) + def make_gl_entries(self): if not cint(webnotes.defaults.get_global_default("auto_inventory_accounting")): return @@ -220,7 +224,7 @@ class DocType(StockController): if not flt(d.incoming_rate): d.incoming_rate = self.get_incoming_rate(args) - d.amount = flt(d.qty) * flt(d.incoming_rate) + d.amount = flt(d.transfer_qty) * flt(d.incoming_rate) def get_incoming_rate(self, args): incoming_rate = 0 diff --git a/stock/doctype/stock_entry/stock_entry.txt b/stock/doctype/stock_entry/stock_entry.txt index fef710b513..d88b0b76fd 100644 --- a/stock/doctype/stock_entry/stock_entry.txt +++ b/stock/doctype/stock_entry/stock_entry.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-03-28 15:56:40", + "creation": "2013-04-09 11:43:55", "docstatus": 0, - "modified": "2013-03-29 15:31:42", + "modified": "2013-05-09 13:31:00", "modified_by": "Administrator", "owner": "Administrator" }, @@ -518,6 +518,14 @@ "read_only": 0, "width": "50%" }, + { + "doctype": "DocField", + "fieldname": "total_amount", + "fieldtype": "Currency", + "label": "Total Amount", + "options": "Company:company:default_currency", + "read_only": 1 + }, { "doctype": "DocField", "fieldname": "project_name", @@ -558,6 +566,14 @@ "read_only": 0, "reqd": 1 }, + { + "doctype": "DocField", + "fieldname": "col5", + "fieldtype": "Column Break", + "print_width": "50%", + "read_only": 0, + "width": "50%" + }, { "allow_on_submit": 0, "doctype": "DocField", @@ -576,14 +592,6 @@ "reqd": 1, "search_index": 0 }, - { - "doctype": "DocField", - "fieldname": "col5", - "fieldtype": "Column Break", - "print_width": "50%", - "read_only": 0, - "width": "50%" - }, { "allow_on_submit": 0, "doctype": "DocField", From ef06a4b349613607359c730a5931a6baef03ee7b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 9 May 2013 15:13:47 +0530 Subject: [PATCH 19/24] [autoname] [cleanup] strip blank spaces and remove autoname where naming_series: can be set in doctype --- accounts/doctype/c_form/c_form.py | 4 ---- accounts/doctype/cost_center/cost_center.py | 2 +- .../journal_voucher/journal_voucher.py | 5 ----- .../doctype/sales_invoice/sales_invoice.py | 4 ---- .../quality_inspection/quality_inspection.py | 20 ++++-------------- .../quality_inspection/quality_inspection.txt | 6 +++--- hr/doctype/attendance/attendance.py | 4 ---- hr/doctype/employee/employee.py | 2 +- .../production_order/production_order.py | 3 --- .../installation_note/installation_note.py | 7 +------ .../installation_note/installation_note.txt | 18 +++++----------- utilities/doctype/address/address.py | 3 ++- utilities/doctype/contact/contact.py | 21 ++++++++++--------- 13 files changed, 28 insertions(+), 71 deletions(-) diff --git a/accounts/doctype/c_form/c_form.py b/accounts/doctype/c_form/c_form.py index 9f89ad5d07..25a8c3bfc1 100644 --- a/accounts/doctype/c_form/c_form.py +++ b/accounts/doctype/c_form/c_form.py @@ -17,16 +17,12 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import flt, getdate -from webnotes.model.doc import make_autoname from webnotes.model.bean import getlist class DocType: def __init__(self,d,dl): self.doc, self.doclist = d,dl - def autoname(self): - self.doc.name = make_autoname(self.doc.naming_series + '.#####') - def validate(self): """Validate invoice that c-form is applicable and no other c-form is received for that""" diff --git a/accounts/doctype/cost_center/cost_center.py b/accounts/doctype/cost_center/cost_center.py index bf0918879f..4e9b7fd9e7 100644 --- a/accounts/doctype/cost_center/cost_center.py +++ b/accounts/doctype/cost_center/cost_center.py @@ -29,7 +29,7 @@ class DocType(DocTypeNestedSet): def autoname(self): company_abbr = webnotes.conn.sql("select abbr from tabCompany where name=%s", self.doc.company_name)[0][0] - self.doc.name = self.doc.cost_center_name + ' - ' + company_abbr + self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr def validate_mandatory(self): if not self.doc.group_or_ledger: diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py index f7d4035a58..a5a4f10f34 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.py +++ b/accounts/doctype/journal_voucher/journal_voucher.py @@ -34,11 +34,6 @@ class DocType(AccountsController): self.credit_days_global = -1 self.is_approving_authority = -1 - def autoname(self): - if not self.doc.naming_series: - webnotes.msgprint("""Naming Series is mandatory""", raise_exception=1) - self.doc.name = make_autoname(self.doc.naming_series+'.#####') - def validate(self): if not self.doc.is_opening: self.doc.is_opening='No' diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 87f73c19ab..b643007add 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -30,7 +30,6 @@ from webnotes import _, msgprint month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12} - from controllers.selling_controller import SellingController class DocType(SellingController): @@ -40,9 +39,6 @@ class DocType(SellingController): self.tname = 'Sales Invoice Item' self.fname = 'entries' - def autoname(self): - self.doc.name = make_autoname(self.doc.naming_series+ '.#####') - def validate(self): super(DocType, self).validate() self.fetch_missing_values() diff --git a/buying/doctype/quality_inspection/quality_inspection.py b/buying/doctype/quality_inspection/quality_inspection.py index 336aabee8d..48a9a7a6f5 100644 --- a/buying/doctype/quality_inspection/quality_inspection.py +++ b/buying/doctype/quality_inspection/quality_inspection.py @@ -17,28 +17,16 @@ from __future__ import unicode_literals import webnotes -from webnotes.model import db_exists -from webnotes.model.doc import addchild, make_autoname -from webnotes.model.bean import copy_doclist - -sql = webnotes.conn.sql - - +from webnotes.model.doc import addchild class DocType: def __init__(self, doc, doclist=[]): self.doc = doc self.doclist = doclist - # Autoname - # --------- - def autoname(self): - self.doc.name = make_autoname(self.doc.naming_series+'.#####') - - def get_item_specification_details(self): self.doclist = self.doc.clear_table(self.doclist, 'qa_specification_details') - specification = sql("select specification, value from `tabItem Quality Inspection Parameter` \ + specification = webnotes.conn.sql("select specification, value from `tabItem Quality Inspection Parameter` \ where parent = '%s' order by idx" % (self.doc.item_code)) for d in specification: child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', self.doclist) @@ -48,13 +36,13 @@ class DocType: def on_submit(self): if self.doc.purchase_receipt_no: - sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '%s', t2.modified = '%s' \ + webnotes.conn.sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '%s', t2.modified = '%s' \ where t1.parent = '%s' and t1.item_code = '%s' and t1.parent = t2.name" \ % (self.doc.name, self.doc.modified, self.doc.purchase_receipt_no, self.doc.item_code)) def on_cancel(self): if self.doc.purchase_receipt_no: - sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '', t2.modified = '%s' \ + webnotes.conn.sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '', t2.modified = '%s' \ where t1.parent = '%s' and t1.item_code = '%s' and t1.parent = t2.name" \ % (self.doc.modified, self.doc.purchase_receipt_no, self.doc.item_code)) diff --git a/buying/doctype/quality_inspection/quality_inspection.txt b/buying/doctype/quality_inspection/quality_inspection.txt index e8650e0554..60ede7093e 100644 --- a/buying/doctype/quality_inspection/quality_inspection.txt +++ b/buying/doctype/quality_inspection/quality_inspection.txt @@ -1,13 +1,13 @@ [ { - "creation": "2013-01-10 16:34:11", + "creation": "2013-04-30 13:13:03", "docstatus": 0, - "modified": "2013-01-22 14:57:21", + "modified": "2013-05-09 14:34:10", "modified_by": "Administrator", "owner": "Administrator" }, { - "autoname": "QAI/.######", + "autoname": "naming_series:", "doctype": "DocType", "is_submittable": 1, "module": "Buying", diff --git a/hr/doctype/attendance/attendance.py b/hr/doctype/attendance/attendance.py index 67af429dd0..ac41acf815 100644 --- a/hr/doctype/attendance/attendance.py +++ b/hr/doctype/attendance/attendance.py @@ -18,7 +18,6 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import getdate, nowdate -from webnotes.model.doc import make_autoname from webnotes import msgprint, _ sql = webnotes.conn.sql @@ -28,9 +27,6 @@ class DocType: self.doc = doc self.doclist = doclist - def autoname(self): - self.doc.name = make_autoname(self.doc.naming_series+'.#####') - def get_emp_name(self): return { "employee_name": webnotes.conn.get_value("Employee", diff --git a/hr/doctype/employee/employee.py b/hr/doctype/employee/employee.py index 87fe9a45e9..9a9ed136af 100644 --- a/hr/doctype/employee/employee.py +++ b/hr/doctype/employee/employee.py @@ -36,7 +36,7 @@ class DocType: if ret[0][0]=='Naming Series': self.doc.name = make_autoname(self.doc.naming_series + '.####') elif ret[0][0]=='Employee Number': - self.doc.name = make_autoname(self.doc.employee_number) + self.doc.name = self.doc.employee_number self.doc.employee = self.doc.name diff --git a/manufacturing/doctype/production_order/production_order.py b/manufacturing/doctype/production_order/production_order.py index a0498e063f..c76a87f6b8 100644 --- a/manufacturing/doctype/production_order/production_order.py +++ b/manufacturing/doctype/production_order/production_order.py @@ -18,9 +18,6 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import cstr, flt, now, nowdate -from webnotes.model import db_exists -from webnotes.model.doc import make_autoname -from webnotes.model.bean import copy_doclist from webnotes.model.code import get_obj from webnotes import msgprint diff --git a/selling/doctype/installation_note/installation_note.py b/selling/doctype/installation_note/installation_note.py index b0e1d966d9..ea20d51d64 100644 --- a/selling/doctype/installation_note/installation_note.py +++ b/selling/doctype/installation_note/installation_note.py @@ -18,9 +18,7 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import cstr, getdate -from webnotes.model import db_exists -from webnotes.model.doc import make_autoname -from webnotes.model.bean import getlist, copy_doclist +from webnotes.model.bean import getlist from webnotes.model.code import get_obj from webnotes import msgprint from stock.utils import get_valid_serial_nos @@ -37,9 +35,6 @@ class DocType(TransactionBase): self.tname = 'Installation Note Item' self.fname = 'installed_item_details' - def autoname(self): - self.doc.name = make_autoname(self.doc.naming_series+'.#####') - def validate(self): self.validate_fiscal_year() self.validate_installation_date() diff --git a/selling/doctype/installation_note/installation_note.txt b/selling/doctype/installation_note/installation_note.txt index 52917e0b01..9dd851d583 100644 --- a/selling/doctype/installation_note/installation_note.txt +++ b/selling/doctype/installation_note/installation_note.txt @@ -1,13 +1,13 @@ [ { - "creation": "2013-01-10 16:34:18", + "creation": "2013-04-30 13:13:06", "docstatus": 0, - "modified": "2013-01-22 14:56:02", + "modified": "2013-05-09 14:43:28", "modified_by": "Administrator", "owner": "Administrator" }, { - "autoname": "IN/.####", + "autoname": "naming_series:", "doctype": "DocType", "is_submittable": 1, "module": "Selling", @@ -33,6 +33,7 @@ "permlevel": 0, "read": 1, "report": 1, + "role": "Sales User", "submit": 1, "write": 1 }, @@ -302,15 +303,6 @@ "options": "Installation Note Item" }, { - "doctype": "DocPerm", - "role": "System Manager" - }, - { - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "doctype": "DocPerm", - "role": "Sales Manager" + "doctype": "DocPerm" } ] \ No newline at end of file diff --git a/utilities/doctype/address/address.py b/utilities/doctype/address/address.py index 243bbdd7e3..cfcbea582f 100644 --- a/utilities/doctype/address/address.py +++ b/utilities/doctype/address/address.py @@ -18,6 +18,7 @@ from __future__ import unicode_literals import webnotes from webnotes import msgprint +from webnotes.utils import cstr class DocType: def __init__(self, doc, doclist=[]): @@ -29,7 +30,7 @@ class DocType: self.doc.address_title = self.doc.customer or self.doc.supplier or self.doc.sales_partner if self.doc.address_title: - self.doc.name = self.doc.address_title + "-" + self.doc.address_type + self.doc.name = cstr(self.doc.address_title).strip() + "-" + cstr(self.doc.address_type).strip() else: webnotes.msgprint("""Address Title is mandatory.""", raise_exception=True) diff --git a/utilities/doctype/contact/contact.py b/utilities/doctype/contact/contact.py index bceee7d6a1..a19501f100 100644 --- a/utilities/doctype/contact/contact.py +++ b/utilities/doctype/contact/contact.py @@ -16,7 +16,7 @@ from __future__ import unicode_literals import webnotes - +from webnotes.utils import cstr from utilities.transaction_base import TransactionBase @@ -32,15 +32,16 @@ class DocType(TransactionBase): webnotes.conn.set(self.doc, 'status', 'Replied') def autoname(self): - if self.doc.customer: - self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.customer - elif self.doc.supplier: - self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.supplier - elif self.doc.sales_partner: - self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.sales_partner - else: - self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') - + # concat first and last name + self.doc.name = " ".join(filter(None, + [cstr(self.doc.fields.get(f)).strip() for f in ["first_name", "last_name"]])) + + # concat party name if reqd + for fieldname in ("customer", "supplier", "sales_partner"): + if self.doc.fields.get(fieldname): + self.doc.name = self.doc.name + "-" + cstr(self.doc.fields.get(fieldname)).strip() + break + def validate(self): self.validate_primary_contact() From e1b2ae573909b9abfae9ad0fc716822d6f88c66f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 9 May 2013 16:56:19 +0530 Subject: [PATCH 20/24] [fixes] float precision for pur invoice --- accounts/doctype/purchase_invoice/purchase_invoice.py | 8 +++++--- controllers/buying_controller.py | 10 +++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py index 50d5d43d80..c53b6d94fc 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -464,15 +464,17 @@ class DocType(BuyingController): # if auto inventory accounting enabled and stock item, # then do stock related gl entries # expense will be booked in sales invoice - stock_item_and_auto_inventory_accounting = True + valuation_amt = (flt(item.amount, self.precision.item.amount) + + flt(item.item_tax_amount, self.precision.item.item_tax_amount) + + flt(item.rm_supp_cost, self.precision.item.rm_supp_cost)) + gl_entries.append( self.get_gl_dict({ "account": stock_account, "against": self.doc.credit_to, - "debit": flt(item.valuation_rate) * flt(item.conversion_factor) \ - * flt(item.qty), + "debit": valuation_amt, "remarks": self.doc.remarks or "Accounting Entry for Stock" }) ) diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index 9e181bc8fe..28d2db646b 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -367,9 +367,13 @@ class BuyingController(StockController): if d.item_code and d.qty: # if no item code, which is sometimes the case in purchase invoice, # then it is not possible to track valuation against it - d.valuation_rate = (flt(d.purchase_rate or d.rate) - + (flt(d.item_tax_amount) + flt(d.rm_supp_cost)) / flt(d.qty) - ) / flt(d.conversion_factor) + d.valuation_rate = flt((flt(d.purchase_rate, self.precision.item.purchase_rate) or + flt(d.rate, self.precision.item.rate) + + (flt(d.item_tax_amount, self.precision.item.item_tax_amount) + + flt(d.rm_supp_cost, self.precision.item.rm_supp_cost)) / + flt(d.qty, self.precision.item.qty)) / + flt(d.conversion_factor, self.precision.item.conversion_factor), + self.precision.item.valuation_rate) else: d.valuation_rate = 0.0 From 9e1d120186846d720c7e3359ed6567f2f5efdb72 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 9 May 2013 19:34:34 +0530 Subject: [PATCH 21/24] [time log] [query] search task based on subject --- projects/doctype/time_log/time_log.js | 12 ++++++++---- projects/utils.py | 17 ++++++++++++++++- public/js/queries.js | 6 +++++- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/projects/doctype/time_log/time_log.js b/projects/doctype/time_log/time_log.js index a6023320f1..22f9610b8f 100644 --- a/projects/doctype/time_log/time_log.js +++ b/projects/doctype/time_log/time_log.js @@ -1,5 +1,9 @@ -$.extend(cur_frm.cscript, { - refresh: function(doc) { - +wn.provide("erpnext.projects"); + +erpnext.projects.TimeLog = wn.ui.form.Controller.extend({ + setup: function() { + this.frm.set_query("task", erpnext.queries.task); } -}); \ No newline at end of file +}); + +cur_frm.cscript = new erpnext.projects.TimeLog({frm: cur_frm}); \ No newline at end of file diff --git a/projects/utils.py b/projects/utils.py index 7a45b08d9d..70f6995bf5 100644 --- a/projects/utils.py +++ b/projects/utils.py @@ -5,4 +5,19 @@ import webnotes @webnotes.whitelist() def get_time_log_list(doctype, txt, searchfield, start, page_len, filters): - return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"]) \ No newline at end of file + return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"]) + +@webnotes.whitelist() +def query_task(doctype, txt, searchfield, start, page_len, filters): + search_string = "%%%s%%" % txt + order_by_string = "%s%%" % txt + return webnotes.conn.sql("""select name, subject from `tabTask` + where `%s` like %s or `subject` like %s + order by + case when `subject` like %s then 0 else 1 end, + case when `%s` like %s then 0 else 1 end, + `%s`, + subject + limit %s, %s""" % + (searchfield, "%s", "%s", "%s", searchfield, "%s", searchfield, "%s", "%s"), + (search_string, search_string, order_by_string, order_by_string, start, page_len)) \ No newline at end of file diff --git a/public/js/queries.js b/public/js/queries.js index 9809cd980d..24ddc13590 100644 --- a/public/js/queries.js +++ b/public/js/queries.js @@ -160,4 +160,8 @@ erpnext.queries.bom = function(opts) { : "") + " LIMIT 50" -} \ No newline at end of file +} + +erpnext.queries.task = function() { + return { query: "projects.utils.query_task" }; +}; \ No newline at end of file From 2186e836703e9fbcbbdb922fa55f30e6198f81ea Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 10 May 2013 00:39:15 +0530 Subject: [PATCH 22/24] [lead to customer] [fix] fix for creating customer from lead when there are restrictive permissions based on company for creating customer --- selling/doctype/lead/lead.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js index d8d322d324..118b4c723e 100644 --- a/selling/doctype/lead/lead.js +++ b/selling/doctype/lead/lead.js @@ -104,7 +104,17 @@ cur_frm.cscript['Create Customer'] = function(){ 'from_to_list':"[['Lead', 'Customer']]" }, function(r,rt) { - loaddoc("Customer", n); + wn.model.with_doctype("Customer", function() { + var customer = wn.model.get_doc("Customer", n); + var customer_copy = $.extend({}, customer); + + var updated = wn.model.set_default_values(customer_copy); + $.each(updated, function(i, f) { + if(!customer[f]) customer[f] = customer_copy[f]; + }); + + loaddoc("Customer", n); + }); } ); } From e762b264b130431d582a0c8b13639400204ac3ef Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 10 May 2013 11:11:46 +0530 Subject: [PATCH 23/24] [fixes] bom autoname --- manufacturing/doctype/bom/bom.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manufacturing/doctype/bom/bom.py b/manufacturing/doctype/bom/bom.py index 5f42f4da5d..5a1d47fd4e 100644 --- a/manufacturing/doctype/bom/bom.py +++ b/manufacturing/doctype/bom/bom.py @@ -34,7 +34,8 @@ class DocType: last_name = sql("""select max(name) from `tabBOM` where name like "BOM/%s/%%" """ % cstr(self.doc.item).replace('"', '\\"')) if last_name: - idx = cint(cstr(last_name[0][0]).split('/')[-1]) + 1 + idx = cint(cstr(last_name[0][0]).split('/')[-1].split('-')[0]) + 1 + else: idx = 1 self.doc.name = 'BOM/' + self.doc.item + ('/%.3i' % idx) From 1252729e1cfcc41c5df3d4fc13741f7d804da9f0 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 10 May 2013 13:38:23 +0530 Subject: [PATCH 24/24] [sales invoice] [fix] bug fix in setting pos values on save --- accounts/doctype/sales_invoice/sales_invoice.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index b643007add..d18b967dfa 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -191,11 +191,11 @@ class DocType(SellingController): self.doc.fields[fieldname] = pos.get(fieldname) # set pos values in items - for doc in self.doclist.get({"parentfield": "entries"}): - if doc.fields.get('item_code'): - for fieldname, val in self.apply_pos_settings(doc.fields).items(): - if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)): - doc.fields[fieldname] = val + for item in self.doclist.get({"parentfield": "entries"}): + if item.fields.get('item_code'): + for fieldname, val in self.apply_pos_settings(item.fields).items(): + if (not for_validate) or (for_validate and not item.fields.get(fieldname)): + item.fields[fieldname] = val # fetch terms if self.doc.tc_name and not self.doc.terms: