Merge pull request !9538 from 李鹏宇/dev
This commit is contained in:
@@ -14,5 +14,18 @@
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall"/>
|
||||
</record>
|
||||
<record forcecreate="True" id="catering_fill_missing_cron" model="ir.cron">
|
||||
<field name="name">定时任务:自动补全当天餐饮收集数据</field>
|
||||
<field name="model_id" ref="model_yuthon_catering"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model.cron_fill_today_missing()</field>
|
||||
<field eval="True" name="active"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">days</field>
|
||||
<field name="nextcall" eval="(DateTime.now()).strftime('%Y-%m-%d 21:00:00')"/>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
</odoo>
|
||||
|
||||
@@ -308,7 +308,7 @@ class YuthonCatering(models.Model):
|
||||
def fill_march6_missing_catering(self):
|
||||
"""表3月9日缺失员工的餐饮收集任务数据"""
|
||||
from datetime import date as date_cls
|
||||
target_date = date_cls(2026, 3, 9)
|
||||
target_date = date_cls(2026, 3, 10)
|
||||
conf_records = self.env['yuthon.catering.conf'].search([])
|
||||
if not conf_records:
|
||||
return
|
||||
@@ -330,6 +330,30 @@ class YuthonCatering(models.Model):
|
||||
if create_vals:
|
||||
self.create(create_vals)
|
||||
|
||||
def cron_fill_today_missing(self):
|
||||
"""定时任务:自动补全当天缺失的餐饮收集数据,每天晚21:00执行"""
|
||||
today = fields.Date.today()
|
||||
conf_records = self.env['yuthon.catering.conf'].search([])
|
||||
if not conf_records:
|
||||
return
|
||||
employee_ids = conf_records.mapped('employee_ids')
|
||||
if not employee_ids:
|
||||
return
|
||||
create_vals = []
|
||||
for employee in employee_ids:
|
||||
existing = self.search([
|
||||
('employee_id', '=', employee.id),
|
||||
('date', '=', today),
|
||||
], limit=1)
|
||||
if not existing:
|
||||
create_vals.append({
|
||||
'date': today,
|
||||
'employee_id': employee.id,
|
||||
'state': 'unconfirmed',
|
||||
})
|
||||
if create_vals:
|
||||
self.create(create_vals)
|
||||
|
||||
def batch_generate_catering(self):
|
||||
"""批量生成2025-12、2026-01、2026-02的餐饮收集任务数据,排除节假日"""
|
||||
from datetime import date as date_cls
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<button name="task_catering22" string="一次修复" type="object" class="btn btn-primary"/>
|
||||
<button name="batch_confirm_catering" string="批量确认" type="object" class="btn btn-primary"/>
|
||||
<button name="batch_generate_catering" string="批量生成12/1/2月餐饮数据" type="object" class="btn btn-primary"/>
|
||||
<button name="fill_march6_missing_catering" string="表3月9日缺失数据" type="object" class="btn btn-primary"/>
|
||||
<button name="fill_march6_missing_catering" string="补3月10日缺失数据" type="object" class="btn btn-primary"/>
|
||||
</header>
|
||||
<field name="date"/>
|
||||
<field name="week_day" readonly="1"/>
|
||||
|
||||
@@ -843,30 +843,29 @@ class YuthonHrEmployee(models.Model):
|
||||
id_number = record.identification_id.upper()
|
||||
if len(id_number) != 18:
|
||||
record._clear_info()
|
||||
raise UserError("身份证号码长度应为18位")
|
||||
# raise UserError("身份证号码长度应为18位")
|
||||
# try:
|
||||
if not (all(c.isdigit() for c in id_number[:-1]) and (
|
||||
id_number[-1].isdigit() or id_number[-1] == 'X')):
|
||||
raise ValueError("身份证号码包含无效字符")
|
||||
|
||||
try:
|
||||
if not (all(c.isdigit() for c in id_number[:-1]) and (
|
||||
id_number[-1].isdigit() or id_number[-1] == 'X')):
|
||||
raise ValueError("身份证号码包含无效字符")
|
||||
year = int(id_number[6:10])
|
||||
month = int(id_number[10:12])
|
||||
day = int(id_number[12:14])
|
||||
record.birthday = date(year, month, day)
|
||||
record.birthday_month = month
|
||||
|
||||
year = int(id_number[6:10])
|
||||
month = int(id_number[10:12])
|
||||
day = int(id_number[12:14])
|
||||
record.birthday = date(year, month, day)
|
||||
record.birthday_month = month
|
||||
today = date.today()
|
||||
if year is not None:
|
||||
record.old = today.year - year - ((today.month, today.day) < (month, day))
|
||||
else:
|
||||
record.old = 0
|
||||
gender_code = int(id_number[-2])
|
||||
record.user_sex = 'girl' if gender_code % 2 == 0 else 'boy'
|
||||
|
||||
today = date.today()
|
||||
if year is not None:
|
||||
record.old = today.year - year - ((today.month, today.day) < (month, day))
|
||||
else:
|
||||
record.old = 0
|
||||
gender_code = int(id_number[-2])
|
||||
record.user_sex = 'girl' if gender_code % 2 == 0 else 'boy'
|
||||
|
||||
except ValueError as e:
|
||||
record._clear_info()
|
||||
raise UserError(str(e) or "身份证号码格式不正确") # Raise UserError
|
||||
# except ValueError as e:
|
||||
# record._clear_info()
|
||||
# raise UserError(str(e) or "身份证号码格式不正确")
|
||||
else:
|
||||
record._clear_info()
|
||||
self.is_identification = False
|
||||
|
||||
Reference in New Issue
Block a user