doctype level changes
This commit is contained in:
parent
4437a5ed18
commit
0a50554417
@ -120,12 +120,12 @@ class OpeningInvoiceCreationTool(Document):
|
|||||||
if party_type == "Customer":
|
if party_type == "Customer":
|
||||||
party_doc.customer_name = party
|
party_doc.customer_name = party
|
||||||
else:
|
else:
|
||||||
supplier_type = frappe.db.get_single_value("Buying Settings", "supplier_type")
|
supplier_group = frappe.db.get_single_value("Buying Settings", "supplier_group")
|
||||||
if not supplier_type:
|
if not supplier_group:
|
||||||
frappe.throw(_("Please Set Supplier Type in Buying Settings."))
|
frappe.throw(_("Please Set Supplier Group in Buying Settings."))
|
||||||
|
|
||||||
party_doc.supplier_name = party
|
party_doc.supplier_name = party
|
||||||
party_doc.supplier_type = supplier_type
|
party_doc.supplier_group = supplier_group
|
||||||
|
|
||||||
party_doc.flags.ignore_mandatory = True
|
party_doc.flags.ignore_mandatory = True
|
||||||
party_doc.save(ignore_permissions=True)
|
party_doc.save(ignore_permissions=True)
|
||||||
|
|||||||
@ -33,7 +33,7 @@ frappe.ui.form.on("Pricing Rule", "refresh", function(frm) {
|
|||||||
${__("Pricing Rule is first selected based on 'Apply On' field, which can be Item, Item Group or Brand.")}
|
${__("Pricing Rule is first selected based on 'Apply On' field, which can be Item, Item Group or Brand.")}
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
${__("Then Pricing Rules are filtered out based on Customer, Customer Group, Territory, Supplier, Supplier Type, Campaign, Sales Partner etc.")}
|
${__("Then Pricing Rules are filtered out based on Customer, Customer Group, Territory, Supplier, Supplier Group, Campaign, Sales Partner etc.")}
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
${__('Pricing Rules are further filtered based on quantity.')}
|
${__('Pricing Rules are further filtered based on quantity.')}
|
||||||
@ -51,7 +51,7 @@ frappe.ui.form.on("Pricing Rule", "refresh", function(frm) {
|
|||||||
${__('Customer > Customer Group > Territory')}
|
${__('Customer > Customer Group > Territory')}
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
${__('Supplier > Supplier Type')}
|
${__('Supplier > Supplier Group')}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@ -75,7 +75,7 @@ cur_frm.cscript.set_options_for_applicable_for = function() {
|
|||||||
options = $.merge(options, ["Customer", "Customer Group", "Territory", "Sales Partner", "Campaign"]);
|
options = $.merge(options, ["Customer", "Customer Group", "Territory", "Sales Partner", "Campaign"]);
|
||||||
}
|
}
|
||||||
if(cur_frm.doc.buying) {
|
if(cur_frm.doc.buying) {
|
||||||
$.merge(options, ["Supplier", "Supplier Type"]);
|
$.merge(options, ["Supplier", "Supplier Group"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_field_options("applicable_for", options.join("\n"));
|
set_field_options("applicable_for", options.join("\n"));
|
||||||
|
|||||||
@ -41,7 +41,7 @@ class PricingRule(Document):
|
|||||||
throw(_("Selling must be checked, if Applicable For is selected as {0}"
|
throw(_("Selling must be checked, if Applicable For is selected as {0}"
|
||||||
.format(self.applicable_for)))
|
.format(self.applicable_for)))
|
||||||
|
|
||||||
if not self.buying and self.applicable_for in ["Supplier", "Supplier Type"]:
|
if not self.buying and self.applicable_for in ["Supplier", "Supplier Group"]:
|
||||||
throw(_("Buying must be checked, if Applicable For is selected as {0}"
|
throw(_("Buying must be checked, if Applicable For is selected as {0}"
|
||||||
.format(self.applicable_for)))
|
.format(self.applicable_for)))
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ def apply_pricing_rule(args):
|
|||||||
"customer_group": "something",
|
"customer_group": "something",
|
||||||
"territory": "something",
|
"territory": "something",
|
||||||
"supplier": "something",
|
"supplier": "something",
|
||||||
"supplier_type": "something",
|
"supplier_group": "something",
|
||||||
"currency": "something",
|
"currency": "something",
|
||||||
"conversion_rate": "something",
|
"conversion_rate": "something",
|
||||||
"price_list": "something",
|
"price_list": "something",
|
||||||
@ -165,10 +165,10 @@ def get_pricing_rule_for_item(args):
|
|||||||
if customer:
|
if customer:
|
||||||
args.customer_group, args.territory = customer
|
args.customer_group, args.territory = customer
|
||||||
|
|
||||||
args.supplier = args.supplier_type = None
|
args.supplier = args.supplier_group = None
|
||||||
|
|
||||||
elif args.supplier and not args.supplier_type:
|
elif args.supplier and not args.supplier_group:
|
||||||
args.supplier_type = frappe.db.get_value("Supplier", args.supplier, "supplier_type")
|
args.supplier_group = frappe.db.get_value("Supplier", args.supplier, "supplier_group")
|
||||||
args.customer = args.customer_group = args.territory = None
|
args.customer = args.customer_group = args.territory = None
|
||||||
|
|
||||||
pricing_rules = get_pricing_rules(args)
|
pricing_rules = get_pricing_rules(args)
|
||||||
@ -258,7 +258,7 @@ def get_pricing_rules(args):
|
|||||||
conditions = item_variant_condition = ""
|
conditions = item_variant_condition = ""
|
||||||
values = {"item_code": args.get("item_code"), "brand": args.get("brand")}
|
values = {"item_code": args.get("item_code"), "brand": args.get("brand")}
|
||||||
|
|
||||||
for field in ["company", "customer", "supplier", "supplier_type", "campaign", "sales_partner"]:
|
for field in ["company", "customer", "supplier", "supplier_group", "campaign", "sales_partner"]:
|
||||||
if args.get(field):
|
if args.get(field):
|
||||||
conditions += " and ifnull("+field+", '') in (%("+field+")s, '')"
|
conditions += " and ifnull("+field+", '') in (%("+field+")s, '')"
|
||||||
values[field] = args.get(field)
|
values[field] = args.get(field)
|
||||||
@ -324,11 +324,11 @@ def filter_pricing_rules(args, pricing_rules):
|
|||||||
|
|
||||||
# apply internal priority
|
# apply internal priority
|
||||||
all_fields = ["item_code", "item_group", "brand", "customer", "customer_group", "territory",
|
all_fields = ["item_code", "item_group", "brand", "customer", "customer_group", "territory",
|
||||||
"supplier", "supplier_type", "campaign", "sales_partner", "variant_of"]
|
"supplier", "supplier_group", "campaign", "sales_partner", "variant_of"]
|
||||||
|
|
||||||
if len(pricing_rules) > 1:
|
if len(pricing_rules) > 1:
|
||||||
for field_set in [["item_code", "variant_of", "item_group", "brand"],
|
for field_set in [["item_code", "variant_of", "item_group", "brand"],
|
||||||
["customer", "customer_group", "territory"], ["supplier", "supplier_type"]]:
|
["customer", "customer_group", "territory"], ["supplier", "supplier_group"]]:
|
||||||
remaining_fields = list(set(all_fields) - set(field_set))
|
remaining_fields = list(set(all_fields) - set(field_set))
|
||||||
if if_all_rules_same(pricing_rules, remaining_fields):
|
if if_all_rules_same(pricing_rules, remaining_fields):
|
||||||
pricing_rules = apply_internal_priority(pricing_rules, field_set, args)
|
pricing_rules = apply_internal_priority(pricing_rules, field_set, args)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
cur_frm.add_fetch("customer", "customer_group", "customer_group" );
|
cur_frm.add_fetch("customer", "customer_group", "customer_group" );
|
||||||
cur_frm.add_fetch("supplier", "supplier_type", "supplier_type" );
|
cur_frm.add_fetch("supplier", "supplier_group_name", "supplier_group" );
|
||||||
|
|
||||||
frappe.ui.form.on("Tax Rule", "tax_type", function(frm) {
|
frappe.ui.form.on("Tax Rule", "tax_type", function(frm) {
|
||||||
frm.toggle_reqd("sales_tax_template", frm.doc.tax_type=="Sales");
|
frm.toggle_reqd("sales_tax_template", frm.doc.tax_type=="Sales");
|
||||||
|
|||||||
@ -30,7 +30,7 @@ class TaxRule(Document):
|
|||||||
|
|
||||||
def validate_tax_template(self):
|
def validate_tax_template(self):
|
||||||
if self.tax_type== "Sales":
|
if self.tax_type== "Sales":
|
||||||
self.purchase_tax_template = self.supplier = self.supplier_type = None
|
self.purchase_tax_template = self.supplier = self.supplier_group = None
|
||||||
if self.customer:
|
if self.customer:
|
||||||
self.customer_group = None
|
self.customer_group = None
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ class TaxRule(Document):
|
|||||||
self.sales_tax_template = self.customer = self.customer_group = None
|
self.sales_tax_template = self.customer = self.customer_group = None
|
||||||
|
|
||||||
if self.supplier:
|
if self.supplier:
|
||||||
self.supplier_type = None
|
self.supplier_group = None
|
||||||
|
|
||||||
if not (self.sales_tax_template or self.purchase_tax_template):
|
if not (self.sales_tax_template or self.purchase_tax_template):
|
||||||
frappe.throw(_("Tax Template is mandatory."))
|
frappe.throw(_("Tax Template is mandatory."))
|
||||||
@ -53,7 +53,7 @@ class TaxRule(Document):
|
|||||||
"customer": self.customer,
|
"customer": self.customer,
|
||||||
"customer_group": self.customer_group,
|
"customer_group": self.customer_group,
|
||||||
"supplier": self.supplier,
|
"supplier": self.supplier,
|
||||||
"supplier_type": self.supplier_type,
|
"supplier_group": self.supplier_group,
|
||||||
"billing_city": self.billing_city,
|
"billing_city": self.billing_city,
|
||||||
"billing_county": self.billing_county,
|
"billing_county": self.billing_county,
|
||||||
"billing_state": self.billing_state,
|
"billing_state": self.billing_state,
|
||||||
|
|||||||
@ -10,7 +10,7 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
class BuyingSettings(Document):
|
class BuyingSettings(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
for key in ["supplier_type", "supp_master_name", "maintain_same_rate", "buying_price_list"]:
|
for key in ["supplier_group", "supp_master_name", "maintain_same_rate", "buying_price_list"]:
|
||||||
frappe.db.set_default(key, self.get(key, ""))
|
frappe.db.set_default(key, self.get(key, ""))
|
||||||
|
|
||||||
from erpnext.setup.doctype.naming_series.naming_series import set_by_naming_series
|
from erpnext.setup.doctype.naming_series.naming_series import set_by_naming_series
|
||||||
|
|||||||
@ -61,11 +61,11 @@ frappe.ui.form.on("Request for Quotation",{
|
|||||||
fields: [
|
fields: [
|
||||||
{ "fieldtype": "Select", "label": __("Get Suppliers By"),
|
{ "fieldtype": "Select", "label": __("Get Suppliers By"),
|
||||||
"fieldname": "search_type",
|
"fieldname": "search_type",
|
||||||
"options": "Tag\nSupplier Type", "reqd": 1 },
|
"options": "Tag\nSupplier Group", "reqd": 1 },
|
||||||
{ "fieldtype": "Link", "label": __("Supplier Type"),
|
{ "fieldtype": "Link", "label": __("Supplier Group"),
|
||||||
"fieldname": "supplier_type",
|
"fieldname": "supplier_group",
|
||||||
"options": "Supplier Type", "reqd": 0,
|
"options": "Supplier Group", "reqd": 0,
|
||||||
"depends_on": "eval:doc.search_type == 'Supplier Type'"},
|
"depends_on": "eval:doc.search_type == 'Supplier Group'"},
|
||||||
{ "fieldtype": "Data", "label": __("Tag"),
|
{ "fieldtype": "Data", "label": __("Tag"),
|
||||||
"fieldname": "tag", "reqd": 0,
|
"fieldname": "tag", "reqd": 0,
|
||||||
"depends_on": "eval:doc.search_type == 'Tag'" },
|
"depends_on": "eval:doc.search_type == 'Tag'" },
|
||||||
@ -121,14 +121,14 @@ frappe.ui.form.on("Request for Quotation",{
|
|||||||
},
|
},
|
||||||
callback: load_suppliers
|
callback: load_suppliers
|
||||||
});
|
});
|
||||||
} else if (args.supplier_type) {
|
} else if (args.supplier_group) {
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: "frappe.client.get_list",
|
method: "frappe.client.get_list",
|
||||||
args: {
|
args: {
|
||||||
doctype: "Supplier",
|
doctype: "Supplier",
|
||||||
order_by: "name",
|
order_by: "name",
|
||||||
fields: ["name"],
|
fields: ["name"],
|
||||||
filters: [["Supplier", "supplier_type", "=", args.supplier_type]]
|
filters: [["Supplier", "supplier_group_name", "=", args.supplier_group]]
|
||||||
|
|
||||||
},
|
},
|
||||||
callback: load_suppliers
|
callback: load_suppliers
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class TestRequestforQuotation(unittest.TestCase):
|
|||||||
frappe.delete_doc_if_exists("Supplier", "_Test Supplier '1", force=1)
|
frappe.delete_doc_if_exists("Supplier", "_Test Supplier '1", force=1)
|
||||||
supplier = frappe.new_doc("Supplier")
|
supplier = frappe.new_doc("Supplier")
|
||||||
supplier.supplier_name = "_Test Supplier '1"
|
supplier.supplier_name = "_Test Supplier '1"
|
||||||
supplier.supplier_type = "_Test Supplier Type"
|
supplier.supplier_group = "_Test Supplier Group"
|
||||||
supplier.insert()
|
supplier.insert()
|
||||||
|
|
||||||
rfq = make_request_for_quotation(supplier_wt_appos)
|
rfq = make_request_for_quotation(supplier_wt_appos)
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
frappe.listview_settings['Supplier'] = {
|
frappe.listview_settings['Supplier'] = {
|
||||||
add_fields: ["supplier_name", "supplier_type", "image"],
|
add_fields: ["supplier_name", "supplier_group", "image"],
|
||||||
};
|
};
|
||||||
|
|||||||
@ -7,7 +7,7 @@ QUnit.test("test: supplier", function(assert) {
|
|||||||
() => {
|
() => {
|
||||||
return frappe.tests.make('Supplier', [
|
return frappe.tests.make('Supplier', [
|
||||||
{supplier_name: 'Test Supplier'},
|
{supplier_name: 'Test Supplier'},
|
||||||
{supplier_type: 'Hardware'},
|
{supplier_group: 'Hardware'},
|
||||||
{country: 'India'},
|
{country: 'India'},
|
||||||
{default_currency: 'INR'},
|
{default_currency: 'INR'},
|
||||||
{accounts: [
|
{accounts: [
|
||||||
@ -66,7 +66,7 @@ QUnit.test("test: supplier", function(assert) {
|
|||||||
|
|
||||||
() => {
|
() => {
|
||||||
assert.ok(cur_frm.doc.supplier_name == 'Test Supplier', "Name correct");
|
assert.ok(cur_frm.doc.supplier_name == 'Test Supplier', "Name correct");
|
||||||
assert.ok(cur_frm.doc.supplier_type == 'Hardware', "Type correct");
|
assert.ok(cur_frm.doc.supplier_group == 'Hardware', "Type correct");
|
||||||
assert.ok(cur_frm.doc.default_currency == 'INR', "Currency correct");
|
assert.ok(cur_frm.doc.default_currency == 'INR', "Currency correct");
|
||||||
assert.ok(cur_frm.doc.accounts[0].account == 'Creditors - '+frappe.get_abbr('For Testing'), " Account Head abbr correct");
|
assert.ok(cur_frm.doc.accounts[0].account == 'Creditors - '+frappe.get_abbr('For Testing'), " Account Head abbr correct");
|
||||||
assert.ok($('.address-box:nth-child(3) p').text().includes('Shipping City 3'), "Address correct");
|
assert.ok($('.address-box:nth-child(3) p').text().includes('Shipping City 3'), "Address correct");
|
||||||
|
|||||||
@ -36,14 +36,14 @@ class TestSupplier(unittest.TestCase):
|
|||||||
|
|
||||||
frappe.db.set_value("Supplier", "_Test Supplier With Template 1", "payment_terms", "")
|
frappe.db.set_value("Supplier", "_Test Supplier With Template 1", "payment_terms", "")
|
||||||
|
|
||||||
# Set credit limit for the supplier type instead of supplier and evaluate the due date
|
# Set credit limit for the supplier group instead of supplier and evaluate the due date
|
||||||
frappe.db.set_value("Supplier Type", "_Test Supplier Type", "payment_terms", "_Test Payment Term Template 3")
|
frappe.db.set_value("Supplier Group", "_Test Supplier Group", "payment_terms", "_Test Payment Term Template 3")
|
||||||
|
|
||||||
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
||||||
self.assertEqual(due_date, "2016-02-21")
|
self.assertEqual(due_date, "2016-02-21")
|
||||||
|
|
||||||
# Payment terms for Supplier Type instead of supplier and evaluate the due date
|
# Payment terms for Supplier Group instead of supplier and evaluate the due date
|
||||||
frappe.db.set_value("Supplier Type", "_Test Supplier Type", "payment_terms", "_Test Payment Term Template 1")
|
frappe.db.set_value("Supplier Group", "_Test Supplier Group", "payment_terms", "_Test Payment Term Template 1")
|
||||||
|
|
||||||
# Leap year
|
# Leap year
|
||||||
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
||||||
@ -53,7 +53,7 @@ class TestSupplier(unittest.TestCase):
|
|||||||
self.assertEqual(due_date, "2017-02-28")
|
self.assertEqual(due_date, "2017-02-28")
|
||||||
|
|
||||||
# Supplier with no default Payment Terms Template
|
# Supplier with no default Payment Terms Template
|
||||||
frappe.db.set_value("Supplier Type", "_Test Supplier Type", "payment_terms", "")
|
frappe.db.set_value("Supplier Group", "_Test Supplier Group", "payment_terms", "")
|
||||||
frappe.db.set_value("Supplier", "_Test Supplier", "payment_terms", "")
|
frappe.db.set_value("Supplier", "_Test Supplier", "payment_terms", "")
|
||||||
|
|
||||||
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier")
|
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier")
|
||||||
|
|||||||
@ -755,9 +755,9 @@ def make_purchase_order_for_drop_shipment(source_name, for_supplier, target_doc=
|
|||||||
def get_supplier(doctype, txt, searchfield, start, page_len, filters):
|
def get_supplier(doctype, txt, searchfield, start, page_len, filters):
|
||||||
supp_master_name = frappe.defaults.get_user_default("supp_master_name")
|
supp_master_name = frappe.defaults.get_user_default("supp_master_name")
|
||||||
if supp_master_name == "Supplier Name":
|
if supp_master_name == "Supplier Name":
|
||||||
fields = ["name", "supplier_type"]
|
fields = ["name", "supplier_group"]
|
||||||
else:
|
else:
|
||||||
fields = ["name", "supplier_name", "supplier_type"]
|
fields = ["name", "supplier_name", "supplier_group"]
|
||||||
fields = ", ".join(fields)
|
fields = ", ".join(fields)
|
||||||
|
|
||||||
return frappe.db.sql("""select {field} from `tabSupplier`
|
return frappe.db.sql("""select {field} from `tabSupplier`
|
||||||
|
|||||||
@ -34,7 +34,7 @@ frappe.ui.form.on("Delivery Note", {
|
|||||||
|
|
||||||
frm.set_query('transporter_name', function(doc) {
|
frm.set_query('transporter_name', function(doc) {
|
||||||
return {
|
return {
|
||||||
filters: { 'supplier_type': "transporter" }
|
filters: { 'supplier_group': "transporter" }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user