[fix] [minor] fixes after merging akhilesh's changes

This commit is contained in:
Anand Doshi 2013-08-12 20:01:55 +05:30
parent 9e59aff54e
commit 05a340e764
5 changed files with 44 additions and 32 deletions

View File

@ -197,17 +197,9 @@ class DocType(SellingController):
if pos: if pos:
self.doc.conversion_rate = flt(pos.conversion_rate) self.doc.conversion_rate = flt(pos.conversion_rate)
if not self.doc.debit_to: if not for_validate:
self.doc.debit_to = self.doc.customer and webnotes.conn.get_value("Account", { self.doc.customer = pos.customer
"name": self.doc.customer + " - " + self.get_company_abbr(), self.set_customer_defaults()
"docstatus": ["!=", 2]
}) or pos.customer_account
if self.doc.debit_to and not self.doc.customer:
self.doc.customer = webnotes.conn.get_value("Account", {
"name": self.doc.debit_to,
"master_type": "Customer"
}, "master_name")
for fieldname in ('territory', 'naming_series', 'currency', 'charge', 'letter_head', 'tc_name', for fieldname in ('territory', 'naming_series', 'currency', 'charge', 'letter_head', 'tc_name',
'selling_price_list', 'company', 'select_print_heading', 'cash_bank_account'): 'selling_price_list', 'company', 'select_print_heading', 'cash_bank_account'):

View File

@ -156,17 +156,18 @@ class DocType:
raise_exception=InvalidLeaveApproverError) raise_exception=InvalidLeaveApproverError)
def update_dob_event(self): def update_dob_event(self):
if self.doc.date_of_birth:
get_events = webnotes.conn.sql("""select name from `tabEvent` where repeat_on='Every Year' get_events = webnotes.conn.sql("""select name from `tabEvent` where repeat_on='Every Year'
and ref_type='Employee' and ref_name=%s""", (self.doc.name), as_dict=1) and ref_type='Employee' and ref_name=%s""", self.doc.name)
starts_on = self.doc.date_of_birth + " 00:00:00" starts_on = self.doc.date_of_birth + " 00:00:00"
ends_on = self.doc.date_of_birth + " 00:15:00" ends_on = self.doc.date_of_birth + " 00:15:00"
if get_events: if get_events:
webnotes.conn.sql("""update `tabEvent` set starts_on=%s, ends_on=%s webnotes.conn.sql("""update `tabEvent` set starts_on=%s, ends_on=%s
where name=%s""", (get_events[0].name, starts_on, ends_on) where name=%s""", (starts_on, ends_on, get_events[0][0]))
else: else:
event_wrapper = webnotes.bean({ webnotes.bean({
"doctype": "Event", "doctype": "Event",
"subject": _("Birthday") + ": " + self.doc.employee_name, "subject": _("Birthday") + ": " + self.doc.employee_name,
"starts_on": starts_on, "starts_on": starts_on,
@ -179,6 +180,9 @@ class DocType:
"ref_type": "Employee", "ref_type": "Employee",
"ref_name": self.doc.name "ref_name": self.doc.name
}).insert() }).insert()
else:
webnotes.conn.sql("""delete from `tabEvent` where repeat_on='Every Year' and
ref_type='Employee' and ref_name=%s""", self.doc.name)
@webnotes.whitelist() @webnotes.whitelist()
def get_retirement_date(date_of_birth=None): def get_retirement_date(date_of_birth=None):

View File

@ -1,3 +1,7 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes import webnotes
def execute(): def execute():

View File

@ -0,0 +1,11 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
def execute():
for employee in webnotes.conn.sql_list("""select name from `tabEmployee` where ifnull(date_of_birth, '')!=''"""):
obj = webnotes.get_obj("Employee", employee)
obj.update_dob_event()

View File

@ -254,4 +254,5 @@ patch_list = [
"patches.august_2013.p01_hr_settings", "patches.august_2013.p01_hr_settings",
"patches.august_2013.p02_rename_price_list", "patches.august_2013.p02_rename_price_list",
"patches.august_2013.p03_pos_setting_replace_customer_account", "patches.august_2013.p03_pos_setting_replace_customer_account",
"patches.august_2013.p04_employee_birthdays",
] ]