日期排序优化
This commit is contained in:
@@ -82,12 +82,7 @@ class EstateProperty(models.Model):
|
||||
best_price = fields.Float(
|
||||
string="最佳报价", compute="_compute_best_price", store=True
|
||||
)
|
||||
create_date_month = fields.Char(
|
||||
string="创建月份",
|
||||
compute="_compute_create_date_month",
|
||||
store=True,
|
||||
index=True,
|
||||
)
|
||||
create_date_month = fields.Char(string="创建月份", index=True, copy=False)
|
||||
# 房产预期价格必须严格为正数
|
||||
_sql_constraints = [
|
||||
("check_expected_price", "CHECK(expected_price > 0)", "预期价格必须为正数"),
|
||||
@@ -187,9 +182,12 @@ class EstateProperty(models.Model):
|
||||
"""拒绝报价"""
|
||||
return self.write({"state": "offer_received"})
|
||||
|
||||
def _compute_create_date_month(self):
|
||||
for rec in self:
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
records = super().create(vals_list)
|
||||
for rec in records:
|
||||
if rec.create_date:
|
||||
rec.create_date_month = rec.create_date.strftime("%Y-%m")
|
||||
else:
|
||||
rec.create_date_month = False
|
||||
rec.create_date_month = fields.Date.today().strftime("%Y-%m")
|
||||
return records
|
||||
|
||||
@@ -11,19 +11,7 @@ class HrAttendance(models.Model):
|
||||
userid = fields.Char(string="userid")
|
||||
groupname = fields.Char(string="打卡规则名称")
|
||||
current_data = fields.Date(string="打卡日期", tracking=True)
|
||||
current_data_month = fields.Char(
|
||||
string="打卡日期(月份)",
|
||||
compute="_compute_current_data_month",
|
||||
store=True,
|
||||
index=True,
|
||||
)
|
||||
|
||||
def _compute_current_data_month(self):
|
||||
for rec in self:
|
||||
if rec.current_data:
|
||||
rec.current_data_month = rec.current_data.strftime("%Y-%m")
|
||||
else:
|
||||
rec.current_data_month = False
|
||||
current_data_month = fields.Char(string="打卡日期(月份)",index=True, copy=False)
|
||||
|
||||
sch_check_in_time = fields.Datetime(string="上班正常时间")
|
||||
sch_check_out_time = fields.Datetime(string="下班正常时间")
|
||||
@@ -81,7 +69,15 @@ class HrAttendance(models.Model):
|
||||
"domain": [("hr_attendance_id", "=", self.id)],
|
||||
"context": {"hr_attendance_id": self.id},
|
||||
}
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
records = super().create(vals_list)
|
||||
for rec in records:
|
||||
if rec.current_data:
|
||||
rec.current_data_month = rec.current_data.strftime("%Y-%m")
|
||||
else:
|
||||
rec.current_data_month = fields.Date.today().strftime("%Y-%m")
|
||||
return records
|
||||
@api.constrains("check_in", "check_out", "employee_id")
|
||||
def _check_validity(self):
|
||||
for attendance in self:
|
||||
|
||||
@@ -214,14 +214,7 @@ class MeterArchivesLine(models.Model):
|
||||
initial_value = fields.Float(string="初始读数")
|
||||
last_read = fields.Float(string="上次读数", store=True, group_operator=None, compute="_compute_last")
|
||||
meter_date = fields.Date(string="任务日期")
|
||||
meter_date_month = fields.Char(string="任务日期月份", compute="_compute_meter_date_month", store=True, index=True,)
|
||||
|
||||
def _compute_meter_date_month(self):
|
||||
for rec in self:
|
||||
if rec.meter_date:
|
||||
rec.meter_date_month = rec.meter_date.strftime("%Y-%m")
|
||||
else:
|
||||
rec.meter_date_month = False
|
||||
meter_date_month = fields.Char(string="任务日期月份", index=True, copy=False)
|
||||
|
||||
current_meter = fields.Float(string="本次用量", group_operator=None, compute="_compute_current_meter")
|
||||
current_read = fields.Float(string="本次读数", group_operator=None)
|
||||
@@ -239,6 +232,16 @@ class MeterArchivesLine(models.Model):
|
||||
maximum_count = fields.Integer(string="最大位数")
|
||||
is_push = fields.Boolean(string='推送', default=False)
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
records = super().create(vals_list)
|
||||
for rec in records:
|
||||
if rec.meter_date:
|
||||
rec.meter_date_month = rec.meter_date.strftime("%Y-%m")
|
||||
else:
|
||||
rec.meter_date_month = fields.Date.today().strftime("%Y-%m")
|
||||
return records
|
||||
|
||||
@api.depends('last_read', 'current_read')
|
||||
def _compute_current_meter(self):
|
||||
for record in self:
|
||||
|
||||
@@ -188,7 +188,7 @@ class MeterWaterLine(models.Model):
|
||||
last_dosage = fields.Float(string="上次用量", store=True, group_operator=None, compute="_compute_last")
|
||||
last_read = fields.Float(string="上次读数", group_operator=None, compute="_compute_last")
|
||||
meter_date = fields.Date(string="任务日期")
|
||||
meter_date_month = fields.Char(string="任务日期月份", compute="_compute_meter_date_month", store=True, index=True)
|
||||
meter_date_month = fields.Char(string="任务日期月份", index=True, copy=False)
|
||||
current_meter = fields.Float(string="本次用量", group_operator=None, compute="_compute_current_meter")
|
||||
current_read = fields.Float(string='本次读数', group_operator=None)
|
||||
unit_number = fields.Char(string='单元编号/用途')
|
||||
@@ -205,6 +205,16 @@ class MeterWaterLine(models.Model):
|
||||
maximum_count = fields.Integer(string='最大位数')
|
||||
is_push = fields.Boolean(string='推送', default=False)
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
records = super().create(vals_list)
|
||||
for rec in records:
|
||||
if rec.meter_date:
|
||||
rec.meter_date_month = rec.meter_date.strftime("%Y-%m")
|
||||
else:
|
||||
rec.meter_date_month = fields.Date.today().strftime("%Y-%m")
|
||||
return records
|
||||
|
||||
@api.depends('last_read', 'current_read')
|
||||
def _compute_current_meter(self):
|
||||
for record in self:
|
||||
|
||||
Reference in New Issue
Block a user