diff --git a/hr/DocType Mapper/Appraisal Template-Appraisal/Appraisal Template-Appraisal.txt b/hr/DocType Mapper/Appraisal Template-Appraisal/Appraisal Template-Appraisal.txt deleted file mode 100644 index 69d171ff79..0000000000 --- a/hr/DocType Mapper/Appraisal Template-Appraisal/Appraisal Template-Appraisal.txt +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "owner": "ashwini@webnotestech.com", - "docstatus": 0, - "creation": "2010-09-01 15:47:59", - "modified_by": "Administrator", - "modified": "2012-04-03 12:49:50" - }, - { - "match_id": 0, - "parent": "Appraisal Template-Appraisal", - "from_field": "kra_sheet", - "doctype": "Table Mapper Detail", - "to_table": "Appraisal Goal", - "name": "__common__", - "to_field": "appraisal_details", - "parenttype": "DocType Mapper", - "from_table": "Appraisal Template Goal", - "validation_logic": "name is not Null", - "parentfield": "table_mapper_details" - }, - { - "name": "__common__", - "to_doctype": "Appraisal", - "module": "HR", - "doctype": "DocType Mapper", - "from_doctype": "Appraisal Template" - }, - { - "name": "Appraisal Template-Appraisal", - "doctype": "DocType Mapper" - }, - { - "doctype": "Table Mapper Detail" - } -] \ No newline at end of file diff --git a/hr/DocType Mapper/Salary Structure-Salary Slip/Salary Structure-Salary Slip.txt b/hr/DocType Mapper/Salary Structure-Salary Slip/Salary Structure-Salary Slip.txt deleted file mode 100644 index 2cf9075e13..0000000000 --- a/hr/DocType Mapper/Salary Structure-Salary Slip/Salary Structure-Salary Slip.txt +++ /dev/null @@ -1,100 +0,0 @@ -[ - { - "owner": "harshada@webnotestech.com", - "docstatus": 0, - "creation": "2010-12-14 10:33:11", - "modified_by": "Administrator", - "modified": "2011-09-15 15:04:44" - }, - { - "name": "__common__", - "parent": "Salary Structure-Salary Slip", - "doctype": "Table Mapper Detail", - "parenttype": "DocType Mapper", - "validation_logic": "name is not null", - "parentfield": "table_mapper_details" - }, - { - "map": "Yes", - "name": "__common__", - "parent": "Salary Structure-Salary Slip", - "doctype": "Field Mapper Detail", - "parenttype": "DocType Mapper", - "parentfield": "field_mapper_details" - }, - { - "name": "__common__", - "to_doctype": "Salary Slip", - "module": "HR", - "doctype": "DocType Mapper", - "from_doctype": "Salary Structure" - }, - { - "name": "Salary Structure-Salary Slip", - "doctype": "DocType Mapper" - }, - { - "to_field": "gross_pay", - "doctype": "Field Mapper Detail", - "match_id": 0, - "from_field": "total_earning" - }, - { - "to_field": "e_amount", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "modified_value" - }, - { - "to_field": "d_amount", - "doctype": "Field Mapper Detail", - "match_id": 2, - "from_field": "d_modified_amt" - }, - { - "to_field": "e_modified_amount", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "modified_value" - }, - { - "to_field": "e_depends_on_lwp", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "depend_on_lwp" - }, - { - "to_field": "d_modified_amount", - "doctype": "Field Mapper Detail", - "match_id": 2, - "from_field": "d_modified_amt" - }, - { - "to_field": "d_depends_on_lwp", - "doctype": "Field Mapper Detail", - "match_id": 2, - "from_field": "depend_on_lwp" - }, - { - "to_table": "Salary Slip", - "doctype": "Table Mapper Detail", - "match_id": 0, - "from_table": "Salary Structure" - }, - { - "match_id": 1, - "to_field": "earning_details", - "doctype": "Table Mapper Detail", - "from_field": "earning_details", - "from_table": "Salary Structure Earning", - "to_table": "Salary Slip Earning" - }, - { - "match_id": 2, - "to_field": "deduction_details", - "doctype": "Table Mapper Detail", - "from_field": "deduction_details", - "from_table": "Salary Structure Deduction", - "to_table": "Salary Slip Deduction" - } -] \ No newline at end of file diff --git a/hr/doctype/appraisal/appraisal.js b/hr/doctype/appraisal/appraisal.js index 31fdb8e82c..601f3fc3cb 100644 --- a/hr/doctype/appraisal/appraisal.js +++ b/hr/doctype/appraisal/appraisal.js @@ -37,10 +37,10 @@ cur_frm.cscript.refresh = function(doc,cdt,cdn){ } cur_frm.cscript.kra_template = function(doc, dt, dn) { - $c_obj(make_doclist(doc.doctype, doc.name), 'fetch_kra', '', - function() { - cur_frm.refresh(); - }); + wn.model.map_current_doc({ + method: "hr.doctype.appraisal.appraisal.fetch_appraisal_template", + source_name: cur_frm.doc.kra_template, + }); } cur_frm.cscript.calculate_total_score = function(doc,cdt,cdn){ diff --git a/hr/doctype/appraisal/appraisal.py b/hr/doctype/appraisal/appraisal.py index eaa609c3ec..8a50d7c746 100644 --- a/hr/doctype/appraisal/appraisal.py +++ b/hr/doctype/appraisal/appraisal.py @@ -19,12 +19,8 @@ import webnotes from webnotes.utils import cstr, flt, getdate from webnotes.model.bean import getlist -from webnotes.model.code import get_obj from webnotes import msgprint -sql = webnotes.conn.sql - - class DocType: def __init__(self, doc, doclist=[]): self.doc = doc @@ -39,23 +35,18 @@ class DocType: self.calculate_total() def get_employee_name(self): - emp_nm = sql("select employee_name from `tabEmployee` where name=%s", self.doc.employee) + emp_nm = webnotes.conn.sql("select employee_name from `tabEmployee` where name=%s", self.doc.employee) emp_nm= emp_nm and emp_nm[0][0] or '' self.doc.employee_name = emp_nm return emp_nm - - def fetch_kra(self): - self.doclist = self.doc.clear_table(self.doclist,'appraisal_details') - get_obj('DocType Mapper', 'Appraisal Template-Appraisal').dt_map('Appraisal Template', 'Appraisal', - self.doc.kra_template, self.doc, self.doclist, "[['Appraisal Template','Appraisal'],['Appraisal Template Goal', 'Appraisal Goal']]") - + def validate_dates(self): if getdate(self.doc.start_date) > getdate(self.doc.end_date): msgprint("End Date can not be less than Start Date") raise Exception def validate_existing_appraisal(self): - chk = sql("""select name from `tabAppraisal` where employee=%s + chk = webnotes.conn.sql("""select name from `tabAppraisal` where employee=%s and (status='Submitted' or status='Completed') and ((start_date>=%s and start_date<=%s) or (end_date>=%s and end_date<=%s))""",(self.doc.employee,self.doc.start_date,self.doc.end_date,self.doc.start_date,self.doc.end_date)) @@ -88,3 +79,18 @@ class DocType: def on_cancel(self): webnotes.conn.set(self.doc, 'status', 'Cancelled') + +@webnotes.whitelist() +def fetch_appraisal_template(source_name, target_doclist=None): + from webnotes.model.mapper import get_mapped_doclist + + doclist = get_mapped_doclist("Appraisal Template", source_name, { + "Appraisal Template": { + "doctype": "Appraisal", + }, + "Appraisal Template Goal": { + "doctype": "Appraisal Goal", + } + }, target_doclist) + + return [d.fields for d in doclist] \ No newline at end of file diff --git a/hr/doctype/salary_structure/salary_structure.js b/hr/doctype/salary_structure/salary_structure.js index 873ba177ce..2979243173 100644 --- a/hr/doctype/salary_structure/salary_structure.js +++ b/hr/doctype/salary_structure/salary_structure.js @@ -16,8 +16,6 @@ cur_frm.add_fetch('employee', 'company', 'company'); -// On load -//======================================================================= cur_frm.cscript.onload = function(doc, dt, dn){ e_tbl = getchildren('Salary Structure Earning', doc.name, 'earning_details', doc.doctype); d_tbl = getchildren('Salary Structure Deduction', doc.name, 'deduction_details', doc.doctype); @@ -25,8 +23,6 @@ cur_frm.cscript.onload = function(doc, dt, dn){ $c_obj(make_doclist(doc.doctype,doc.name),'make_earn_ded_table','', function(r, rt) { refresh_many(['earning_details', 'deduction_details']);}); } -// On refresh -//======================================================================= cur_frm.cscript.refresh = function(doc, dt, dn){ if((!doc.__islocal) && (doc.is_active == 'Yes')){ cur_frm.add_custom_button('Make Salary Slip', cur_frm.cscript['Make Salary Slip']); @@ -35,56 +31,26 @@ cur_frm.cscript.refresh = function(doc, dt, dn){ cur_frm.toggle_enable('employee', doc.__islocal); } - -// Make Salry Slip -//======================================================================= -cur_frm.cscript['Make Salary Slip'] = function(){ - var doc = cur_frm.doc; - var callback = function(r,rt){ - ret = r.message; - n = wn.model.make_new_doc_and_get_name("Salary Slip"); - $c('dt_map', args={ - 'docs':wn.model.compress([locals["Salary Slip"][n]]), - 'from_doctype':'Salary Structure', - 'to_doctype':'Salary Slip', - 'from_docname':doc.name, - 'from_to_list':"[['Salary Structure', 'Salary Slip'], ['Salary Structure Earning', 'Salary Slip Earning'], ['Salary Structure Deduction', 'Salary Slip Deduction']]" - }, - function(r,rt) { - n.fiscal_year = sys_defaults.fiscal_year; - n.bank_name = ret['bank_name']; - n.bank_account_no = ret['bank_ac_no']; - n.esic_no=ret['esic_no']; - n.pf_no= ret['pf_no']; - loaddoc("Salary Slip", n); - } - ); - } - $c_obj(make_doclist(doc.doctype,doc.name),'get_ss_values',cur_frm.doc.employee, callback); +cur_frm.cscript['Make Salary Slip'] = function() { + wn.model.open_mapped_doc({ + method: "hr.doctype.salary_structure.salary_structure.make_salary_slip", + source_name: cur_frm.doc.name + }); } - -// get employee details -//======================================================================= cur_frm.cscript.employee = function(doc, dt, dn){ if (doc.employee) get_server_fields('get_employee_details','','',doc,dt,dn); } -// calculate earning totals -//======================================================================= cur_frm.cscript.modified_value = function(doc, cdt, cdn){ calculate_totals(doc, cdt, cdn); } -// calculate deduction totals -//======================================================================= cur_frm.cscript.d_modified_amt = function(doc, cdt, cdn){ calculate_totals(doc, cdt, cdn); } -// calculate totals -//======================================================================= var calculate_totals = function(doc, cdt, cdn) { var tbl1 = getchildren('Salary Structure Earning', doc.name, 'earning_details', doc.doctype); var tbl2 = getchildren('Salary Structure Deduction', doc.name, 'deduction_details', doc.doctype); @@ -102,8 +68,6 @@ var calculate_totals = function(doc, cdt, cdn) { refresh_many(['total_earning', 'total_deduction', 'net_pay']); } -// validate -//======================================================================= cur_frm.cscript.validate = function(doc, cdt, cdn) { calculate_totals(doc, cdt, cdn); } diff --git a/hr/doctype/salary_structure/salary_structure.py b/hr/doctype/salary_structure/salary_structure.py index 018aab7e7c..d7777561f8 100644 --- a/hr/doctype/salary_structure/salary_structure.py +++ b/hr/doctype/salary_structure/salary_structure.py @@ -94,4 +94,41 @@ class DocType: def validate(self): self.check_existing() - self.validate_amount() \ No newline at end of file + self.validate_amount() + +@webnotes.whitelist() +def make_salary_slip(source_name, target_doclist=None): + from webnotes.model.mapper import get_mapped_doclist + + def postprocess(source, target): + emp = webnotes.conn.get_value("Employee", source.doc.employee, + ["bank_name", "bank_ac_no", "esic_card_no", "pf_number"], as_dict=1) + if emp: + target[0].bank_name = emp.bank_name + target[0].bank_ac_no = emp.bank_ac_no + target[0].esic_no = emp.esic_card_no + target[0].pf_no = emp.pf_number + + doclist = get_mapped_doclist("Salary Structure", source_name, { + "Salary Structure": { + "doctype": "Salary Slip", + "field_map": { + "total_earning": "gross_pay" + } + }, + "Salary Structure Deduction": { + "doctype": "Salary Slip Deduction", + "field_map": { + "depend_on_lwp": "d_depends_on_lwp" + } + }, + "Salary Structure Earning": { + "doctype": "Salary Slip Earning", + "field_map": { + "depend_on_lwp": "e_depends_on_lwp", + "modified_value": "e_modified_amount" + } + } + }, target_doclist, postprocess) + + return [d.fields for d in doclist] \ No newline at end of file diff --git a/patches/july_2013/p01_remove_doctype_mappers.py b/patches/july_2013/p01_remove_doctype_mappers.py new file mode 100644 index 0000000000..901b1b6cb0 --- /dev/null +++ b/patches/july_2013/p01_remove_doctype_mappers.py @@ -0,0 +1,4 @@ +import webnotes +def execute(): + for m in webnotes.conn.sql("select name from `tabDocType Mapper`"): + webnotes.delete_doc("DocType Mapper", m[0]) \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index bbe51fadeb..ad01ce60eb 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -250,4 +250,5 @@ patch_list = [ "patches.june_2013.p08_shopping_cart_settings", "patches.june_2013.p09_update_global_defaults", "patches.june_2013.p10_lead_address", + "patches.july_2013.p01_remove_doctype_mappers", ] \ No newline at end of file diff --git a/selling/DocType Mapper/Delivery Note-Installation Note/Delivery Note-Installation Note.txt b/selling/DocType Mapper/Delivery Note-Installation Note/Delivery Note-Installation Note.txt deleted file mode 100644 index 086ad7f182..0000000000 --- a/selling/DocType Mapper/Delivery Note-Installation Note/Delivery Note-Installation Note.txt +++ /dev/null @@ -1,118 +0,0 @@ -[ - { - "owner": "Administrator", - "docstatus": 0, - "creation": "2010-08-08 17:09:34", - "modified_by": "Administrator", - "modified": "2011-09-15 15:04:42" - }, - { - "name": "__common__", - "parent": "Delivery Note-Installation Note", - "doctype": "Table Mapper Detail", - "parenttype": "DocType Mapper", - "parentfield": "table_mapper_details" - }, - { - "map": "Yes", - "name": "__common__", - "parent": "Delivery Note-Installation Note", - "doctype": "Field Mapper Detail", - "parenttype": "DocType Mapper", - "parentfield": "field_mapper_details" - }, - { - "name": "__common__", - "to_doctype": "Installation Note", - "module": "Selling", - "doctype": "DocType Mapper", - "ref_doc_submitted": 1, - "from_doctype": "Delivery Note" - }, - { - "name": "Delivery Note-Installation Note", - "doctype": "DocType Mapper" - }, - { - "match_id": 0, - "to_field": "company", - "doctype": "Field Mapper Detail", - "from_field": "company", - "checking_operator": "=" - }, - { - "match_id": 0, - "to_field": "customer", - "doctype": "Field Mapper Detail", - "from_field": "customer", - "checking_operator": "=" - }, - { - "to_field": "delivery_note_no", - "doctype": "Field Mapper Detail", - "match_id": 0, - "from_field": "name" - }, - { - "to_field": "prevdoc_detail_docname", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "name" - }, - { - "to_field": "prevdoc_docname", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "parent" - }, - { - "to_field": "prevdoc_doctype", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "parenttype" - }, - { - "to_field": "qty", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "eval: flt(obj.qty) - flt(obj.installed_qty)" - }, - { - "to_field": "prevdoc_date", - "doctype": "Field Mapper Detail", - "match_id": 2, - "from_field": "posting_date" - }, - { - "to_field": "serial_no", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "serial_no" - }, - { - "match_id": 1, - "to_field": "installed_item_details", - "doctype": "Table Mapper Detail", - "from_field": "delivery_note_details", - "from_table": "Delivery Note Item", - "to_table": "Installation Note Item", - "validation_logic": "qty > ifnull(installed_qty,0) and docstatus = 1" - }, - { - "match_id": 0, - "doctype": "Table Mapper Detail", - "from_table": "Delivery Note", - "to_table": "Installation Note", - "validation_logic": "docstatus = 1" - }, - { - "reference_key": "prevdoc_docname", - "match_id": 2, - "reference_doctype_key": "prevdoc_doctype", - "to_field": "installed_item_details", - "doctype": "Table Mapper Detail", - "from_table": "Delivery Note", - "to_table": "Installation Note Item", - "validation_logic": "docstatus = 1" - } -] \ No newline at end of file diff --git a/selling/DocType Mapper/Opportunity-Quotation/Opportunity-Quotation.txt b/selling/DocType Mapper/Opportunity-Quotation/Opportunity-Quotation.txt deleted file mode 100644 index ffa85e5df2..0000000000 --- a/selling/DocType Mapper/Opportunity-Quotation/Opportunity-Quotation.txt +++ /dev/null @@ -1,113 +0,0 @@ -[ - { - "owner": "Administrator", - "docstatus": 0, - "creation": "2010-08-08 17:09:34", - "modified_by": "Administrator", - "modified": "2012-04-03 12:49:50" - }, - { - "name": "__common__", - "parent": "Opportunity-Quotation", - "doctype": "Table Mapper Detail", - "parenttype": "DocType Mapper", - "validation_logic": "docstatus=1", - "parentfield": "table_mapper_details" - }, - { - "name": "__common__", - "parent": "Opportunity-Quotation", - "doctype": "Field Mapper Detail", - "parenttype": "DocType Mapper", - "parentfield": "field_mapper_details" - }, - { - "name": "__common__", - "to_doctype": "Quotation", - "module": "Selling", - "doctype": "DocType Mapper", - "ref_doc_submitted": 1, - "from_doctype": "Opportunity" - }, - { - "name": "Opportunity-Quotation", - "doctype": "DocType Mapper" - }, - { - "map": "Yes", - "match_id": 1, - "to_field": "stock_uom", - "doctype": "Field Mapper Detail", - "from_field": "uom" - }, - { - "map": "Yes", - "match_id": 0, - "to_field": "enq_no", - "doctype": "Field Mapper Detail", - "from_field": "name" - }, - { - "map": "Yes", - "match_id": 1, - "to_field": "prevdoc_docname", - "doctype": "Field Mapper Detail", - "from_field": "parent" - }, - { - "map": "Yes", - "match_id": 1, - "to_field": "prevdoc_doctype", - "doctype": "Field Mapper Detail", - "from_field": "parenttype" - }, - { - "map": "Yes", - "match_id": 0, - "to_field": "quotation_to", - "doctype": "Field Mapper Detail", - "from_field": "enquiry_from" - }, - { - "map": "Yes", - "match_id": 0, - "to_field": "order_type", - "doctype": "Field Mapper Detail", - "from_field": "enquiry_type" - }, - { - "map": "No", - "match_id": 0, - "to_field": "transaction_date", - "doctype": "Field Mapper Detail", - "from_field": "transaction_date" - }, - { - "map": "No", - "match_id": 0, - "to_field": "status", - "doctype": "Field Mapper Detail", - "from_field": "status" - }, - { - "map": "No", - "match_id": 0, - "to_field": "naming_series", - "doctype": "Field Mapper Detail", - "from_field": "naming_series" - }, - { - "to_table": "Quotation", - "doctype": "Table Mapper Detail", - "match_id": 0, - "from_table": "Opportunity" - }, - { - "match_id": 1, - "to_field": "quotation_details", - "doctype": "Table Mapper Detail", - "from_field": "enq_details", - "from_table": "Opportunity Item", - "to_table": "Quotation Item" - } -] \ No newline at end of file diff --git a/selling/doctype/installation_note/installation_note.js b/selling/doctype/installation_note/installation_note.js index 61d0484a08..4fd8678eaf 100644 --- a/selling/doctype/installation_note/installation_note.js +++ b/selling/doctype/installation_note/installation_note.js @@ -36,6 +36,14 @@ erpnext.selling.InstallationNote = wn.ui.form.Controller.extend({ 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']); } + }, + get_items: function() { + wn.model.map_current_doc({ + method: "stock.doctype.delivery_note.delivery_note.make_installation_note", + source_name: cur_frm.doc.delivery_note_no, + }) + unhide_field(['customer_address', 'contact_person', 'customer_name', 'address_display', + 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']); } }); @@ -66,14 +74,6 @@ cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) { return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50'; } -cur_frm.cscript.get_items = function(doc, dt, dn) { - var callback = function(r,rt) { - unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']); - cur_frm.refresh(); - } - get_server_fields('pull_delivery_note_details','','',doc, dt, dn,1,callback); -} - cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) { if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1); } diff --git a/selling/doctype/installation_note/installation_note.py b/selling/doctype/installation_note/installation_note.py index 63e1bae3fa..62c5b66f33 100644 --- a/selling/doctype/installation_note/installation_note.py +++ b/selling/doctype/installation_note/installation_note.py @@ -53,14 +53,7 @@ class DocType(TransactionBase): sales_com_obj.check_active_sales_items(self) sales_com_obj.get_prevdoc_date(self) self.validate_reference_value() - - def pull_delivery_note_details(self): - self.validate_prev_docname() - self.doclist = get_obj('DocType Mapper', 'Delivery Note-Installation Note').dt_map( - 'Delivery Note', 'Installation Note', self.doc.delivery_note_no, - self.doc, self.doclist, "[['Delivery Note', 'Installation Note'], \ - ['Delivery Note Item', 'Installation Note Item']]") - + def validate_prev_docname(self): for d in getlist(self.doclist, 'installed_item_details'): if self.doc.delivery_note_no == d.prevdoc_docname: diff --git a/selling/doctype/installation_note/installation_note.txt b/selling/doctype/installation_note/installation_note.txt index 9a9986390d..d148f3125b 100644 --- a/selling/doctype/installation_note/installation_note.txt +++ b/selling/doctype/installation_note/installation_note.txt @@ -2,7 +2,7 @@ { "creation": "2013-04-30 13:13:06", "docstatus": 0, - "modified": "2013-07-05 14:40:56", + "modified": "2013-07-07 18:10:24", "modified_by": "Administrator", "owner": "Administrator" }, @@ -23,20 +23,13 @@ "permlevel": 0 }, { - "amend": 1, - "cancel": 1, - "create": 1, "doctype": "DocPerm", "name": "__common__", "parent": "Installation Note", "parentfield": "permissions", "parenttype": "DocType", - "permlevel": 0, "read": 1, - "report": 1, - "role": "Sales User", - "submit": 1, - "write": 1 + "report": 1 }, { "doctype": "DocType", @@ -267,7 +260,6 @@ "hidden": 0, "label": "Get Items", "oldfieldtype": "Button", - "options": "pull_delivery_note_details", "print_hide": 1 }, { @@ -280,6 +272,60 @@ "options": "Installation Note Item" }, { - "doctype": "DocPerm" + "amend": 1, + "cancel": 1, + "create": 1, + "doctype": "DocPerm", + "permlevel": 0, + "role": "System Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "doctype": "DocPerm", + "permlevel": 1, + "role": "System Manager", + "submit": 0 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "doctype": "DocPerm", + "permlevel": 0, + "role": "Sales User", + "submit": 1, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "doctype": "DocPerm", + "permlevel": 1, + "role": "Sales User", + "submit": 0 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "doctype": "DocPerm", + "permlevel": 0, + "role": "Sales Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "doctype": "DocPerm", + "permlevel": 1, + "role": "Sales Manager", + "submit": 0 } ] \ No newline at end of file diff --git a/stock/DocType Mapper/Delivery Note-Packing Slip/Delivery Note-Packing Slip.txt b/stock/DocType Mapper/Delivery Note-Packing Slip/Delivery Note-Packing Slip.txt deleted file mode 100644 index fc88bba000..0000000000 --- a/stock/DocType Mapper/Delivery Note-Packing Slip/Delivery Note-Packing Slip.txt +++ /dev/null @@ -1,86 +0,0 @@ -[ - { - "creation": "2012-02-02 11:50:33", - "docstatus": 0, - "modified": "2013-04-16 12:26:28", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Table Mapper Detail", - "name": "__common__", - "parent": "Delivery Note-Packing Slip", - "parentfield": "table_mapper_details", - "parenttype": "DocType Mapper" - }, - { - "doctype": "Field Mapper Detail", - "name": "__common__", - "parent": "Delivery Note-Packing Slip", - "parentfield": "field_mapper_details", - "parenttype": "DocType Mapper" - }, - { - "doctype": "DocType Mapper", - "from_doctype": "Delivery Note", - "module": "Stock", - "name": "__common__", - "ref_doc_submitted": 0, - "to_doctype": "Packing Slip" - }, - { - "doctype": "DocType Mapper", - "name": "Delivery Note-Packing Slip" - }, - { - "doctype": "Field Mapper Detail", - "from_field": "name", - "map": "Yes", - "match_id": 0, - "to_field": "delivery_note" - }, - { - "doctype": "Field Mapper Detail", - "from_field": "qty", - "map": "No", - "match_id": 1, - "to_field": "qty" - }, - { - "doctype": "Field Mapper Detail", - "from_field": "naming_series", - "map": "No", - "match_id": 0, - "to_field": "naming_series" - }, - { - "doctype": "Field Mapper Detail", - "from_field": "name", - "map": "Yes", - "match_id": 1, - "to_field": "dn_detail" - }, - { - "doctype": "Field Mapper Detail", - "from_field": "eval: flt(obj.qty) - flt(obj.packed_qty)", - "map": "Yes", - "match_id": 1, - "to_field": "qty" - }, - { - "doctype": "Table Mapper Detail", - "from_table": "Delivery Note", - "match_id": 0, - "to_table": "Packing Slip", - "validation_logic": "docstatus=0" - }, - { - "doctype": "Table Mapper Detail", - "from_field": "delivery_note_details", - "from_table": "Delivery Note Item", - "match_id": 1, - "to_field": "item_details", - "to_table": "Packing Slip Item", - "validation_logic": "IFNULL(packed_qty, 0) < IFNULL(qty, 0)" - } -] \ No newline at end of file diff --git a/stock/DocType Mapper/Sales Invoice-Delivery Note/Sales Invoice-Delivery Note.txt b/stock/DocType Mapper/Sales Invoice-Delivery Note/Sales Invoice-Delivery Note.txt deleted file mode 100755 index eaf687a03a..0000000000 --- a/stock/DocType Mapper/Sales Invoice-Delivery Note/Sales Invoice-Delivery Note.txt +++ /dev/null @@ -1,132 +0,0 @@ -[ - { - "owner": "Administrator", - "docstatus": 0, - "creation": "2010-12-14 17:56:41", - "modified_by": "Administrator", - "modified": "2012-04-03 12:49:50" - }, - { - "name": "__common__", - "parent": "Sales Invoice-Delivery Note", - "doctype": "Table Mapper Detail", - "parenttype": "DocType Mapper", - "parentfield": "table_mapper_details" - }, - { - "name": "__common__", - "parent": "Sales Invoice-Delivery Note", - "doctype": "Field Mapper Detail", - "parenttype": "DocType Mapper", - "parentfield": "field_mapper_details" - }, - { - "name": "__common__", - "to_doctype": "Delivery Note", - "module": "Stock", - "doctype": "DocType Mapper", - "ref_doc_submitted": 1, - "from_doctype": "Sales Invoice" - }, - { - "name": "Sales Invoice-Delivery Note", - "doctype": "DocType Mapper" - }, - { - "map": "Yes", - "match_id": 1, - "to_field": "qty", - "doctype": "Field Mapper Detail", - "from_field": "eval: flt(obj.qty) - flt(obj.delivered_qty)" - }, - { - "map": "Yes", - "match_id": 1, - "to_field": "prevdoc_docname", - "doctype": "Field Mapper Detail", - "from_field": "parent" - }, - { - "map": "Yes", - "match_id": 1, - "to_field": "prevdoc_doctype", - "doctype": "Field Mapper Detail", - "from_field": "parenttype" - }, - { - "map": "Yes", - "match_id": 1, - "to_field": "prevdoc_detail_docname", - "doctype": "Field Mapper Detail", - "from_field": "name" - }, - { - "map": "Yes", - "match_id": 1, - "to_field": "amount", - "doctype": "Field Mapper Detail", - "from_field": "eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.basic_rate)" - }, - { - "map": "Yes", - "match_id": 1, - "to_field": "export_amount", - "doctype": "Field Mapper Detail", - "from_field": "eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.export_rate)" - }, - { - "map": "No", - "match_id": 0, - "to_field": "naming_series", - "doctype": "Field Mapper Detail", - "from_field": "naming_series" - }, - { - "map": "Yes", - "match_id": 0, - "to_field": "delivery_address", - "doctype": "Field Mapper Detail", - "from_field": "customer_address" - }, - { - "map": "Yes", - "match_id": 1, - "to_field": "serial_no", - "doctype": "Field Mapper Detail", - "from_field": "serial_no" - }, - { - "match_id": 0, - "doctype": "Table Mapper Detail", - "from_table": "Sales Invoice", - "to_table": "Delivery Note", - "validation_logic": "docstatus=1" - }, - { - "match_id": 1, - "to_field": "delivery_note_details", - "doctype": "Table Mapper Detail", - "from_field": "entries", - "from_table": "Sales Invoice Item", - "to_table": "Delivery Note Item", - "validation_logic": "docstatus = 1" - }, - { - "match_id": 2, - "to_field": "other_charges", - "doctype": "Table Mapper Detail", - "from_field": "other_charges", - "from_table": "Sales Taxes and Charges", - "to_table": "Sales Taxes and Charges", - "validation_logic": "name is not null" - }, - { - "match_id": 3, - "to_field": "sales_team", - "doctype": "Table Mapper Detail", - "from_field": "sales_team", - "from_table": "Sales Team", - "to_table": "Sales Team", - "validation_logic": "name is not null" - } -] \ No newline at end of file diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js index 4f3ddacf72..8756e83c35 100644 --- a/stock/doctype/delivery_note/delivery_note.js +++ b/stock/doctype/delivery_note/delivery_note.js @@ -31,7 +31,8 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( if(flt(doc.per_billed, 2) < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Invoice', this.make_sales_invoice); - if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Installation Note', cur_frm.cscript['Make Installation Note']); + if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1) + cur_frm.add_custom_button('Make Installation Note', this.make_installation_note); if (doc.docstatus==1) cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); @@ -59,7 +60,15 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice", source_name: cur_frm.doc.name }) + }, + + make_installation_note: function() { + wn.model.open_mapped_doc({ + method: "stock.doctype.delivery_note.delivery_note.make_installation_note", + source_name: cur_frm.doc.name + }); } + }); // for backward compatibility: combine new and previous states @@ -114,40 +123,6 @@ cur_frm.fields_dict['transporter_name'].get_query = function(doc) { return 'SELECT DISTINCT `tabSupplier`.`name` FROM `tabSupplier` WHERE `tabSupplier`.supplier_type = "transporter" AND `tabSupplier`.docstatus != 2 AND `tabSupplier`.%(key)s LIKE "%s" ORDER BY `tabSupplier`.`name` LIMIT 50'; } -cur_frm.cscript['Make Sales Invoice'] = function() { - var doc = cur_frm.doc - n = wn.model.make_new_doc_and_get_name('Sales Invoice'); - $c('dt_map', args={ - 'docs':wn.model.compress([locals['Sales Invoice'][n]]), - 'from_doctype':doc.doctype, - 'to_doctype':'Sales Invoice', - 'from_docname':doc.name, - 'from_to_list':"[['Delivery Note','Sales Invoice'],['Delivery Note Item','Sales Invoice Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team']]" - }, function(r,rt) { - loaddoc('Sales Invoice', n); - } - ); -} - -cur_frm.cscript['Make Installation Note'] = function() { - var doc = cur_frm.doc; - if(doc.per_installed < 99.99){ - n = wn.model.make_new_doc_and_get_name('Installation Note'); - $c('dt_map', args={ - 'docs':wn.model.compress([locals['Installation Note'][n]]), - 'from_doctype':doc.doctype, - 'to_doctype':'Installation Note', - 'from_docname':doc.name, - 'from_to_list':"[['Delivery Note','Installation Note'],['Delivery Note Item','Installation Note Item']]" - }, function(r,rt) { - loaddoc('Installation Note', n); - } - ); - } - else if(doc.per_installed >= 100) - msgprint("Item installation is already completed") -} - cur_frm.cscript['Make Packing Slip'] = function() { n = wn.model.make_new_doc_and_get_name('Packing Slip'); ps = locals["Packing Slip"][n]; diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py index 25ba04c476..aa3a4d167a 100644 --- a/stock/doctype/delivery_note/delivery_note.py +++ b/stock/doctype/delivery_note/delivery_note.py @@ -22,6 +22,8 @@ from webnotes.model.bean import getlist from webnotes.model.code import get_obj from webnotes import msgprint, _ import webnotes.defaults +from webnotes.model.mapper import get_mapped_doclist + sql = webnotes.conn.sql @@ -365,9 +367,7 @@ class DocType(SellingController): make_gl_entries(gl_entries, cancel=(self.doc.docstatus == 2)) @webnotes.whitelist() -def make_sales_invoice(source_name, target_doclist=None): - from webnotes.model.mapper import get_mapped_doclist - +def make_sales_invoice(source_name, target_doclist=None): def update_item(obj, target, source_parent): target.export_amount = flt(obj.amount) - flt(obj.billed_amt) target.amount = target.export_amount / flt(source_parent.conversion_rate) @@ -407,4 +407,35 @@ def make_sales_invoice(source_name, target_doclist=None): } }, target_doclist, update_accounts) + return [d.fields for d in doclist] + +@webnotes.whitelist() +def make_installation_note(source_name, target_doclist=None): + def update_item(obj, target, source_parent): + target.qty = flt(obj.qty) - flt(obj.installed_qty) + + doclist = get_mapped_doclist("Delivery Note", source_name, { + "Delivery Note": { + "doctype": "Installation Note Item", + "field_map": { + "name": "delivery_note_no", + "posting_date": "prevdoc_date" + }, + "validation": { + "docstatus": ["=", 1] + } + }, + "Delivery Note Item": { + "doctype": "Installation Note Item", + "field_map": { + "name": "prevdoc_detail_docname", + "parent": "prevdoc_docname", + "parenttype": "prevdoc_doctype", + "serial_no": "serial_no" + }, + "postprocess": update_item, + "condition": lambda doc: doc.installed_qty < doc.qty + } + }, target_doclist) + return [d.fields for d in doclist] \ No newline at end of file diff --git a/support/DocType Mapper/Customer Issue-Maintenance Visit/Customer Issue-Maintenance Visit.txt b/support/DocType Mapper/Customer Issue-Maintenance Visit/Customer Issue-Maintenance Visit.txt deleted file mode 100644 index da862017ad..0000000000 --- a/support/DocType Mapper/Customer Issue-Maintenance Visit/Customer Issue-Maintenance Visit.txt +++ /dev/null @@ -1,83 +0,0 @@ -[ - { - "owner": "ashwini@webnotestech.com", - "docstatus": 0, - "creation": "2010-08-08 17:09:34", - "modified_by": "Administrator", - "modified": "2011-09-15 15:04:41" - }, - { - "reference_key": "prevdoc_docname", - "name": "__common__", - "parent": "Customer Issue-Maintenance Visit", - "doctype": "Table Mapper Detail", - "parenttype": "DocType Mapper", - "from_table": "Customer Issue", - "validation_logic": "docstatus=1", - "parentfield": "table_mapper_details" - }, - { - "map": "Yes", - "name": "__common__", - "parent": "Customer Issue-Maintenance Visit", - "doctype": "Field Mapper Detail", - "parenttype": "DocType Mapper", - "parentfield": "field_mapper_details" - }, - { - "name": "__common__", - "to_doctype": "Maintenance Visit", - "module": "Support", - "doctype": "DocType Mapper", - "ref_doc_submitted": 1, - "from_doctype": "Customer Issue" - }, - { - "name": "Customer Issue-Maintenance Visit", - "doctype": "DocType Mapper" - }, - { - "match_id": 0, - "to_field": "customer", - "doctype": "Field Mapper Detail", - "from_field": "customer", - "checking_operator": "=" - }, - { - "to_field": "customer_issue_no", - "doctype": "Field Mapper Detail", - "match_id": 0, - "from_field": "name" - }, - { - "match_id": 1, - "to_field": "description", - "doctype": "Field Mapper Detail", - "from_field": "complaint", - "checking_operator": "=" - }, - { - "to_field": "prevdoc_doctype", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "doctype" - }, - { - "to_field": "prevdoc_docname", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "name" - }, - { - "match_id": 1, - "reference_doctype_key": "prevdoc_doctype", - "to_field": "maintenance_visit_details", - "doctype": "Table Mapper Detail", - "to_table": "Maintenance Visit Purpose" - }, - { - "to_table": "Maintenance Visit", - "match_id": 0, - "doctype": "Table Mapper Detail" - } -] \ No newline at end of file diff --git a/support/DocType Mapper/Maintenance Schedule-Maintenance Visit/Maintenance Schedule-Maintenance Visit.txt b/support/DocType Mapper/Maintenance Schedule-Maintenance Visit/Maintenance Schedule-Maintenance Visit.txt deleted file mode 100644 index 9ea33b1601..0000000000 --- a/support/DocType Mapper/Maintenance Schedule-Maintenance Visit/Maintenance Schedule-Maintenance Visit.txt +++ /dev/null @@ -1,76 +0,0 @@ -[ - { - "owner": "Administrator", - "docstatus": 0, - "creation": "2012-06-27 13:18:25", - "modified_by": "Administrator", - "modified": "2012-06-27 13:18:25" - }, - { - "name": "__common__", - "parent": "Maintenance Schedule-Maintenance Visit", - "doctype": "Table Mapper Detail", - "parenttype": "DocType Mapper", - "validation_logic": "docstatus=1", - "parentfield": "table_mapper_details" - }, - { - "map": "Yes", - "name": "__common__", - "parent": "Maintenance Schedule-Maintenance Visit", - "doctype": "Field Mapper Detail", - "parenttype": "DocType Mapper", - "parentfield": "field_mapper_details" - }, - { - "name": "__common__", - "to_doctype": "Maintenance Visit", - "module": "Support", - "doctype": "DocType Mapper", - "ref_doc_submitted": 1, - "from_doctype": "Maintenance Schedule" - }, - { - "name": "Maintenance Schedule-Maintenance Visit", - "doctype": "DocType Mapper" - }, - { - "match_id": 0, - "to_field": "customer", - "doctype": "Field Mapper Detail", - "from_field": "customer", - "checking_operator": "=" - }, - { - "to_field": "maintenance_schedule", - "doctype": "Field Mapper Detail", - "match_id": 0, - "from_field": "name" - }, - { - "to_field": "prevdoc_docname", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "parent" - }, - { - "to_field": "prevdoc_doctype", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "parenttype" - }, - { - "match_id": 1, - "to_field": "maintenance_visit_details", - "doctype": "Table Mapper Detail", - "from_field": "item_maintenance_detail", - "from_table": "Maintenance Schedule Item", - "to_table": "Maintenance Visit Purpose" - }, - { - "to_table": "Maintenance Visit", - "doctype": "Table Mapper Detail", - "match_id": 0, - "from_table": "Maintenance Schedule" - } -] \ No newline at end of file diff --git a/support/DocType Mapper/Sales Order-Maintenance Schedule/Sales Order-Maintenance Schedule.txt b/support/DocType Mapper/Sales Order-Maintenance Schedule/Sales Order-Maintenance Schedule.txt deleted file mode 100644 index 7dde342c3c..0000000000 --- a/support/DocType Mapper/Sales Order-Maintenance Schedule/Sales Order-Maintenance Schedule.txt +++ /dev/null @@ -1,78 +0,0 @@ -[ - { - "owner": "Administrator", - "docstatus": 0, - "creation": "2010-08-08 17:09:35", - "modified_by": "Administrator", - "modified": "2011-09-15 15:04:44" - }, - { - "name": "__common__", - "parent": "Sales Order-Maintenance Schedule", - "doctype": "Table Mapper Detail", - "parenttype": "DocType Mapper", - "parentfield": "table_mapper_details" - }, - { - "map": "Yes", - "name": "__common__", - "parent": "Sales Order-Maintenance Schedule", - "doctype": "Field Mapper Detail", - "parenttype": "DocType Mapper", - "parentfield": "field_mapper_details" - }, - { - "name": "__common__", - "to_doctype": "Maintenance Schedule", - "module": "Support", - "doctype": "DocType Mapper", - "ref_doc_submitted": 1, - "from_doctype": "Sales Order" - }, - { - "name": "Sales Order-Maintenance Schedule", - "doctype": "DocType Mapper" - }, - { - "match_id": 0, - "to_field": "customer", - "doctype": "Field Mapper Detail", - "from_field": "customer", - "checking_operator": "=" - }, - { - "to_field": "sales_order_no", - "doctype": "Field Mapper Detail", - "match_id": 0, - "from_field": "name" - }, - { - "match_id": 1, - "to_field": "item_code", - "doctype": "Field Mapper Detail", - "from_field": "item_code", - "checking_operator": "=" - }, - { - "to_field": "prevdoc_docname", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "parent" - }, - { - "match_id": 1, - "to_field": "item_maintenance_detail", - "doctype": "Table Mapper Detail", - "from_field": "sales_order_details", - "from_table": "Sales Order Item", - "to_table": "Maintenance Schedule Item", - "validation_logic": "docstatus =1" - }, - { - "match_id": 0, - "doctype": "Table Mapper Detail", - "from_table": "Sales Order", - "to_table": "Maintenance Schedule", - "validation_logic": "docstatus=1" - } -] \ No newline at end of file diff --git a/support/DocType Mapper/Sales Order-Maintenance Visit/Sales Order-Maintenance Visit.txt b/support/DocType Mapper/Sales Order-Maintenance Visit/Sales Order-Maintenance Visit.txt deleted file mode 100644 index c2d4d02d76..0000000000 --- a/support/DocType Mapper/Sales Order-Maintenance Visit/Sales Order-Maintenance Visit.txt +++ /dev/null @@ -1,76 +0,0 @@ -[ - { - "owner": "ashwini@webnotestech.com", - "docstatus": 0, - "creation": "2010-08-08 17:09:36", - "modified_by": "Administrator", - "modified": "2011-09-15 15:04:45" - }, - { - "name": "__common__", - "parent": "Sales Order-Maintenance Visit", - "doctype": "Table Mapper Detail", - "parenttype": "DocType Mapper", - "validation_logic": "docstatus=1", - "parentfield": "table_mapper_details" - }, - { - "map": "Yes", - "name": "__common__", - "parent": "Sales Order-Maintenance Visit", - "doctype": "Field Mapper Detail", - "parenttype": "DocType Mapper", - "parentfield": "field_mapper_details" - }, - { - "name": "__common__", - "to_doctype": "Maintenance Visit", - "module": "Support", - "doctype": "DocType Mapper", - "ref_doc_submitted": 1, - "from_doctype": "Sales Order" - }, - { - "name": "Sales Order-Maintenance Visit", - "doctype": "DocType Mapper" - }, - { - "match_id": 0, - "to_field": "customer", - "doctype": "Field Mapper Detail", - "from_field": "customer", - "checking_operator": "=" - }, - { - "to_field": "sales_order_no", - "doctype": "Field Mapper Detail", - "match_id": 0, - "from_field": "name" - }, - { - "to_field": "prevdoc_docname", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "parent" - }, - { - "to_field": "prevdoc_doctype", - "doctype": "Field Mapper Detail", - "match_id": 1, - "from_field": "parenttype" - }, - { - "match_id": 1, - "to_field": "maintenance_visit_details", - "doctype": "Table Mapper Detail", - "from_field": "sales_order_details", - "from_table": "Sales Order Item", - "to_table": "Maintenance Visit Purpose" - }, - { - "to_table": "Maintenance Visit", - "doctype": "Table Mapper Detail", - "match_id": 0, - "from_table": "Sales Order" - } -] \ No newline at end of file