Fixed Pricing Rule Cleanup Fieldname

This commit is contained in:
Anand Doshi 2014-03-05 17:27:00 +05:30
parent 74d0e40bdc
commit 7ea8528d50

View File

@ -6,8 +6,9 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import throw, _ from frappe import throw, _
from frappe.model.controller import DocListController
class DocType: class DocType(DocListController):
def __init__(self, d, dl): def __init__(self, d, dl):
self.doc, self.doclist = d, dl self.doc, self.doclist = d, dl
@ -23,15 +24,15 @@ class DocType:
frappe.MandatoryError) frappe.MandatoryError)
def cleanup_fields_value(self): def cleanup_fields_value(self):
fields = ["item_code", "item_group", "brand", "customer", "customer_group", for logic_field in ["apply_on", "applicable_for", "price_or_discount"]:
"territory", "supplier", "supplier_type", "campaign", "sales_partner", fieldname = frappe.scrub(self.doc.fields.get(logic_field) or "")
"price", "discount_percentage"]
for field_with_value in ["apply_on", "applicable_for", "price_or_discount"]: # reset all values except for the logic field
val = self.doc.fields.get(field_with_value) options = (self.meta.get_options(logic_field) or "").split("\n")
if val: for f in options:
fields.remove(frappe.scrub(val)) if not f: continue
for field in fields: f = frappe.scrub(f)
self.doc.fields[field] = None if f!=fieldname:
self.doc.fields[f] = None