Commit c66a9f03 authored by Odoo's avatar Odoo
Browse files

[FIX] get_rule_dates_sub more simple and wrong query args

parent c26c9912
......@@ -188,21 +188,9 @@ class Payslips(BrowsableObject):
return result
def get_rule_dates_sub(self, months_back, date_to=False):
today = fields.Date.today()
date_to = date_to or self.date_to or today
date_to_obj = fields.Date.from_string(date_to)
date_from_obj = date_to_obj - relativedelta(months=months_back)
date_from = "{}-{:02}-01".format(date_from_obj.year,
date_from_obj.month)
if months_back == 0:
date_to = date_to
else:
date_to = fields.Date.to_string(
date_to_obj - timedelta(days=date_to_obj.day)
)
return date_from, date_to
date_to = date_to or self.date_to
date_from = date(date_to.year,date_to.month - int(months_back), 1)
return date_from.strftime('%Y-%m-%d'), date_to.strftime('%Y-%m-%d')
def rule_total_max_sub(self, rule_code,rule_code_sub, months_back,
date_to=False, *args, **kwargs):
......@@ -234,7 +222,7 @@ class Payslips(BrowsableObject):
date_from, date_to = self.get_rule_dates_sub(months_back, date_to)
query_arguments = (rule_code,rule_code_sub,self.employee_id.id or 0,
query_arguments = (rule_code,rule_code_sub,self.employee_id or 0,
rule_code,
rule_code_sub,
date_from,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment