Skip to content

Commit

Permalink
add: updates from muzamil.zaviago.com
Browse files Browse the repository at this point in the history
  • Loading branch information
umer2001 committed Nov 6, 2024
1 parent 561fcef commit ece7a68
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 51 deletions.
34 changes: 29 additions & 5 deletions frappe/contacts/custom/address.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"name": "Address-is_your_company_address",
"no_copy": 0,
"non_negative": 0,
"not_in_filter": 0,
"options": null,
"owner": "Administrator",
"permlevel": 0,
Expand Down Expand Up @@ -82,7 +83,7 @@
"field_name": "county",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-09-12 14:01:27.462259",
"modified": "2024-10-17 13:33:17.103492",
"modified_by": "Administrator",
"module": null,
"name": "Address-county-allow_in_quick_entry",
Expand All @@ -97,23 +98,46 @@
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"creation": "2024-02-01 17:47:50.450748",
"creation": "2024-10-29 15:56:59.868312",
"default_value": null,
"doc_type": "Address",
"docstatus": 0,
"doctype_or_field": "DocField",
"field_name": "linked_with",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-10-29 15:56:59.868312",
"modified_by": "Administrator",
"module": null,
"name": "Address-linked_with-hidden",
"owner": "Administrator",
"property": "hidden",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"creation": "2024-10-29 15:56:59.708198",
"default_value": null,
"doc_type": "Address",
"docstatus": 0,
"doctype_or_field": "DocType",
"field_name": null,
"idx": 0,
"is_system_generated": 0,
"modified": "2024-09-12 14:01:27.436728",
"modified": "2024-10-29 15:56:59.708198",
"modified_by": "Administrator",
"module": null,
"name": "Address-main-field_order",
"owner": "Administrator",
"property": "field_order",
"property_type": "Data",
"row_name": null,
"value": "[\"address_details\", \"address_title\", \"address_type\", \"address_line1\", \"address_line2\", \"city\", \"state\", \"country\", \"pincode\", \"column_break0\", \"email_id\", \"phone\", \"fax\", \"is_primary_address\", \"is_shipping_address\", \"disabled\", \"linked_with\", \"is_your_company_address\", \"links\"]"
"value": "[\"address_details\", \"address_title\", \"address_type\", \"address_line1\", \"address_line2\", \"city\", \"county\", \"state\", \"country\", \"pincode\", \"column_break0\", \"email_id\", \"phone\", \"fax\", \"tax_category\", \"is_primary_address\", \"is_shipping_address\", \"disabled\", \"linked_with\", \"is_your_company_address\", \"links\"]"
},
{
"_assign": null,
Expand All @@ -128,7 +152,7 @@
"field_name": "phone",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-09-12 14:01:27.489708",
"modified": "2024-10-17 13:33:17.179106",
"modified_by": "Administrator",
"module": null,
"name": "Address-phone-allow_in_quick_entry",
Expand Down
43 changes: 34 additions & 9 deletions frappe/contacts/custom/contact.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"name": "Contact-custom_checked_primary_contact",
"no_copy": 0,
"non_negative": 0,
"not_in_filter": 0,
"options": null,
"owner": "Administrator",
"permlevel": 0,
Expand Down Expand Up @@ -89,7 +90,7 @@
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 27,
"idx": 31,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
Expand All @@ -109,6 +110,7 @@
"name": "Contact-is_billing_contact",
"no_copy": 0,
"non_negative": 0,
"not_in_filter": 0,
"options": null,
"owner": "Administrator",
"permlevel": 0,
Expand Down Expand Up @@ -146,7 +148,7 @@
"field_name": "address",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-09-12 14:01:27.085979",
"modified": "2024-10-17 13:33:16.343600",
"modified_by": "Administrator",
"module": null,
"name": "Contact-address-hidden",
Expand All @@ -169,7 +171,7 @@
"field_name": "company_name",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-09-12 14:01:26.925827",
"modified": "2024-10-17 13:33:16.382377",
"modified_by": "Administrator",
"module": null,
"name": "Contact-company_name-hidden",
Expand All @@ -179,6 +181,29 @@
"row_name": null,
"value": "1"
},
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"creation": "2024-10-29 15:53:56.748640",
"default_value": null,
"doc_type": "Contact",
"docstatus": 0,
"doctype_or_field": "DocField",
"field_name": "contact_details",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-10-29 15:53:56.748640",
"modified_by": "Administrator",
"module": null,
"name": "Contact-contact_details-hidden",
"owner": "Administrator",
"property": "hidden",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"_assign": null,
"_comments": null,
Expand All @@ -192,7 +217,7 @@
"field_name": null,
"idx": 0,
"is_system_generated": 0,
"modified": "2024-09-12 14:01:26.834348",
"modified": "2024-10-17 13:33:16.418453",
"modified_by": "Administrator",
"module": null,
"name": "Contact-main-field_order",
Expand All @@ -215,7 +240,7 @@
"field_name": null,
"idx": 0,
"is_system_generated": 0,
"modified": "2024-09-12 14:01:26.953981",
"modified": "2024-10-17 13:33:16.460942",
"modified_by": "Administrator",
"module": null,
"name": "Contact-main-quick_entry",
Expand All @@ -238,7 +263,7 @@
"field_name": "more_info",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-09-12 14:01:26.989645",
"modified": "2024-10-17 13:33:16.503214",
"modified_by": "Administrator",
"module": null,
"name": "Contact-more_info-hidden",
Expand All @@ -261,7 +286,7 @@
"field_name": "status",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-09-12 14:01:27.016658",
"modified": "2024-10-17 13:33:16.547342",
"modified_by": "Administrator",
"module": null,
"name": "Contact-status-hidden",
Expand All @@ -284,7 +309,7 @@
"field_name": "sync_with_google_contacts",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-09-12 14:01:27.050069",
"modified": "2024-10-17 13:33:16.591773",
"modified_by": "Administrator",
"module": null,
"name": "Contact-sync_with_google_contacts-hidden",
Expand All @@ -307,7 +332,7 @@
"field_name": "user",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-09-12 14:01:27.116826",
"modified": "2024-10-17 13:33:16.638670",
"modified_by": "Administrator",
"module": null,
"name": "Contact-user-hidden",
Expand Down
13 changes: 10 additions & 3 deletions frappe/contacts/doctype/address/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ frappe.ui.form.on("Address", {
after_save: function (frm) {
// muzammal
frappe.call({
method: 'frappe.contacts.doctype.address.custom_address.checkPrimaryAddress',
method: 'frappe.contacts.doctype.address.custom_address.check_primary_address',
args: {
'links':frm.doc.links,
'reference':frm.doc.name,
'ref':frm.doc.name,
},
callback: function(r) {
if (!r.exc) {
Expand Down Expand Up @@ -102,7 +102,14 @@ frappe.ui.form.on("Address", {
//muzammal
$(document).ready(function () {
window.addEventListener('popstate', function (event) {
$("header").removeClass("hide");
show_header()
});
window.addEventListener('pushstate', function (event) {
show_header()
});
});
function show_header(){
$("header").removeClass("hide");
$("header").show();
}
//muzammal
3 changes: 2 additions & 1 deletion frappe/contacts/doctype/address/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
from frappe.model.naming import make_autoname
from frappe.utils import cstr
import json
from frappe.contacts.doctype.address.custom_address import customAddress
# from frappe.contacts.doctype.address.custom_address import customAddress

class Address(Document):
class Address(Document,customAddress):
# begin: auto-generated types
# This code is auto-generated. Do not modify anything in this block.

Expand Down
9 changes: 6 additions & 3 deletions frappe/contacts/doctype/address/custom_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
import json
class customAddress:
pass



@frappe.whitelist()
def checkPrimaryAddress(links,reference):
def check_primary_address(links,ref):
links=json.loads(links)
for link in links:
if( link['link_doctype']=='Customer' ):
customer=frappe.get_doc('Customer',link['link_name'])
if( customer.customer_primary_address is None or customer.customer_primary_address=="" ):
customer.customer_primary_address=reference
customer.customer_primary_address=ref
customer.save()
addr=frappe.get_doc("Address",reference)
addr=frappe.get_doc("Address",ref)
addr.is_primary_address=True
addr.is_shipping_address=True
addr.save()
57 changes: 57 additions & 0 deletions frappe/contacts/doctype/contact/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ frappe.ui.form.on("Contact", {
if( frm.doc.links.length<1 ){
frappe.throw(("Please create contact from customer"));
}

if( frm.doc.first_name == 'undefined' || frm.doc.first_name == null || frm.doc.first_name == '' ){
// $(".frappe-control[data-fieldname='first_name'] .control-value").html(frm.doc.links[0].link_name);
if( frm.doc.links ){
frm.set_value('first_name', frm.doc.links[0].link_name);
}
}
},
onload(frm) {
frm.email_field = "email_id";
Expand Down Expand Up @@ -98,6 +105,22 @@ frappe.ui.form.on("Contact", {
);
}
}
//muzammal
frm.add_custom_button(__('Unlink and Delete'), function(){
frappe.call({
method: 'unlink_and_delete_contact',
args: {
'reference':frm.doc.name,
},
callback: function(r) {
if( r.message=="deleted" ){
location.replace("/app/contact/")

}
}
});
});
//muzammal
},
validate: function (frm) {
// clear linked customer / supplier / sales partner on saving...
Expand Down Expand Up @@ -129,6 +152,40 @@ frappe.ui.form.on("Contact", {
}
},
]);
//muzammal

let links='';
let email_phone='false';
let custom_checked_primary_contact='';
if( frm.doc.custom_checked_primary_contact==0 ){
custom_checked_primary_contact='false';
links=frm.doc.links;
}else{
custom_checked_primary_contact='true';
links="false";
}
if( frm.doc.email_ids || frm.doc.phone_nos ){
email_phone="yes";
}
frappe.call({
method: 'frappe.contacts.doctype.contact.custom_contact.primaryContactDetails',
args: {
'reference':frm.doc.name,
'links':links,
'email_ids':frm.doc.email_ids,
'phone_nos':frm.doc.phone_nos,
'custom_checked_primary_contact':custom_checked_primary_contact,
},
callback: function(r) {
if(r.message=="validate"){
// frm.set_value("custom_checked_primary_contact",true);
// frm.dirty();
// frm.save();
frm.reload_doc();
}
}
});
//muzammal
},
sync_with_google_contacts: function (frm) {
if (frm.doc.sync_with_google_contacts) {
Expand Down
Loading

0 comments on commit ece7a68

Please sign in to comment.