fix: basic validations for Membership Type Linked Item

This commit is contained in:
Rucha Mahabal 2021-01-20 21:59:27 +05:30
parent 3575939386
commit fa4b3ba505
2 changed files with 15 additions and 3 deletions

View File

@ -3,12 +3,20 @@
frappe.ui.form.on('Membership Type', {
refresh: function (frm) {
frappe.db.get_single_value("Membership Settings", "enable_razorpay").then(val => {
frappe.db.get_single_value('Membership Settings', 'enable_razorpay').then(val => {
if (val) frm.set_df_property('razorpay_plan_id', 'hidden', false);
});
frappe.db.get_single_value("Membership Settings", "enable_invoicing").then(val => {
frappe.db.get_single_value('Membership Settings', 'enable_invoicing').then(val => {
if (val) frm.set_df_property('linked_item', 'hidden', false);
});
frm.set_query('linked_item', () => {
return {
filters: {
is_stock_item: 0
}
}
})
}
});

View File

@ -7,7 +7,11 @@ from frappe.model.document import Document
import frappe
class MembershipType(Document):
pass
def validate(self):
if self.linked_item:
is_stock_item = frappe.db.get_value("Item", self.linked_item, "is_stock_item")
if is_stock_item:
frappe.throw(_("The Linked Item should be a service item"))
def get_membership_type(razorpay_id):
return frappe.db.exists("Membership Type", {"razorpay_plan_id": razorpay_id})