[fix] Only 1 account per company for a party
This commit is contained in:
parent
cd0989e051
commit
da98ab6f3c
@ -192,6 +192,15 @@ def get_party_account_currency(party_type, party, company):
|
||||
|
||||
return frappe.local_cache("party_account_currency", (party_type, party, company), generator)
|
||||
|
||||
def validate_party_accounts(doc):
|
||||
companies = []
|
||||
|
||||
for account in doc.get("accounts"):
|
||||
if account.company in companies:
|
||||
frappe.throw(_("There can only be 1 Account per Company in {0} {1}").format(doc.doctype, doc.name))
|
||||
else:
|
||||
companies.append(account.company)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_due_date(posting_date, party_type, party, company):
|
||||
"""Set Due Date = Posting Date + Credit Days"""
|
||||
|
@ -8,6 +8,7 @@ from frappe import msgprint, _
|
||||
from frappe.model.naming import make_autoname
|
||||
from erpnext.utilities.address_and_contact import load_address_and_contact
|
||||
from erpnext.utilities.transaction_base import TransactionBase
|
||||
from erpnext.accounts.party import validate_party_accounts
|
||||
|
||||
class Supplier(TransactionBase):
|
||||
def get_feed(self):
|
||||
@ -45,6 +46,8 @@ class Supplier(TransactionBase):
|
||||
if not self.naming_series:
|
||||
msgprint(_("Series is mandatory"), raise_exception=1)
|
||||
|
||||
validate_party_accounts(self)
|
||||
|
||||
def get_contacts(self,nm):
|
||||
if nm:
|
||||
contact_details =frappe.db.convert_to_lists(frappe.db.sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = %s", nm))
|
||||
|
@ -7,10 +7,10 @@ from frappe.model.naming import make_autoname
|
||||
from frappe import _, msgprint, throw
|
||||
import frappe.defaults
|
||||
from frappe.utils import flt
|
||||
|
||||
from frappe.desk.reportview import build_match_conditions
|
||||
from erpnext.utilities.transaction_base import TransactionBase
|
||||
from erpnext.utilities.address_and_contact import load_address_and_contact
|
||||
from frappe.desk.reportview import build_match_conditions
|
||||
from erpnext.accounts.party import validate_party_accounts
|
||||
|
||||
class Customer(TransactionBase):
|
||||
def get_feed(self):
|
||||
@ -32,6 +32,7 @@ class Customer(TransactionBase):
|
||||
|
||||
def validate(self):
|
||||
self.flags.is_new_doc = self.is_new()
|
||||
validate_party_accounts(self)
|
||||
|
||||
def update_lead_status(self):
|
||||
if self.lead_name:
|
||||
|
Loading…
x
Reference in New Issue
Block a user