!2828 添加功能

Merge pull request !2828 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2025-05-22 13:19:34 +00:00
committed by Gitee
16 changed files with 336 additions and 44 deletions
+3 -3
View File
@@ -27,7 +27,7 @@ class GoApprovals(models.Model):
details = fields.Text(string="外出说明", default="1.可通过填写天数和小时,直接获得结束时间\n 2.一份外出单,可同时选择多人一次审批")
related_issues_id = fields.Many2one('issue.library', string="关联议题")
date_start = fields.Datetime(string="开始时间", default=fields.Datetime.now)
date_end = fields.Datetime(string="结束时间")
date_end = fields.Datetime(string="结束时间", default=fields.Datetime.now)
meal = fields.Selection([('yes', '是'), ('no', '否')], string="误餐费", default=None)
days = fields.Integer(string="天数")
hours = fields.Integer(string="小时")
@@ -39,8 +39,8 @@ class GoApprovals(models.Model):
is_hour = fields.Boolean(string="按小时")
start_day_selection = fields.Selection([('half', '上半天'),('afternoon', '下半天')], string="天")
end_day_selection = fields.Selection([('half', '上半天'), ('afternoon', '下半天')], string="天")
statr_date = fields.Date(string="开始日期")
end_date = fields.Date(string="结束日期")
statr_date = fields.Date(string="开始日期", default=fields.Date.today)
end_date = fields.Date(string="结束日期", default=fields.Date.today)
def _get_default_name_title(self):
return self._description if self._description else self._name
+57 -1
View File
@@ -230,8 +230,59 @@ class YuthonProperty(models.Model):
self._context.get('active_ids', self._context.get('active_id')))
form_id = self.env.ref('yuthon_property_approval.view_property_management_form').id
property_list = []
today = fields.Date.today()
first_record = property_ids[0]
# 获取第一条记录的有效purpose_id
valid_manage = first_record.manage_information_ids.filtered(
lambda m: m.start_time and m.start_time <= today and
(not m.end_date or m.end_date >= today)
)
if not valid_manage:
raise UserError(f"{first_record.name}该物业没有找到有效的管理信息!")
reference_purpose_id = valid_manage[0].purpose_id.id
# 参考值集合(tenure_type, company_id, admin_id, precinct_id, purpose_id)
reference_values = (
first_record.tenure_type,
first_record.company_id.id,
first_record.admin_id.id,
first_record.precinct_id.id,
reference_purpose_id
)
# 检查所有记录的属性是否与第一条记录一致
for record in property_ids[1:]:
# 获取当前记录的有效purpose_id
current_valid_manage = record.manage_information_ids.filtered(
lambda m: m.start_time and m.start_time <= today and
(not m.end_date or m.end_date >= today)
)
if not current_valid_manage:
raise UserError(f"{first_record.name}该物业没有找到有效的管理信息!")
current_purpose_id = current_valid_manage[0].purpose_id.id
# 当前记录的值集合
current_values = (
record.tenure_type,
record.company_id.id,
record.admin_id.id,
record.precinct_id.id,
current_purpose_id
)
# 如果有任何属性不一致,抛出统一错误
if current_values != reference_values:
raise UserError("所选记录的公司、管理类型、权属类型、管理员和所属片区必须完全一样!")
for record in property_ids:
property_list.append([0, 0, {'property_id': record.id}])
for manage in record.manage_information_ids:
# 判断记录是否有效:start_time ≤ today ≤ end_date(或end_date为空)
if manage.start_time and manage.start_time <= today:
if not manage.end_date or manage.end_date >= today:
manage_id = manage
else:
manage_id = False
else:
manage_id = False
property_list.append([0, 0, {'property_id': record.id,
'information_line_id': manage_id.id}])
return {
'name': '提交物业变更',
'view_mode': 'form',
@@ -239,6 +290,11 @@ class YuthonProperty(models.Model):
'type': 'ir.actions.act_window',
'views': [(form_id, 'form')],
"context": {
'default_company_id': first_record.company_id.id,
'default_purpose_id': reference_purpose_id,
'default_admin_id_all': first_record.admin_id.id,
'default_precinct_id': first_record.precinct_id.id,
'default_tenure_type': first_record.tenure_type,
'default_management_line2_ids': property_list
}
}
@@ -18,7 +18,6 @@ class PropertyManagement(models.Model):
department_id = fields.Many2one('hr.department', related='user_id.employee_id.department_id',string="申请人部门")
handling_opinions = fields.Text(string="经办意见")
management_line2_ids = fields.One2many('property.management.line2', 'property_management_id', string="原物业信息")
new_property_ids = fields.One2many('property.information.detail.lines', 'new_property_id', string="新物业信息")
management_line_ids = fields.One2many('property.management.line', 'property_management_id', string="物业信息")
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
default='normal')
@@ -29,6 +28,12 @@ class PropertyManagement(models.Model):
active = fields.Boolean('Active', default=True, tracking=True)
work_end = fields.Boolean(string="结束")
company_id = fields.Many2one('yuthon.property.company', string="公司")
purpose_id = fields.Many2one('yuthon.resource.purpose', string="管理类型")
admin_id_all = fields.Many2one('res.users', string="管理员")
precinct_id = fields.Many2one('yuthon.precinct.message', string="所属片区")
tenure_type = fields.Selection([('self', '自有'), ('agency', '代管')], string='权属类型')
def _get_default_name_title(self):
return self._description if self._description else self._name
@@ -53,7 +58,6 @@ class PropertyManagement(models.Model):
@api.onchange('management_line2_ids')
def _onchange_management_line2_ids(self):
self.management_line_ids = [(5, 0, 0)]
self.new_property_ids = [(5, 0, 0)]
for line in self.management_line2_ids:
if line.property_id:
self.management_line_ids = [(0, 0, {
@@ -64,33 +68,29 @@ class PropertyManagement(models.Model):
'admin_id_all': line.admin_id_all.id,
'tenure_type': line.tenure_type
})]
self.new_property_ids = [(0, 0, {
'property_id': line.property_id.id,
})]
def approval_end(self):
for record in self:
for line in record.new_property_ids:
for line in record.management_line2_ids:
line.property_id.write({
'company_id': line.company_id.id,
'purpose_id': line.purpose_id.id,
'precinct_id': line.precincts_id.id,
'admin_id': line.admin_id_all.id,
'tenure_type': line.tenure_type
'company_id': record.company_id.id,
'precinct_id': record.precinct_id.id,
'admin_id': record.admin_id_all.id,
'tenure_type': record.tenure_type
})
record.write({'is_line': True})
class PropertyInformationDetailLines(models.Model):
_name = 'property.information.detail.lines'
_description = '新物业信息'
new_property_id = fields.Many2one('property.management', string="关联物业分配申请表")
property_id = fields.Many2one('yuthon.property', string="物业名称")
company_id = fields.Many2one('yuthon.property.company', string="公司")
purpose_id = fields.Many2one('yuthon.resource.purpose', string="管理类型")
admin_id_all = fields.Many2one('res.users', string="管理员")
precincts_id = fields.Many2one('yuthon.precinct.message', string="新片区")
tenure_type = fields.Selection([('self', '自有'), ('agency', '代管')], string='权属类型')
line.information_line_id.write({'end_date': fields.Date.today()})
self.env['manage.information.line'].create({
'yuthon_property_id': line.property_id.id,
'purpose_id' : record.purpose_id.id,
'precinct_id': record.precinct_id.id,
'tenure_type': record.tenure_type,
'management_area': line.information_line_id.management_area,
'rent_area': line.information_line_id.rent_area,
'admin_id' : record.admin_id_all.id,
'company_id': record.company_id.id,
'start_time': fields.Date.today(),
})
record.write({'is_line': True})
# 结果保留明细行
class PropertyManagementLine(models.Model):
@@ -99,6 +99,7 @@ class PropertyManagementLine(models.Model):
property_id = fields.Many2one('yuthon.property', string="物业名称")
property_management_id = fields.Many2one('property.management', string="关联物业分配申请表")
information_line_id = fields.Many2one('manage.information.line')
company_id = fields.Many2one('yuthon.property.company', string="公司")
purpose_id = fields.Many2one('yuthon.resource.purpose', string="管理类型")
admin_id_all = fields.Many2one('res.users', string="管理员")
@@ -113,9 +114,12 @@ class PropertyManagementLine2(models.Model):
property_management_id = fields.Many2one('property.management', string="关联物业分配申请表")
property_id = fields.Many2one('yuthon.property', string="物业名称")
purpose_id = fields.Many2one('yuthon.resource.purpose', string="管理类型")
information_line_id = fields.Many2one('manage.information.line')
tenure_type = fields.Selection(related='property_id.tenure_type', string='权属类型')
company_id = fields.Many2one(related='property_id.company_id', string="公司")
admin_id_all = fields.Many2one(related='property_id.admin_id', string="管理员")
precinct_id = fields.Many2one(related='property_id.precinct_id', string="所属片区")
class PropertyInformationDetailLines(models.Model):
_name = 'property.information.detail.lines'
@@ -24,7 +24,6 @@ access_property_confirm,property_confirm,model_property_confirm,base.group_user,
access_property_move,property_move,model_property_move,base.group_user,1,1,1,1
access_property_record,property_record,model_property_record,base.group_user,1,1,1,1
access_property_equity,property_equity,model_property_equity,base.group_user,1,1,1,1
access_property_information_detail_lines,property_information_detail_lines,model_property_information_detail_lines,base.group_user,1,1,1,1
access_property_lease_contract_line,property_lease_contract_line,model_property_lease_contract_line,base.group_user,1,1,1,1
access_property_rent_breakdown_line,property_rent_breakdown_line,model_property_rent_breakdown_line,base.group_user,1,1,1,1
access_property_water_fee_line,property_water_fee_line,model_property_water_fee_line,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
24 access_property_move property_move model_property_move base.group_user 1 1 1 1
25 access_property_record property_record model_property_record base.group_user 1 1 1 1
26 access_property_equity property_equity model_property_equity base.group_user 1 1 1 1
access_property_information_detail_lines property_information_detail_lines model_property_information_detail_lines base.group_user 1 1 1 1
27 access_property_lease_contract_line property_lease_contract_line model_property_lease_contract_line base.group_user 1 1 1 1
28 access_property_rent_breakdown_line property_rent_breakdown_line model_property_rent_breakdown_line base.group_user 1 1 1 1
29 access_property_water_fee_line property_water_fee_line model_property_water_fee_line base.group_user 1 1 1 1
@@ -71,6 +71,7 @@
<field name="admin_id_all"/>
<field name="precinct_id"/>
<field name="purpose_id"/>
<field name="information_line_id"/>
</tree>
</field>
</group>
@@ -84,21 +85,26 @@
<field name="admin_id_all"/>
<field name="precinct_id"/>
<field name="purpose_id"/>
<field name="information_line_id"/>
</tree>
</field>
</group>
<group string="新管理信息">
<field name="new_property_ids" string=" ">
<tree editable="bottom">
<field name="new_property_id" column_invisible="1"/>
<field name="property_id"/>
<field name="company_id" required="1"/>
<field name="tenure_type"/>
<field name="admin_id_all"/>
<field name="precincts_id"/>
<field name="purpose_id"/>
</tree>
</field>
<group col="5">
<group>
<field name="company_id"/>
</group>
<group>
<field name="tenure_type"/>
</group>
<group>
<field name="admin_id_all"/>
</group>
<group>
<field name="precinct_id"/>
</group>
<group>
<field name="purpose_id"/>
</group>
</group>
</sheet>
</form>
+2 -1
View File
@@ -28,6 +28,7 @@
'views/yuthon_none_views.xml',
'views/yuthon_mutual_approval_views.xml',
'views/yuthon_care_condolences_views.xml',
'views/trade_project_approval_views.xml',
'views/yuthon_trade_setting_views.xml',
'views/yuthon_work_condolences_views.xml',
'views/yuthon_task_approval_views.xml',
@@ -36,7 +37,7 @@
'views/yuthon_trade_menu.xml',
],
'demo': [],
'depends': ['mail', 'documents', 'soong_workflow', 'yuthon_work_brand', 'hr', 'yuthon_hr_employee', 'yuthon_issue'],
'depends': ['mail', 'documents', 'soong_workflow', 'yuthon_work_brand', 'hr', 'yuthon_hr_employee', 'yuthon_issue', 'project'],
'installable': True,
'application': True,
}
@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="trade_project_approval_code_sequence" model="ir.sequence">
<field name="name">立项申请编号</field>
<field name="code">trade_project_approval_code</field>
<field name="prefix">LX%(y)s%(month)s%(day)s</field>
<field name="padding">3</field>
<field name="company_id" eval="False"/>
</record>
<record id="property_work_condolences_code_sequence" model="ir.sequence">
<field name="name">节日慰问编号</field>
<field name="code">property_work_condolences_code</field>
+1
View File
@@ -23,3 +23,4 @@ from . import trade_reward_approval
from . import yuthon_seals_approval
from . import yuthon_business_approval
from . import inherit_workflow_record
from . import trade_project_approval
@@ -0,0 +1,52 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, fields, api, exceptions, _
class TradeProjectApproval(models.Model):
_name = 'trade.project.approval'
_description = '立项申请'
_inherit = ['soong.workflow.mixin', 'mail.thread.main.attachment', 'mail.activity.mixin']
code = fields.Char(string="流水号",
default=lambda self: self.env['ir.sequence'].next_by_code('trade_project_approval_code'))
users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
department_id = fields.Many2one(related='users_id.employee_id.department_id', string="申请部门")
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
default='normal')
date_application = fields.Date(string="申请日期")
text = fields.Text(string='正文')
name = fields.Char(string="项目名称")
project_classify_id = fields.Many2one('project.classify.setting', string="项目分类")
start_date = fields.Date(string="计划开始")
end_date = fields.Date(string="计划完成")
plan_duration = fields.Integer(string="计划工期")
funding_id = fields.Many2one('project.funding.setting', string="资金来源")
employee_id = fields.Many2one('hr.employee', string="分管领导")
project_invest = fields.Float(string="项目总投资")
projected_earnings = fields.Float(string="预计投资收益")
project_content = fields.Text(string="项目概括")
project_goal = fields.Text(string="项目目标")
expected_results = fields.Text(string="预期成果")
document_ids = fields.Many2many('ir.attachment', string="立项文件")
work_end = fields.Boolean(string="结束")
active = fields.Boolean('Active', default=True, tracking=True)
def _get_default_name_title(self):
return self._description if self._description else self._name
name_title = fields.Char(default=_get_default_name_title)
# 项目归属
project_belong_id = fields.Many2one('res.users', string="项目负责人")
project_department_id = fields.Many2one('hr.department', string="项目部门")
def approval_end(self):
for rec in self:
self.env['project.project'].create({
'name' : rec.name,
'user_id' : rec.project_belong_id.id,
'company_id': rec.user_id.employee_id.company_id.id,
})
+1 -1
View File
@@ -1,7 +1,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, fields, api, exceptions, _
class TradeRewardApproval(models.Model):
_name = 'trade.reward.approval'
_description = '奖励申报呈批表'
@@ -14,20 +14,37 @@ class YuthonWorkSetting(models.Model):
name = fields.Char(string='名称')
class SealsTypeSetting(models.Model):
_name = 'seals.type.setting'
_description = '用章类型'
name = fields.Char(string='名称')
class SealsScopeSetting(models.Model):
_name = 'seals.scope.setting'
_description = '用章范围'
name = fields.Char(string='名称')
class SendingUnitSetting(models.Model):
_name = 'sending.unit.setting'
_description = '发送单位'
name = fields.Char(string='名称')
class ProjectClassifySetting(models.Model):
_name = 'project.classify.setting'
_description = '项目分类'
name = fields.Char(string='名称')
class ProjectFundingSetting(models.Model):
_name = 'project.funding.setting'
_description = '资金来源'
name = fields.Char(string='名称')
@@ -31,6 +31,9 @@ access_yuthon_reward_line,yuthon_reward_line,model_yuthon_reward_line,base.group
access_seals_type_setting,seals_type_setting,model_seals_type_setting,base.group_user,1,1,1,1
access_seals_scope_setting,seals_scope_setting,model_seals_scope_setting,base.group_user,1,1,1,1
access_sending_unit_setting,sending_unit_setting,model_sending_unit_setting,base.group_user,1,1,1,1
access_trade_project_approval,trade_project_approval,model_trade_project_approval,base.group_user,1,1,1,1
access_project_funding_setting,project_funding_setting,model_project_funding_setting,base.group_user,1,1,1,1
access_project_classify_setting,project_classify_setting,model_project_classify_setting,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
31 access_seals_scope_setting seals_scope_setting model_seals_scope_setting base.group_user 1 1 1 1
32 access_sending_unit_setting sending_unit_setting model_sending_unit_setting base.group_user 1 1 1 1
33 access_trade_project_approval trade_project_approval model_trade_project_approval base.group_user 1 1 1 1
34 access_project_funding_setting project_funding_setting model_project_funding_setting base.group_user 1 1 1 1
35 access_project_classify_setting project_classify_setting model_project_classify_setting base.group_user 1 1 1 1
36
37
38
39
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_trade_project_approval_tree" model="ir.ui.view">
<field name="name">trade.project.approval.tree</field>
<field name="model">trade.project.approval</field>
<field name="arch" type="xml">
<tree string="立项申请">
<field name="name"/>
<field name="users_id"/>
<field name="project_classify_id"/>
<field name="date_application"/>
</tree>
</field>
</record>
<record id="view_trade_project_approval_form" model="ir.ui.view">
<field name="name">trade.project.approval.form</field>
<field name="model">trade.project.approval</field>
<field name="arch" type="xml">
<form string="立项申请">
<sheet>
<widget name="web_ribbon" title="普件" bg_color="text-bg-success"
invisible="urgency_level != 'normal'"/>
<widget name="web_ribbon" title="急件" bg_color="text-bg-warning"
invisible="urgency_level != 'urgent'"/>
<widget name="web_ribbon" title="特级" bg_color="text-bg-danger"
invisible="urgency_level != 'emergency'"/>
<group col="2">
<group>
<field name="code" string="流水号" readonly="1"/>
</group>
<group>
<field name="urgency_level" readonly="1"/>
</group>
<group/>
</group>
<div class="col-12 text-center">
<h1>
<field name="name_title" readonly="1"/>
</h1>
</div>
<group col="3" string="经办信息">
<group>
<field name="users_id" string="申请人"/>
</group>
<group>
<field name="department_id"/>
</group>
<group>
<field name="date_application"/>
</group>
</group>
<group string="项目信息">
<field name="name"/>
</group>
<group col="4">
<group>
<field name="project_classify_id"/>
</group>
<group>
<field name="start_date"/>
</group>
<group>
<field name="end_date"/>
</group>
<group>
<field name="plan_duration"/>
</group>
</group>
<group col="3">
<group>
<field name="funding_id"/>
</group>
<group>
<field name="project_invest"/>
</group>
<group>
<field name="projected_earnings"/>
</group>
</group>
<group>
<field name="employee_id"/>
<field name="project_content"/>
<field name="project_goal"/>
<field name="expected_results"/>
</group>
<group string="项目归属">
<field name="project_belong_id"/>
<field name="project_department_id"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="trade_project_approval_action" model="ir.actions.act_window">
<field name="name">立项申请</field>
<field name="res_model">trade.project.approval</field>
<field name="view_mode">tree,form</field>
</record>
</odoo>
+16
View File
@@ -108,6 +108,12 @@
parent="executive_trade_process_ment"
action="view_business_approval_action"
sequence="80"/>
<menuitem id="trade_project_approval_board"
name="立项申请"
parent="executive_trade_process_ment"
action="trade_project_approval_action"
sequence="90"/>
<menuitem id="executive_trade_setting"
name="配置"
parent="executive_manage_approval"
@@ -152,4 +158,14 @@
parent="executive_trade_setting"
action="view_sending_unit_setting_action"
sequence="70"/>
<menuitem id="project_classify_setting_board"
name="项目分类"
parent="executive_trade_setting"
action="view_project_classify_setting_action"
sequence="80"/>
<menuitem id="project_funding_setting_board"
name="资金来源"
parent="executive_trade_setting"
action="view_project_funding_setting_action"
sequence="90"/>
</odoo>
@@ -70,4 +70,32 @@
<field name="res_model">sending.unit.setting</field>
<field name="view_mode">tree</field>
</record>
<record id="view_project_classify_setting_tree" model="ir.ui.view">
<field name="name">项目分类</field>
<field name="model">project.classify.setting</field>
<field name="arch" type="xml">
<tree string="项目分类" editable="bottom">
<field name="name"/>
</tree>
</field>
</record>
<record id="view_project_classify_setting_action" model="ir.actions.act_window">
<field name="name">项目分类</field>
<field name="res_model">project.classify.setting</field>
<field name="view_mode">tree</field>
</record>
<record id="view_project_funding_setting_tree" model="ir.ui.view">
<field name="name">资金来源</field>
<field name="model">project.funding.setting</field>
<field name="arch" type="xml">
<tree string="资金来源" editable="bottom">
<field name="name"/>
</tree>
</field>
</record>
<record id="view_project_funding_setting_action" model="ir.actions.act_window">
<field name="name">资金来源</field>
<field name="res_model">project.funding.setting</field>
<field name="view_mode">tree</field>
</record>
</odoo>
@@ -3,7 +3,6 @@
<menuitem id="executive_manage_menu_root_board"
name="行政管理"
web_icon="yuthon_work_brand,static/description/manage.png"
active="False"
sequence="80"/>
<menuitem id="executive_manage_union_root_board"