refactor: suggested changes
This commit is contained in:
parent
34a5cb9106
commit
0be6583083
@ -57,16 +57,16 @@ class Supplier(TransactionBase):
|
|||||||
self.payment_terms = ""
|
self.payment_terms = ""
|
||||||
self.accounts = []
|
self.accounts = []
|
||||||
|
|
||||||
if not self.accounts and doc.accounts:
|
if doc.accounts:
|
||||||
for account in doc.accounts:
|
for account in doc.accounts:
|
||||||
child = self.append('accounts')
|
child = self.append('accounts')
|
||||||
child.company = account.company
|
child.company = account.company
|
||||||
child.account = account.account
|
child.account = account.account
|
||||||
self.save()
|
|
||||||
|
|
||||||
if not self.payment_terms and doc.payment_terms:
|
if doc.payment_terms:
|
||||||
self.payment_terms = doc.payment_terms
|
self.payment_terms = doc.payment_terms
|
||||||
|
|
||||||
|
self.save()
|
||||||
|
|
||||||
def validate_internal_supplier(self):
|
def validate_internal_supplier(self):
|
||||||
internal_supplier = frappe.db.get_value("Supplier",
|
internal_supplier = frappe.db.get_value("Supplier",
|
||||||
|
@ -84,26 +84,23 @@ class Customer(TransactionBase):
|
|||||||
self.accounts = self.credit_limits = []
|
self.accounts = self.credit_limits = []
|
||||||
self.payment_terms = self.default_price_list = ""
|
self.payment_terms = self.default_price_list = ""
|
||||||
|
|
||||||
if not self.accounts and doc.accounts:
|
tables = [["accounts", "account"], ["credit_limits", "credit_limit"]]
|
||||||
for account in doc.accounts:
|
fields = ["payment_terms", "default_price_list"]
|
||||||
child = self.append('accounts')
|
|
||||||
child.company = account.company
|
for row in tables:
|
||||||
child.account = account.account
|
table, field = row[0], row[1]
|
||||||
|
if not doc.get(table): continue
|
||||||
|
|
||||||
|
for entry in doc.get(table):
|
||||||
|
child = self.append(table)
|
||||||
|
child.update({"company": entry.company, field: entry.get(field)})
|
||||||
|
|
||||||
|
for field in fields:
|
||||||
|
if not doc.get(field): continue
|
||||||
|
self.update({field: doc.get(field)})
|
||||||
|
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
if not self.credit_limits and doc.credit_limits:
|
|
||||||
for credit in doc.credit_limits:
|
|
||||||
child = self.append('credit_limits')
|
|
||||||
child.company = credit.company
|
|
||||||
child.credit_limit = credit.credit_limit
|
|
||||||
self.save()
|
|
||||||
|
|
||||||
if not self.payment_terms and doc.payment_terms:
|
|
||||||
self.payment_terms = doc.payment_terms
|
|
||||||
|
|
||||||
if not self.default_price_list and doc.default_price_list:
|
|
||||||
self.default_price_list = doc.default_price_list
|
|
||||||
|
|
||||||
def check_customer_group_change(self):
|
def check_customer_group_change(self):
|
||||||
frappe.flags.customer_group_changed = False
|
frappe.flags.customer_group_changed = False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user