Skip to content

Commit

Permalink
fix: Autoname for customer and supplier (frappe#27398)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepeshgarg007 committed Sep 15, 2021
1 parent 625626b commit 759f2b7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions erpnext/buying/doctype/buying_settings/buying_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"fieldname": "supp_master_name",
"fieldtype": "Select",
"label": "Supplier Naming By",
"options": "Supplier Name\nNaming Series"
"options": "Supplier Name\nNaming Series\nAuto Name"
},
{
"fieldname": "supplier_group",
Expand Down Expand Up @@ -123,7 +123,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2021-06-24 10:38:28.934525",
"modified": "2021-09-08 19:26:23.548837",
"modified_by": "Administrator",
"module": "Buying",
"name": "Buying Settings",
Expand Down
6 changes: 4 additions & 2 deletions erpnext/buying/doctype/supplier/supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
delete_contact_and_address,
load_address_and_contact,
)
from frappe.model.naming import set_name_by_naming_series
from frappe.model.naming import set_name_by_naming_series, set_name_from_naming_options

from erpnext.accounts.party import get_dashboard_info, validate_party_accounts
from erpnext.utilities.transaction_base import TransactionBase
Expand Down Expand Up @@ -40,8 +40,10 @@ def autoname(self):
supp_master_name = frappe.defaults.get_global_default('supp_master_name')
if supp_master_name == 'Supplier Name':
self.name = self.supplier_name
else:
elif supp_master_name == 'Naming Series':
set_name_by_naming_series(self)
else:
self.name = set_name_from_naming_options(frappe.get_meta(self.doctype).autoname, self)

def on_update(self):
if not self.naming_series:
Expand Down
6 changes: 4 additions & 2 deletions erpnext/selling/doctype/customer/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
from frappe.desk.reportview import build_match_conditions, get_filters_cond
from frappe.model.mapper import get_mapped_doc
from frappe.model.naming import set_name_by_naming_series
from frappe.model.naming import set_name_by_naming_series, set_name_from_naming_options
from frappe.model.rename_doc import update_linked_doctypes
from frappe.utils import cint, cstr, flt, get_formatted_email, today
from frappe.utils.user import get_users_with_role
Expand All @@ -40,8 +40,10 @@ def autoname(self):
cust_master_name = frappe.defaults.get_global_default('cust_master_name')
if cust_master_name == 'Customer Name':
self.name = self.get_customer_name()
else:
elif cust_master_name == 'Naming Series':
set_name_by_naming_series(self)
else:
self.name = set_name_from_naming_options(frappe.get_meta(self.doctype).autoname, self)

def get_customer_name(self):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
"fieldtype": "Select",
"in_list_view": 1,
"label": "Customer Naming By",
"options": "Customer Name\nNaming Series"
"options": "Customer Name\nNaming Series\nAuto Name"
},
{
"fieldname": "campaign_naming_by",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Campaign Naming By",
"options": "Campaign Name\nNaming Series"
"options": "Campaign Name\nNaming Series\nAuto Name"
},
{
"fieldname": "customer_group",
Expand Down Expand Up @@ -204,7 +204,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2021-09-01 22:55:33.803624",
"modified": "2021-09-08 19:38:10.175989",
"modified_by": "Administrator",
"module": "Selling",
"name": "Selling Settings",
Expand All @@ -223,4 +223,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}
}

0 comments on commit 759f2b7

Please sign in to comment.