当前位置: 首页>>代码示例>>Python>>正文


Python fields.Date方法代码示例

本文整理汇总了Python中openerp.fields.Date方法的典型用法代码示例。如果您正苦于以下问题:Python fields.Date方法的具体用法?Python fields.Date怎么用?Python fields.Date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openerp.fields的用法示例。


在下文中一共展示了fields.Date方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _flextime_month

# 需要导入模块: from openerp import fields [as 别名]
# 或者: from openerp.fields import Date [as 别名]
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"))) 
开发者ID:vertelab,项目名称:odoo-payroll,代码行数:13,代码来源:hr_payroll.py

示例2: _default_match_day

# 需要导入模块: from openerp import fields [as 别名]
# 或者: from openerp.fields import Date [as 别名]
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 --------------------------- 
开发者ID:sotogarcia,项目名称:odoo-development,代码行数:10,代码来源:soccer_match.py

示例3: _check_release_date

# 需要导入模块: from openerp import fields [as 别名]
# 或者: from openerp.fields import Date [as 别名]
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') 
开发者ID:PacktPublishing,项目名称:Odoo-Development-Cookbook,代码行数:7,代码来源:library_book.py

示例4: on_change_date_end

# 需要导入模块: from openerp import fields [as 别名]
# 或者: from openerp.fields import Date [as 别名]
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",
                },
            } 
开发者ID:PacktPublishing,项目名称:Odoo-Development-Cookbook,代码行数:13,代码来源:models.py

示例5: _default_date

# 需要导入模块: from openerp import fields [as 别名]
# 或者: from openerp.fields import Date [as 别名]
def _default_date(self):
        return fields.Date.today() 
开发者ID:PacktPublishing,项目名称:Odoo-Development-Cookbook,代码行数:4,代码来源:models.py

示例6: _compute_date_due

# 需要导入模块: from openerp import fields [as 别名]
# 或者: from openerp.fields import Date [as 别名]
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) 
开发者ID:PacktPublishing,项目名称:Odoo-Development-Cookbook,代码行数:7,代码来源:models.py

示例7: _prepare_loan

# 需要导入模块: from openerp import fields [as 别名]
# 或者: from openerp.fields import Date [as 别名]
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 
开发者ID:PacktPublishing,项目名称:Odoo-Development-Cookbook,代码行数:10,代码来源:models.py

示例8: get_unbanked_flextime

# 需要导入模块: from openerp import fields [as 别名]
# 或者: from openerp.fields import Date [as 别名]
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 
开发者ID:vertelab,项目名称:odoo-payroll,代码行数:14,代码来源:hr_payroll.py


注:本文中的openerp.fields.Date方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。