[fix] customer naming series validation and patch to fix missing default taxes and lead
This commit is contained in:
parent
926ae17e5a
commit
0332f83bc2
@ -208,3 +208,4 @@ erpnext.patches.v6_0.fix_outstanding_amount
|
||||
erpnext.patches.v6_0.fix_planned_qty
|
||||
erpnext.patches.v6_0.multi_currency
|
||||
erpnext.patches.v6_2.remove_newsletter_duplicates
|
||||
erpnext.patches.v6_2.fix_missing_default_taxes_and_lead
|
||||
|
25
erpnext/patches/v6_2/fix_missing_default_taxes_and_lead.py
Normal file
25
erpnext/patches/v6_2/fix_missing_default_taxes_and_lead.py
Normal file
@ -0,0 +1,25 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
# remove missing default taxes
|
||||
for customer in frappe.db.sql_list("""select name from `tabCustomer`
|
||||
where ifnull(default_taxes_and_charges, '')!='' and not exists (
|
||||
select name from `tabSales Taxes and Charges Template` where name=`tabCustomer`.default_taxes_and_charges
|
||||
)"""):
|
||||
c = frappe.get_doc("Customer", customer)
|
||||
c.default_taxes_and_charges = None
|
||||
c.save()
|
||||
|
||||
for supplier in frappe.db.sql_list("""select name from `tabSupplier`
|
||||
where ifnull(default_taxes_and_charges, '')!='' and not exists (
|
||||
select name from `tabPurchase Taxes and Charges Template` where name=`tabSupplier`.default_taxes_and_charges
|
||||
)"""):
|
||||
c = frappe.get_doc("Supplier", supplier)
|
||||
c.default_taxes_and_charges = None
|
||||
c.save()
|
||||
|
||||
# remove missing lead
|
||||
for customer in frappe.db.sql_list("""select name from `tabCustomer`
|
||||
where ifnull(lead_name, '')!='' and not exists (select name from `tabLead` where name=`tabCustomer`.lead_name)"""):
|
||||
frappe.db.set_value("Customer", customer, "lead_name", None)
|
@ -26,15 +26,13 @@ class Customer(TransactionBase):
|
||||
if cust_master_name == 'Customer Name':
|
||||
self.name = self.customer_name
|
||||
else:
|
||||
self.name = make_autoname(self.naming_series+'.#####')
|
||||
if not self.naming_series:
|
||||
frappe.throw(_("Series is mandatory"), frappe.MandatoryError)
|
||||
|
||||
def validate_mandatory(self):
|
||||
if frappe.defaults.get_global_default('cust_master_name') == 'Naming Series' and not self.naming_series:
|
||||
frappe.throw(_("Series is mandatory"), frappe.MandatoryError)
|
||||
self.name = make_autoname(self.naming_series+'.#####')
|
||||
|
||||
def validate(self):
|
||||
self.flags.is_new_doc = self.is_new()
|
||||
self.validate_mandatory()
|
||||
validate_accounting_currency(self)
|
||||
validate_party_account(self)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user