Skip to content

Instantly share code, notes, and snippets.

@tienhieuD
Created August 13, 2018 05:41
Show Gist options
  • Save tienhieuD/d55c0e5ddd1bbed47599e7a830c7979f to your computer and use it in GitHub Desktop.
Save tienhieuD/d55c0e5ddd1bbed47599e7a830c7979f to your computer and use it in GitHub Desktop.
import calendar
from datetime import datetime as date
def get_date_range(self, month, year):
last_day_of_month = calendar.monthrange(year, month)[1]
begin_date = date(year, month, 1).strftime('%Y-%m-%d')
end_date = date(year, month, last_day_of_month).strftime('%Y-%m-%d')
return begin_date, end_date
# -----------------------------------------
# Code
# -----------------------------------------
begin_date, end_date = self.get_date_range(month, year)
figure = self.env['working.rate'].search([
('employee_code', '=', self.employee_code),
('date', '>=', begin_date),
('date', '<=', end_date),
]).x_value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment