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


Python Date.today方法代码示例

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


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

示例1: _get_car_atn

# 需要导入模块: from odoo.fields import Date [as 别名]
# 或者: from odoo.fields.Date import today [as 别名]
    def _get_car_atn(self, acquisition_date, car_value, fuel_type, co2):
        # Compute the correction coefficient from the age of the car
        now = Date.today()
        if acquisition_date:
            number_of_month = ((now.year - acquisition_date.year) * 12.0 + now.month -
                               acquisition_date.month +
                               int(bool(now.day - acquisition_date.day + 1)))
            if number_of_month <= 12:
                age_coefficient = 1.00
            elif number_of_month <= 24:
                age_coefficient = 0.94
            elif number_of_month <= 36:
                age_coefficient = 0.88
            elif number_of_month <= 48:
                age_coefficient = 0.82
            elif number_of_month <= 60:
                age_coefficient = 0.76
            else:
                age_coefficient = 0.70
            car_value = car_value * age_coefficient
            # Compute atn value from corrected car_value
            magic_coeff = 6.0 / 7.0  # Don't ask me why
            if fuel_type == 'electric':
                atn = 0.0
            else:
                if fuel_type in ['diesel', 'hybrid']:
                    reference = 87.0
                else:
                    reference = 105.0

                if co2 <= reference:
                    atn = car_value * max(0.04, (0.055 - 0.001 * (reference - co2))) * magic_coeff
                else:
                    atn = car_value * min(0.18, (0.055 + 0.001 * (co2 - reference))) * magic_coeff
            return max(1280, atn) / 12.0
开发者ID:Gorrice,项目名称:odoo,代码行数:37,代码来源:fleet.py

示例2: setUp

# 需要导入模块: from odoo.fields import Date [as 别名]
# 或者: from odoo.fields.Date import today [as 别名]
    def setUp(self):
        super(TestTheoreticalAmount, self).setUp()
        #create the budgetary position
        user_type_id = self.ref('account.data_account_type_revenue')
        tag_id = self.ref('account.account_tag_operating')
        account_rev = self.env['account.account'].create({
            'code': 'Y2020',
            'name': 'Budget - Test Revenue Account',
            'user_type_id': user_type_id,
            'tag_ids': [(4, tag_id, 0)]
        })
        buget_post = self.env['account.budget.post'].create({
            'name': 'Sales',
            'account_ids': [(4, account_rev.id, 0)],
        })
        #create the budget and budget lines
        first_january = Datetime.now().replace(day=1, month=1)
        self.last_day_of_budget = first_january + timedelta(days=364)  # will be 30th of December or 31th in case of leap year

        date_from = first_january.date()
        date_to = self.last_day_of_budget.date()

        crossovered_budget = self.env['crossovered.budget'].create({
            'name': 'test budget name',
            'date_from': date_from,
            'date_to': date_to,
        })
        crossovered_budget_line_obj = self.env['crossovered.budget.lines']
        self.line = crossovered_budget_line_obj.create({
            'crossovered_budget_id': crossovered_budget.id,
            'general_budget_id': buget_post.id,
            'date_from': date_from,
            'date_to': date_to,
            'planned_amount': -364,
        })
        self.paid_date_line = crossovered_budget_line_obj.create({
            'crossovered_budget_id': crossovered_budget.id,
            'general_budget_id': buget_post.id,
            'date_from': date_from,
            'date_to': date_to,
            'planned_amount': -364,
            'paid_date':  Date.today().replace(day=9, month=9),
        })

        self.patcher = patch('odoo.addons.account_budget.models.account_budget.fields.Date', wraps=Date)
        self.mock_date = self.patcher.start()
开发者ID:astirpe,项目名称:odoo,代码行数:48,代码来源:test_theoreticalamount.py

示例3: setUp

# 需要导入模块: from odoo.fields import Date [as 别名]
# 或者: from odoo.fields.Date import today [as 别名]
    def setUp(self):
        super(TestPayslipBase, self).setUp()

        # Some salary rules references
        self.hra_rule_id = self.ref('hr_payroll.hr_salary_rule_houserentallowance1')
        self.conv_rule_id = self.ref('hr_payroll.hr_salary_rule_convanceallowance1')
        self.prof_tax_rule_id = self.ref('hr_payroll.hr_salary_rule_professionaltax1')
        self.pf_rule_id = self.ref('hr_payroll.hr_salary_rule_providentfund1')
        self.mv_rule_id = self.ref('hr_payroll.hr_salary_rule_meal_voucher')
        self.comm_rule_id = self.ref('hr_payroll.hr_salary_rule_sales_commission')

        # I create a new employee "Richard"
        self.richard_emp = self.env['hr.employee'].create({
            'name': 'Richard',
            'gender': 'male',
            'birthday': '1984-05-01',
            'country_id': self.ref('base.be'),
            'department_id': self.ref('hr.dep_rd')
        })

        # I create a salary structure for "Software Developer"
        self.developer_pay_structure = self.env['hr.payroll.structure'].create({
            'name': 'Salary Structure for Software Developer',
            'code': 'SD',
            'company_id': self.ref('base.main_company'),
            'rule_ids': [(4, self.hra_rule_id), (4, self.conv_rule_id),
                         (4, self.prof_tax_rule_id), (4, self.pf_rule_id),
                         (4, self.mv_rule_id), (4, self.comm_rule_id)],
        })

        # I create a contract for "Richard"
        self.env['hr.contract'].create({
            'date_end': Date.to_string((datetime.now() + timedelta(days=365))),
            'date_start': Date.today(),
            'name': 'Contract for Richard',
            'wage': 5000.0,
            'type_id': self.ref('hr_contract.hr_contract_type_emp'),
            'employee_id': self.richard_emp.id,
            'struct_id': self.developer_pay_structure.id,
        })
开发者ID:10537,项目名称:odoo,代码行数:42,代码来源:common.py


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