[cleanup] move contact, address to frappe 💥

This commit is contained in:
Rushabh Mehta
2017-01-13 18:53:11 +05:30
parent 448acf6f46
commit b92087cb2d
52 changed files with 196 additions and 3168 deletions

View File

@@ -3,18 +3,28 @@
frappe.provide("erpnext.maintenance");
frappe.ui.form.on_change("Maintenance Schedule", "customer", function(frm) {
erpnext.utils.get_party_details(frm) });
frappe.ui.form.on_change("Maintenance Schedule", "customer_address", function(){
erpnext.utils.get_address_display(cur_frm, 'customer_address', 'address_display');
});
frappe.ui.form.on_change("Maintenance Schedule", "contact_person", function(){
erpnext.utils.get_contact_details(cur_frm);
});
frappe.ui.form.on('Maintenance Schedule', {
setup: function(frm) {
frm.set_query('contact_person', erpnext.queries.contact_query);
frm.set_query('customer_address', erpnext.queries.address_query);
},
customer: function(frm) {
erpnext.utils.get_party_details(frm)
},
customer_address: function(frm) {
erpnext.utils.get_address_display(frm, 'customer_address', 'address_display');
},
contact_person: function(frm) {
erpnext.utils.get_contact_details(frm);
}
})
// TODO commonify this code
erpnext.maintenance.MaintenanceSchedule = frappe.ui.form.Controller.extend({
refresh: function() {
frappe.contact_link = {doc: this.frm.doc, fieldname: 'customer', doctype: 'Customer'}
var me = this;
if (this.frm.doc.docstatus === 0) {
@@ -94,18 +104,6 @@ cur_frm.cscript.onload = function(doc, dt, dn) {
}
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
return {
filters:{ 'customer': doc.customer }
}
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return {
filters:{ 'customer': doc.customer }
}
}
cur_frm.cscript.generate_schedule = function(doc, cdt, cdn) {
if (!doc.__islocal) {
return $c('runserverobj', args={'method':'generate_schedule', 'docs':doc},

View File

@@ -2,20 +2,31 @@
// License: GNU General Public License v3. See license.txt
frappe.provide("erpnext.maintenance");
me.frm.set_query('contact_person', erpnext.queries.contact_query);
frappe.ui.form.on_change("Maintenance Visit", "customer", function(frm) {
erpnext.utils.get_party_details(frm) });
frappe.ui.form.on_change("Maintenance Visit", "customer_address", function(frm){
erpnext.utils.get_address_display(frm, 'customer_address', 'address_display')
});
frappe.ui.form.on_change("Maintenance Visit", "contact_person", function(frm){
erpnext.utils.get_contact_details(frm)
});
frappe.ui.form.on('Maintenance Visit', {
setup: function(frm) {
frm.set_query('contact_person', erpnext.queries.contact_query);
frm.set_query('customer_address', erpnext.queries.address_query);
},
customer: function(frm) {
erpnext.utils.get_party_details(frm)
},
customer_address: function(frm) {
erpnext.utils.get_address_display(frm, 'customer_address', 'address_display');
},
contact_person: function(frm) {
erpnext.utils.get_contact_details(frm);
}
})
// TODO commonify this code
erpnext.maintenance.MaintenanceVisit = frappe.ui.form.Controller.extend({
refresh: function() {
frappe.contact_link = {doc: this.frm.doc, fieldname: 'customer', doctype: 'Customer'}
if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__('Maintenance Schedule'),
function() {
@@ -69,18 +80,6 @@ cur_frm.cscript.onload = function(doc, dt, dn) {
cur_frm.add_fetch('item_code', 'description', 'description');
}
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
return{
filters:{'customer': doc.customer}
}
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return{
filters:{'customer': doc.customer}
}
}
cur_frm.fields_dict.customer.get_query = function(doc,cdt,cdn) {
return {query: "erpnext.controllers.queries.customer_query" }
}