添加功能
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record forcecreate="True" id="financial_sheet_collection_task" model="ir.cron">
|
||||
<field name="name">定时任务:财务数据表</field>
|
||||
<field name="model_id" ref="model_financial_sheet_collection"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model.account_task()</field>
|
||||
<field eval="True" name="active"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">weeks</field>
|
||||
<field name="nextcall" eval="(DateTime.now()).strftime('%Y-%m-%d 08:20:00')"/>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall"/>
|
||||
</record>
|
||||
<record forcecreate="True" id="information_summary_table_task" model="ir.cron">
|
||||
<field name="name">定时任务:信息汇总表</field>
|
||||
<field name="model_id" ref="model_information_summary_table"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model.account_task()</field>
|
||||
<field eval="True" name="active"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">months</field>
|
||||
<field name="nextcall" eval="(DateTime.now()).strftime('%Y-%m-%d 08:20:00')"/>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall"/>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -5,14 +5,47 @@ class FinancialSheetCollection(models.Model):
|
||||
_name = 'financial.sheet.collection'
|
||||
_description = '财务数据表收集'
|
||||
|
||||
collection_id = fields.Many2one('sheet.collection.setting', string='项目名称')
|
||||
employee_id = fields.Many2one('hr.employee', string='人员')
|
||||
company_id = fields.Many2one('res.company', string='公司')
|
||||
department_id = fields.Many2one('hr.department', string="部门")
|
||||
user_role_id = fields.Many2one('soong.user.role', string="角色")
|
||||
create_date = fields.Datetime(string='创建日期', default=fields.Datetime.now)
|
||||
account_type = fields.Selection([('to', '待确认',), ('ok', '已确认')], string='状态', default='to')
|
||||
sheet_line_ids = fields.One2many('financial.sheet.line', 'sheet_id', string='财务数据表行')
|
||||
|
||||
def open_record(self):
|
||||
return {
|
||||
"type": "ir.actions.act_window",
|
||||
"res_model": 'financial.sheet.collection',
|
||||
"res_id": self.id,
|
||||
"name": "详情",
|
||||
"view_mode": "form",
|
||||
}
|
||||
|
||||
def button_put(self):
|
||||
menu_id = self.env['ir.ui.menu'].search([('name', '=', '财务数据表收集')])
|
||||
for record in self.search([('account_type', '=', 'to')]):
|
||||
url = f'https://oa.thtzjt.com/web#id={self.id}&cids=2&action={menu_id.action.id}&model=financial.sheet.collection&view_type=list&menu_id={menu_id.id}'
|
||||
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='notice',
|
||||
user_id=record.employee_id.wecom_userid,
|
||||
title="财务数据表",
|
||||
description="您有待确认的财务数据表请尽快确认",
|
||||
url=url, btntxt="详细信息")
|
||||
record.account_type = 'ok'
|
||||
|
||||
def account_task(self):
|
||||
pass
|
||||
|
||||
|
||||
class FinancialSheetLine(models.Model):
|
||||
_name = 'financial.sheet.line'
|
||||
_description = '财务数据表行'
|
||||
|
||||
sheet_id = fields.Many2one('financial.sheet.collection', string='关联财务数据表')
|
||||
collection_id = fields.Many2one('sheet.collection.setting', string='项目名称')
|
||||
this_issue_number = fields.Integer(string='本期数')
|
||||
same_last_year = fields.Integer(string='上年同期数')
|
||||
remake = fields.Text(string='说明')
|
||||
create_date = fields.Datetime(string='创建日期', default=fields.Datetime.now)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,10 +7,39 @@ class InformationSummaryTable(models.Model):
|
||||
_name = 'information.summary.table'
|
||||
_description = '信息汇总表收集'
|
||||
|
||||
table_id = fields.Many2one('summary.table.setting', string='项目名称')
|
||||
this_year = fields.Float(string='本年底')
|
||||
employee_id = fields.Many2one('hr.employee', string='人员')
|
||||
company_id = fields.Many2one('res.company', string='公司')
|
||||
department_id = fields.Many2one('hr.department', string="部门")
|
||||
user_role_id = fields.Many2one('soong.user.role', string="角色")
|
||||
account_type = fields.Selection([('to', '待确认', ), ('ok', '已确认')], string='状态', default='to')
|
||||
summary_line = fields.One2many('information.summary.line', 'summary_id', string='汇总表')
|
||||
|
||||
def open_record(self):
|
||||
return {
|
||||
"type": "ir.actions.act_window",
|
||||
"res_model": 'information.summary.table',
|
||||
"res_id": self.id,
|
||||
"name": "详情",
|
||||
"view_mode": "form",
|
||||
}
|
||||
|
||||
def button_put(self):
|
||||
menu_id = self.env['ir.ui.menu'].search([('name', '=', '信息汇总表收集')])
|
||||
for record in self.search([('account_type', '=', 'to')]):
|
||||
url = f'https://oa.thtzjt.com/web#id={self.id}&cids=2&action={menu_id.action.id}&model=information.summary.table&view_type=list&menu_id={menu_id.id}'
|
||||
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='notice', user_id=record.employee_id.wecom_userid, title="信息汇总表",
|
||||
description="您有待确认的信息汇总表请尽快确认", url=url, btntxt="详细信息")
|
||||
record.account_type = 'ok'
|
||||
|
||||
def account_task(self):
|
||||
pass
|
||||
|
||||
|
||||
class InformationSummaryLine(models.Model):
|
||||
_name = 'information.summary.line'
|
||||
_description = '信息汇总表明细'
|
||||
|
||||
summary_id = fields.Many2one('information.summary.table', string='关联汇总表')
|
||||
table_id = fields.Many2one('summary.table.setting', string='项目名称')
|
||||
this_year = fields.Float(string='本年底')
|
||||
remake = fields.Text(string='说明')
|
||||
|
||||
@@ -3,3 +3,5 @@ access_financial_sheet_collection,financial_sheet_collection,model_financial_she
|
||||
access_summary_table_setting,summary_table_setting,model_summary_table_setting,base.group_system,1,1,1,1
|
||||
access_information_summary_table,information_summary_table,model_information_summary_table,base.group_system,1,1,1,1
|
||||
access_sheet_collection_setting,sheet_collection_setting,model_sheet_collection_setting,base.group_system,1,1,1,1
|
||||
access_financial_sheet_line,financial_sheet_line,model_financial_sheet_line,base.group_system,1,1,1,1
|
||||
access_information_summary_line,information_summary_line,model_information_summary_line,base.group_system,1,1,1,1
|
||||
|
@@ -5,22 +5,58 @@
|
||||
<field name="model">financial.sheet.collection</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="财务数据表收集" editable="bottom">
|
||||
<field name="collection_id"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="company_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="user_role_id"/>
|
||||
<field name="this_issue_number"/>
|
||||
<field name="same_last_year"/>
|
||||
<field name="remake"/>
|
||||
<field name="create_date"/>
|
||||
<field name="account_type"
|
||||
decoration-danger="account_type == 'to'"
|
||||
decoration-success="account_type == 'ok'"
|
||||
/>
|
||||
<button name="button_put" string="发送" type="object" class="oe_highlight" invisible="account_type == 'ok'"/>
|
||||
<button name="open_record" type="object" string="详情" class="btn-primary"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="financial_sheet_collection_form" model="ir.ui.view">
|
||||
<field name="name">financial.sheet.collection.form</field>
|
||||
<field name="model">financial.sheet.collection</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="财务数据表收集">
|
||||
<sheet>
|
||||
<group col="2">
|
||||
<group>
|
||||
<field name="employee_id"/>
|
||||
<field name="company_id"/>
|
||||
<field name="department_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="user_role_id"/>
|
||||
<field name="create_date"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="财务数据表明细">
|
||||
<field name="sheet_line_ids">
|
||||
<tree editable="bottom">
|
||||
<field name="sheet_id" column_invisible="1"/>
|
||||
<field name="collection_id"/>
|
||||
<field name="this_issue_number"/>
|
||||
<field name="same_last_year"/>
|
||||
<field name="remake"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="financial_sheet_collection_action" model="ir.actions.act_window">
|
||||
<field name="name">财务数据表收集</field>
|
||||
<field name="res_model">financial.sheet.collection</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
|
||||
@@ -5,16 +5,52 @@
|
||||
<field name="model">information.summary.table</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="信息汇总表" editable="bottom">
|
||||
<field name="table_id"/>
|
||||
<field name="this_year"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="company_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="user_role_id"/>
|
||||
<field name="remake"/>
|
||||
<field name="account_type"
|
||||
decoration-danger="account_type == 'to'"
|
||||
decoration-success="account_type == 'ok'"
|
||||
/>
|
||||
<button name="button_put" string="发送" type="object" class="oe_highlight"
|
||||
invisible="account_type == 'ok'"/>
|
||||
<button name="open_record" type="object" string="详情" class="btn-primary"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="information_summary_table_form" model="ir.ui.view">
|
||||
<field name="name">information.summary.table.form</field>
|
||||
<field name="model">information.summary.table</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="信息汇总表">
|
||||
<sheet>
|
||||
<group col="2">
|
||||
<group>
|
||||
<field name="employee_id"/>
|
||||
<field name="company_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="department_id"/>
|
||||
<field name="user_role_id"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="信息汇总明细">
|
||||
<field name="summary_line">
|
||||
<tree editable="bottom">
|
||||
<field name="summary_id" column_invisible="1"/>
|
||||
<field name="table_id"/>
|
||||
<field name="this_year"/>
|
||||
<field name="remake"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="information_summary_table_action" model="ir.actions.act_window">
|
||||
<field name="name">信息汇总表</field>
|
||||
<field name="res_model">information.summary.table</field>
|
||||
|
||||
@@ -249,115 +249,115 @@ class PropertyReconciliationWizard(models.Model):
|
||||
total = sum(line.rent for line in self.reconciliation_line_ids)
|
||||
self.receivable_total = total
|
||||
|
||||
all_due_dates = []
|
||||
for line in self.reconciliation_line_ids:
|
||||
if line.collection_type == 'rent' and line.due_date:
|
||||
all_due_dates.append(fields.Date.from_string(line.due_date))
|
||||
# 2. 找到最早的到期日期
|
||||
if all_due_dates:
|
||||
earliest_due_date = min(all_due_dates)
|
||||
# 获取实际日期(假设actual_date是日期对象,如果是字符串需要先转换)
|
||||
actual_date = fields.Date.from_string(self.actual_date) if isinstance(self.actual_date,
|
||||
str) else self.actual_date
|
||||
|
||||
# 计算起始月份(最早到期日的月份)和结束月份(实际日期的月份)
|
||||
start_month = earliest_due_date + relativedelta(months=1)
|
||||
end_month = actual_date - relativedelta(months=1)
|
||||
|
||||
temp_rent_set = set()
|
||||
target_rent_months = []
|
||||
|
||||
# 遍历从起始月到结束月的所有月份
|
||||
current_month = start_month
|
||||
while current_month <= end_month:
|
||||
due_month = current_month.strftime('%Y-%m')
|
||||
# 为每个租金行添加当前月份的记录(去重)
|
||||
for line in self.reconciliation_line_ids:
|
||||
if line.collection_type == 'rent':
|
||||
unique_key = (
|
||||
line.contract_id.id if line.contract_id else None,
|
||||
due_month
|
||||
)
|
||||
if unique_key not in temp_rent_set:
|
||||
temp_rent_set.add(unique_key)
|
||||
target_rent_months.append({
|
||||
'contract_id': line.contract_id,
|
||||
'due_month': due_month
|
||||
})
|
||||
# 移动到下个月
|
||||
if current_month.month == 12:
|
||||
current_month = current_month.replace(year=current_month.year + 1, month=1, day=1)
|
||||
else:
|
||||
current_month = current_month.replace(month=current_month.month + 1, day=1)
|
||||
else:
|
||||
# all_due_dates = []
|
||||
# for line in self.reconciliation_line_ids:
|
||||
# if line.collection_type == 'rent' and line.due_date:
|
||||
# all_due_dates.append(fields.Date.from_string(line.due_date))
|
||||
# # 2. 找到最早的到期日期
|
||||
# if all_due_dates:
|
||||
# earliest_due_date = min(all_due_dates)
|
||||
# # 获取实际日期(假设actual_date是日期对象,如果是字符串需要先转换)
|
||||
# actual_date = fields.Date.from_string(self.actual_date) if isinstance(self.actual_date,
|
||||
# str) else self.actual_date
|
||||
#
|
||||
# # 计算起始月份(最早到期日的月份)和结束月份(实际日期的月份)
|
||||
# start_month = earliest_due_date + relativedelta(months=1)
|
||||
# end_month = actual_date - relativedelta(months=1)
|
||||
#
|
||||
# temp_rent_set = set()
|
||||
# target_rent_months = []
|
||||
#
|
||||
# # 遍历从起始月到结束月的所有月份
|
||||
# current_month = start_month
|
||||
# while current_month <= end_month:
|
||||
# due_month = current_month.strftime('%Y-%m')
|
||||
# # 为每个租金行添加当前月份的记录(去重)
|
||||
# for line in self.reconciliation_line_ids:
|
||||
# if line.collection_type == 'rent':
|
||||
# unique_key = (
|
||||
# line.contract_id.id if line.contract_id else None,
|
||||
# due_month
|
||||
# )
|
||||
# if unique_key not in temp_rent_set:
|
||||
# temp_rent_set.add(unique_key)
|
||||
# target_rent_months.append({
|
||||
# 'contract_id': line.contract_id,
|
||||
# 'due_month': due_month
|
||||
# })
|
||||
# # 移动到下个月
|
||||
# if current_month.month == 12:
|
||||
# current_month = current_month.replace(year=current_month.year + 1, month=1, day=1)
|
||||
# else:
|
||||
# current_month = current_month.replace(month=current_month.month + 1, day=1)
|
||||
# else:
|
||||
# 没有符合条件的明细行时,返回空列表
|
||||
target_rent_months = []
|
||||
|
||||
if target_rent_months:
|
||||
existing_penalty_months = set()
|
||||
for line in self.reconciliation_line_ids:
|
||||
if line.collection_type == 'penalty' and line.due_date:
|
||||
penalty_month = fields.Date.from_string(line.due_date).strftime('%Y-%m')
|
||||
penalty_key = (
|
||||
line.contract_id.id if line.contract_id else None,
|
||||
penalty_month
|
||||
)
|
||||
existing_penalty_months.add(penalty_key)
|
||||
|
||||
# # 3. 补全缺失的跨月违约金(按合同+年月匹配,缺失则新增)
|
||||
# missing_penalty_lines = []
|
||||
# for rent_info in target_rent_months:
|
||||
# contract = rent_info['contract_id']
|
||||
# due_month = rent_info['due_month']
|
||||
#
|
||||
# # 构建待检查的违约金key(合同+年月)
|
||||
# check_key = (
|
||||
# contract.id if contract else None,
|
||||
# due_month
|
||||
# )
|
||||
#
|
||||
# if check_key not in existing_penalty_months:
|
||||
# year, month = map(int, due_month.split('-'))
|
||||
# first_day = datetime(year, month, 1).date()
|
||||
# penalty_days = (self.actual_date - first_day).days + 1
|
||||
#
|
||||
# # 计算补全违约金的日期范围:当月1号 ~ 当月最后1天
|
||||
# # 查找上个月的租金明细行
|
||||
# if month == 1:
|
||||
# last_month_year = year - 1
|
||||
# last_month = 12
|
||||
# else:
|
||||
# last_month_year = year
|
||||
# last_month = month - 1
|
||||
# last_month_str = f"{last_month_year}-{last_month:02d}"
|
||||
#
|
||||
# last_month_rent_line = next((
|
||||
# line for line in self.reconciliation_line_ids
|
||||
# if line.collection_type == 'rent'
|
||||
# and line.contract_id == contract
|
||||
# and line.due_date # 有到期日期
|
||||
# and fields.Date.from_string(line.due_date).strftime('%Y-%m') == last_month_str
|
||||
# ), None)
|
||||
# # 提取上个月租金的rent金额
|
||||
# last_month_rent = last_month_rent_line.rent if last_month_rent_line else 0.0
|
||||
# penalty_amount = penalty_days * round(
|
||||
# last_month_rent * float(contract.percentage_liquidated_damages.name), 2
|
||||
# ) if (contract and last_month_rent > 0) else 0.0
|
||||
#
|
||||
# if penalty_amount > 0:
|
||||
# missing_penalty_lines.append((0, 0, {
|
||||
# 'contract_id': contract.id if contract else None,
|
||||
# 'rent_month': 0,
|
||||
# 'due_date': fields.Date.to_string(first_day),
|
||||
# 'rent': penalty_amount,
|
||||
# 'amount': 0,
|
||||
# 'collection_type': 'penalty',
|
||||
# 'remake': f'违约金({fields.Date.to_string(first_day)}至{fields.Date.to_string(self.actual_date)},共{penalty_days}天',
|
||||
# }))
|
||||
#
|
||||
# # 添加缺失的违约金记录
|
||||
# if missing_penalty_lines:
|
||||
# self.write({'reconciliation_line_ids': missing_penalty_lines})
|
||||
# if target_rent_months:
|
||||
# existing_penalty_months = set()
|
||||
# for line in self.reconciliation_line_ids:
|
||||
# if line.collection_type == 'penalty' and line.due_date:
|
||||
# penalty_month = fields.Date.from_string(line.due_date).strftime('%Y-%m')
|
||||
# penalty_key = (
|
||||
# line.contract_id.id if line.contract_id else None,
|
||||
# penalty_month
|
||||
# )
|
||||
# existing_penalty_months.add(penalty_key)
|
||||
#
|
||||
# # # 3. 补全缺失的跨月违约金(按合同+年月匹配,缺失则新增)
|
||||
# # missing_penalty_lines = []
|
||||
# # for rent_info in target_rent_months:
|
||||
# # contract = rent_info['contract_id']
|
||||
# # due_month = rent_info['due_month']
|
||||
# #
|
||||
# # # 构建待检查的违约金key(合同+年月)
|
||||
# # check_key = (
|
||||
# # contract.id if contract else None,
|
||||
# # due_month
|
||||
# # )
|
||||
# #
|
||||
# # if check_key not in existing_penalty_months:
|
||||
# # year, month = map(int, due_month.split('-'))
|
||||
# # first_day = datetime(year, month, 1).date()
|
||||
# # penalty_days = (self.actual_date - first_day).days + 1
|
||||
# #
|
||||
# # # 计算补全违约金的日期范围:当月1号 ~ 当月最后1天
|
||||
# # # 查找上个月的租金明细行
|
||||
# # if month == 1:
|
||||
# # last_month_year = year - 1
|
||||
# # last_month = 12
|
||||
# # else:
|
||||
# # last_month_year = year
|
||||
# # last_month = month - 1
|
||||
# # last_month_str = f"{last_month_year}-{last_month:02d}"
|
||||
# #
|
||||
# # last_month_rent_line = next((
|
||||
# # line for line in self.reconciliation_line_ids
|
||||
# # if line.collection_type == 'rent'
|
||||
# # and line.contract_id == contract
|
||||
# # and line.due_date # 有到期日期
|
||||
# # and fields.Date.from_string(line.due_date).strftime('%Y-%m') == last_month_str
|
||||
# # ), None)
|
||||
# # # 提取上个月租金的rent金额
|
||||
# # last_month_rent = last_month_rent_line.rent if last_month_rent_line else 0.0
|
||||
# # penalty_amount = penalty_days * round(
|
||||
# # last_month_rent * float(contract.percentage_liquidated_damages.name), 2
|
||||
# # ) if (contract and last_month_rent > 0) else 0.0
|
||||
# #
|
||||
# # if penalty_amount > 0:
|
||||
# # missing_penalty_lines.append((0, 0, {
|
||||
# # 'contract_id': contract.id if contract else None,
|
||||
# # 'rent_month': 0,
|
||||
# # 'due_date': fields.Date.to_string(first_day),
|
||||
# # 'rent': penalty_amount,
|
||||
# # 'amount': 0,
|
||||
# # 'collection_type': 'penalty',
|
||||
# # 'remake': f'违约金({fields.Date.to_string(first_day)}至{fields.Date.to_string(self.actual_date)},共{penalty_days}天',
|
||||
# # }))
|
||||
# #
|
||||
# # # 添加缺失的违约金记录
|
||||
# # if missing_penalty_lines:
|
||||
# # self.write({'reconciliation_line_ids': missing_penalty_lines})
|
||||
|
||||
self.create_reconciliation_vals()
|
||||
line_types = []
|
||||
|
||||
@@ -797,6 +797,16 @@
|
||||
parent="yuthon_account_report"
|
||||
action="yuthon_account_report.information_summary_table_action"
|
||||
sequence="5"/>
|
||||
<menuitem id="financial_sheet_collection_report_menu"
|
||||
name="财务数据表报表"
|
||||
parent="yuthon_account_report"
|
||||
action="yuthon_account_report.financial_sheet_collection_action"
|
||||
sequence="10"/>
|
||||
<menuitem id="information_summary_table_report_menu"
|
||||
name="信息汇总报表"
|
||||
parent="yuthon_account_report"
|
||||
action="yuthon_account_report.financial_sheet_collection_action"
|
||||
sequence="15"/>
|
||||
<menuitem id="table_setting_menu"
|
||||
name="配置"
|
||||
parent="yuthon_account_report"
|
||||
|
||||
Reference in New Issue
Block a user