Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update email and mobile fieldnames in contact #42

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/src/components/Modals/OpportunityModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ function createOpportunity() {
return error.value
}
}
if (opportunity.mobile_no && isNaN(opportunity.mobile_no.replace(/[-+() ]/g, ''))) {
if (opportunity.contact_mobile && isNaN(opportunity.contact_mobile.replace(/[-+() ]/g, ''))) {
error.value = __('Mobile No should be a number')
return error.value
}
if (opportunity.email && !opportunity.email.includes('@')) {
if (opportunity.contact_email && !opportunity.contact_email.includes('@')) {
error.value = __('Invalid Email')
return error.value
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/Contact.vue
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,8 @@ function getOpportunityRowObject(opportunity) {
label: opportunity.status,
color: getDealStatus(opportunity.status)?.iconColorClass,
},
email: opportunity.email,
mobile_no: opportunity.mobile_no,
email: opportunity.contact_email,
mobile_no: opportunity.contact_mobile,
opportunity_owner: {
label: opportunity.opportunity_owner && getUser(opportunity.opportunity_owner).full_name,
...(opportunity.opportunity_owner && getUser(opportunity.opportunity_owner)),
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/Customer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ function getOpportunityRowObject(opportunity) {
label: opportunity.status,
color: getDealStatus(opportunity.status)?.iconColorClass,
},
email: opportunity.email,
mobile_no: opportunity.mobile_no,
email: opportunity.contact_email,
mobile_no: opportunity.contact_mobile,
opportunity_owner: {
label: opportunity.opportunity_owner && getUser(opportunity.opportunity_owner).full_name,
...(opportunity.opportunity_owner && getUser(opportunity.opportunity_owner)),
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/MobileContact.vue
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,8 @@ function getOpportunityRowObject(opportunity) {
label: opportunity.status,
color: getDealStatus(opportunity.status)?.iconColorClass,
},
email: opportunity.email,
mobile_no: opportunity.mobile_no,
email: opportunity.contact_email,
mobile_no: opportunity.contact_mobile,
opportunity_owner: {
label: opportunity.opportunity_owner && getUser(opportunity.opportunity_owner).full_name,
...(opportunity.opportunity_owner && getUser(opportunity.opportunity_owner)),
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/MobileCustomer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ function getOpportunityRowObject(opportunity) {
label: opportunity.status,
color: getDealStatus(opportunity.status)?.iconColorClass,
},
email: opportunity.email,
mobile_no: opportunity.mobile_no,
email: opportunity.contact_email,
mobile_no: opportunity.contact_mobile,
opportunity_owner: {
label: opportunity.opportunity_owner && getUser(opportunity.opportunity_owner).full_name,
...(opportunity.opportunity_owner && getUser(opportunity.opportunity_owner)),
Expand Down
11 changes: 7 additions & 4 deletions next_crm/api/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ def update_opportunities_email_mobile_no(doc):

for linked_opportunity in linked_opportunities:
opportunity = frappe.get_cached_doc("Opportunity", linked_opportunity.parent)
if opportunity.email != doc.email_id or opportunity.mobile_no != doc.mobile_no:
opportunity.email = doc.email_id
opportunity.mobile_no = doc.mobile_no
if (
opportunity.contact_email != doc.email_id
or opportunity.contact_mobile != doc.mobile_no
):
opportunity.contact_email = doc.email_id
opportunity.contact_mobile = doc.mobile_no
opportunity.save(ignore_permissions=True)


Expand Down Expand Up @@ -130,7 +133,7 @@ def set_as_primary(contact, field, value):

contact = frappe.get_doc("Contact", contact)

if field == "email":
if field == "email_id":
for email in contact.email_ids:
if email.email_id == value:
email.is_primary = 1
Expand Down