Python openerp.fields.Date() Examples
The following are 8
code examples of openerp.fields.Date().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
openerp.fields
, or try the search function
.
Example #1
Source File: hr_payroll.py From odoo-payroll with GNU General Public License v3.0 | 8 votes |
def _flextime_month(self): year = datetime.now().year month = datetime.now().month date_start = datetime(year, month, 1) if month == 12: year += 1 month = 1 else: month += 1 date_end = datetime(year, month, 1) - timedelta(days=1) self.flextime_month = round(sum(self.search([('employee_id', '=',self.employee_id.id), ('name', '>', fields.Date.to_string(date_start) + ' 00:00:00'), ('name', '<', fields.Date.to_string(date_end) + ' 23:59:59')]).mapped("flextime")))
Example #2
Source File: soccer_match.py From odoo-development with GNU Affero General Public License v3.0 | 5 votes |
def _default_match_day(self): """ Default value for day of the match, it will be today for new records. """ return fields.Date.context_today(self) # ------------------------- AUXILIARY FUNCTIONS ---------------------------
Example #3
Source File: library_book.py From Odoo-Development-Cookbook with MIT License | 5 votes |
def _check_release_date(self): for r in self: if r.date_release > fields.Date.today(): raise models.ValidationError( 'Release date must be in the past')
Example #4
Source File: models.py From Odoo-Development-Cookbook with MIT License | 5 votes |
def on_change_date_end(self): date_end = fields.Date.from_string(self.date_end) today = date.today() if date_end <= today: self.loan_duration = 0 return { 'warning': { 'title': 'expired membership', 'message': "Membership has expired", }, }
Example #5
Source File: models.py From Odoo-Development-Cookbook with MIT License | 5 votes |
def _default_date(self): return fields.Date.today()
Example #6
Source File: models.py From Odoo-Development-Cookbook with MIT License | 5 votes |
def _compute_date_due(self): for loan in self: start_date = fields.Date.from_string(loan.date) due_date = start_date + timedelta(days=loan.duration) loan.date_due = fields.Date.to_string(due_date)
Example #7
Source File: models.py From Odoo-Development-Cookbook with MIT License | 5 votes |
def _prepare_loan(self, book): values = super(LibraryLoanWizard, self)._prepare_loan(book) loan_duration = self.member_id.loan_duration expected = date.today() + timedelta(days=loan_duration) values.update( {'expected_return_date': fields.Date.to_string(expected)} ) return values
Example #8
Source File: hr_payroll.py From odoo-payroll with GNU General Public License v3.0 | 5 votes |
def get_unbanked_flextime(self): """Returns all flextime since last payslip.""" self.ensure_one() slip = self.env['hr.payslip'].sudo().search([('date_to', '<=', fields.Date.today()), ('state', '=', 'done')], limit = 1, order = 'date_to desc') if slip: attendances = self.env['hr.attendance'].search_read([('employee_id', '=', self.id), ('action', '=', 'sign_out'), ('name', '>', slip.date_to)], ['flextime']) else: attendances = self.env['hr.attendance'].search_read([('employee_id', '=', self.id)], ['flextime']) res = 0 for attendance in attendances: res += attendance['flextime'] return res