23 lines
1.2 KiB
Python
23 lines
1.2 KiB
Python
from odoo import models, fields, api
|
|
from datetime import date, datetime, time
|
|
|
|
|
|
class HydropowerLogs(models.Model):
|
|
_name = 'hydropower.logs'
|
|
_description = '水电单价'
|
|
|
|
meter_type = fields.Selection([('electric', '电表'), ('water', '水表')], string='仪表类型')
|
|
select_time = fields.Selection([('1', '一月'), ('2', '二月'), ('3', '三月'), ('4', '四月'),
|
|
('5', '五月'), ('6', '六月'), ('7', '七月'), ('8', '八月'),
|
|
('9', '九月'), ('10', '十月'), ('11', '十一月'),
|
|
('12', '十二月')], string='计费月份',
|
|
default=lambda self: self._get_default_month())
|
|
select_year = fields.Selection(selection=[(str(i), str(i)) for i in range(2024, 2040)], string='计费年份',
|
|
default=lambda self: str(datetime.now().year))
|
|
price = fields.Float(string='单价', digits=(16, 4))
|
|
line_loss = fields.Float(string='线损', digits=(16, 4))
|
|
|
|
|
|
def _get_default_month(self):
|
|
current_month = datetime.now().month
|
|
return str(current_month) |