feat: details fetched from supplier group in supplier

This commit is contained in:
Noah Jacob 2021-06-16 19:03:27 +05:30
parent 1ef1daf383
commit 9965af166e
2 changed files with 31 additions and 1 deletions

View File

@ -60,10 +60,23 @@ frappe.ui.form.on("Supplier", {
erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name);
}, __('Create'));
frm.add_custom_button(__('Get Supplier Group Details'), function () {
frm.trigger("get_supplier_group_details");
}, __('Actions'));
// indicators
erpnext.utils.set_party_dashboard_indicators(frm);
}
},
get_supplier_group_details: function(frm) {
frappe.call({
method: "get_supplier_group_details",
doc: frm.doc,
callback: function(r){
frm.refresh()
}
});
},
is_internal_supplier: function(frm) {
if (frm.doc.is_internal_supplier == 1) {

View File

@ -51,6 +51,23 @@ class Supplier(TransactionBase):
validate_party_accounts(self)
self.validate_internal_supplier()
@frappe.whitelist()
def get_supplier_group_details(self):
doc = frappe.get_doc('Supplier Group', self.supplier_group)
self.payment_terms = ""
self.accounts = []
if not self.accounts and doc.accounts:
for account in doc.accounts:
child = self.append('accounts')
child.company = account.company
child.account = account.account
self.save()
if not self.payment_terms and doc.payment_terms:
self.payment_terms = doc.payment_terms
def validate_internal_supplier(self):
internal_supplier = frappe.db.get_value("Supplier",
{"is_internal_supplier": 1, "represents_company": self.represents_company, "name": ("!=", self.name)}, "name")