Skip to content

Commit

Permalink
fix: reset old code field values on update for better readability in …
Browse files Browse the repository at this point in the history
…the doctype form
  • Loading branch information
ruchamahabal committed Feb 2, 2024
1 parent 4d77fca commit 403a0d3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions hrms/payroll/doctype/salary_component/salary_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@

class SalaryComponent(Document):
def before_validate(self):
self.condition = sanitize_expression(self.condition)
self.formula = sanitize_expression(self.formula)
self._condition, self.condition = self.condition, sanitize_expression(self.condition)
self._formula, self.formula = self.formula, sanitize_expression(self.formula)

def validate(self):
self.validate_abbr()

def on_update(self):
# set old values (allowing multiline strings for better readability in the doctype form)
if self._condition != self.condition:
self.db_set("condition", self._condition)
if self._formula != self.formula:
self.db_set("formula", self._formula)

def after_insert(self):
if not (self.statistical_component or (self.accounts and all(d.account for d in self.accounts))):
frappe.msgprint(
Expand Down

0 comments on commit 403a0d3

Please sign in to comment.