Merge branch 'refs/heads/dev' into dev_zhou

# Conflicts:
#	yuthon_holiday/views/inherit_hr_leave_allocation_views.xml
This commit is contained in:
zhouzhou
2024-11-10 20:32:47 +08:00
6 changed files with 74 additions and 109 deletions
+27 -17
View File
@@ -179,9 +179,33 @@ class SoongWorkflowMixin(models.AbstractModel):
state_list = ['拟办' if i.node_name == 'start' else i.node_name for i in btn_rec.workflow_id.node_ids]
# 当前节点状态
self_state = state_list.index('拟办' if self.state == 'start' else self.state)
self.env['trans.link'].search([]).unlink()
if btn_rec.name == '退回':
for state in state_list[0:self_state]:
self.env['trans.link'].create({
'node_button_id': btn_rec.id,
'name': state,
'link_type': 'return',
'record_id': self.id,
})
return {
"name": _("评论"),
"type": "ir.actions.act_window",
"view_mode": "form",
"res_model": "soong.workflow.comment.wizard",
"views": [(wizard.id, "form")],
"view_id": wizard.id,
"target": "new",
"context": {
"default_res_id": self.id,
"default_res_model": self._name,
"default_log_ids": logs.ids,
"default_node_btn_id": btn_rec.id,
"default_node_link_len": '转交2' if len(btn_rec.node_id.out_link_ids) > 1 and btn_rec.name == '转交' else '',
},
}
# 下一个节点
next_state = btn_rec.workflow_id.node_ids[self_state + 1].button_ids[1]
self.env['trans.link'].search([]).unlink()
if btn_rec.name == '转交' and len(btn_rec.node_id.out_link_ids) > 1:
for state in btn_rec.node_id.out_link_ids:
self.env['trans.link'].create({
@@ -190,14 +214,6 @@ class SoongWorkflowMixin(models.AbstractModel):
'link_type': 'trans',
'record_id': self.id,
})
elif btn_rec.name == '退回':
for state in state_list[0:self_state]:
self.env['trans.link'].create({
'node_button_id': btn_rec.id,
'name': state,
'link_type': 'return',
'record_id': self.id,
})
# 不自动匹配
employee_user_role_ids = self.env['hr.employee'].search([('user_role_id', '=', next_state.users_role_id.id)])
# 自动匹配
@@ -272,14 +288,6 @@ class SoongWorkflowMixin(models.AbstractModel):
"views": [(False, "diagram_plus")],
}
# @api.model
# def _get_view(self, view_id=None, view_type='form', **options):
# """ Set the correct label for `unit_amount`, depending on company UoM """
# arch, view = super()._get_view(view_id, view_type, **options)
# for node in arch.xpath("//header"):
# node.append(etree.XML("""<span>booooooo</span>"""))
# return arch, view
@api.model
def get_view(self, view_id=None, view_type="form", **options):
res = super().get_view(view_id, view_type, **options)
@@ -302,6 +310,8 @@ class SoongWorkflowMixin(models.AbstractModel):
# 收回
def action_withdraw(self):
for record in self:
if self.state == 'start':
raise UserError('当前节点不允许收回')
employee_id = self.env['hr.employee']
state_list = []
for state in record.workflow_id.node_ids:
@@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models, api
from odoo.exceptions import UserError, ValidationError
class SoongWorkflowCommentWizard(models.TransientModel):
_name = "soong.workflow.comment.wizard"
@@ -66,6 +66,27 @@ class SoongWorkflowCommentWizard(models.TransientModel):
record_id = self.env[self.res_model].search([('id', '=', self.res_id)])
self.record_id = record_id
@api.onchange('return_link_id')
def onchange_employee_ids(self):
record_id = self.env[self.res_model].search([('id', '=', self.res_id)])
for ret in self.return_link_id:
if ret.name == '拟办':
self.employee_ids = record_id.user_id.employee_id
elif self.node_btn_name == '退回':
workflow_id = self.return_link_id.node_button_id.workflow_id
state_list = ['拟办' if i.node_name == 'start' else i.node_name for i in workflow_id.node_ids]
self_state = state_list.index(ret.name)
button_id = workflow_id.node_ids[self_state].button_ids[1]
if button_id.name != '转交':
raise UserError('配置错误,请配置当前{}的转交按钮'.format(self_state))
if button_id.is_automatic:
employee_user_role_ids = self.env['hr.employee'].search([('user_role_id', '=', button_id.users_role_id.id)])
employee_user_role_id = self.env['hr.employee'].search(
[('user_role_id', '=', button_id.users_role_id.id),
('department_id', '=', record_id.department_id.id)])
self.employee_ids = employee_user_role_ids if not button_id.is_automatic else employee_user_role_id
def add_comment(self):
self.ensure_one()
cx = self.env.context.copy() or {}
@@ -29,7 +29,7 @@
<field name="comment_note_id" invisible="node_btn_name != '分发'" string="督办意见" domain="[('type','=','super')]"/>
<field name="department_ids" invisible="node_btn_name not in ['加签', '分发']" widget="many2many_tags"/>
<field name="comment_note_id" invisible="node_btn_name != '加签确认'" string="加签意见"/>
<field name="employee_ids" widget="many2many_tags" invisible="node_btn_name in ['退回', '加签确认']"/>
<field name="employee_ids" widget="many2many_tags" invisible="node_btn_name in ['加签确认']" readonly="1"/>
<field name="users_role_ids" invisible="node_btn_name not in ['加签', '分发']" widget="many2many_tags"/>
<field name="approval_users_ids" invisible="node_btn_name != '分发'" widget="many2many_tags"/>
<field name="approval_users_ids" string='加签人员' invisible="node_btn_name != '加签'" widget="many2many_tags"/>
@@ -22,6 +22,23 @@
<attribute name="string">结束时间</attribute>
<attribute name="optional">show</attribute>
</xpath>
<xpath expr="//tree" position="attributes">
<attribute name="editable">bottom</attribute>
</xpath>
<xpath expr="//tree/field[@name='duration_display']" position="attributes">
<attribute name="string">假期余额</attribute>
</xpath>
<xpath expr="//tree/field[@name='holiday_status_id']" position="attributes">
<attribute name="optional">hide</attribute>
</xpath>
<xpath expr="//tree/field[@name='date_from']" position="attributes">
<attribute name="string">开始时间</attribute>
<attribute name="optional">show</attribute>
</xpath>
<xpath expr="//tree/field[@name='date_to']" position="attributes">
<attribute name="string">结束时间</attribute>
<attribute name="optional">show</attribute>
</xpath>
</field>
</record>
+7 -7
View File
@@ -32,18 +32,18 @@ class WeComApps(models.Model):
self.access_token = access_token
return access_token
def sync_function_api(self, apps_type, api_function, data):
response = self.sync_function_api_base(apps_type, api_function, data)
def sync_function_api(self, apps_type, api_function, data, category="default"):
response = self.sync_function_api_base(apps_type, api_function, data, category)
result_data = json.loads(response.content)
return result_data
def sync_function_api_base(self, apps_type, api_function, data):
wecom_app = self.sudo().env["wecom.apps.config"].search([("wecom_apps_type", "=", apps_type)], limit=1).wecom_apps_id
def sync_function_api_base(self, apps_type, api_function, data, category="default"):
wecom_app = self.sudo().env["wecom.apps.config"].search([("wecom_apps_type", "=", apps_type), ("wecom_apps_category", "=", category)], limit=1).wecom_apps_id
response = self.sudo().env['wecom.api'].function_http_request(api_function, data, wecom_app.access_token)
result_data = json.loads(response.content)
if result_data.get("errcode", 0) in [40014, 42001]:
wecom_app.sync_access_token()
wecom_app = self.sudo().env["wecom.apps.config"].search([("wecom_apps_type", "=", apps_type)],
wecom_app = self.sudo().env["wecom.apps.config"].search([("wecom_apps_type", "=", apps_type), ("wecom_apps_category", "=", category)],
limit=1).wecom_apps_id
response = self.sudo().env['wecom.api'].function_http_request(api_function, data, wecom_app.access_token)
return response
@@ -91,7 +91,7 @@ class WeComApps(models.Model):
'content': message
}
}
result_data = self.sync_function_api("message_send", "MESSAGE_SEND", data)
result_data = self.sync_function_api("message_send", "MESSAGE_SEND", data, category)
if result_data.get("errcode", None) == 0:
return True, result_data
return False, result_data
@@ -146,7 +146,7 @@ class WeComApps(models.Model):
"btntxt": btntxt
},
}
result_data = self.sync_function_api("message_send", "MESSAGE_SEND", data)
result_data = self.sync_function_api("message_send", "MESSAGE_SEND", data, category)
if result_data.get("errcode", None) == 0:
return True, result_data
return False, result_data
-83
View File
@@ -1,83 +0,0 @@
<?xml version="1.0"?>
<odoo>
<data>
<!--引用一个模型的图形视图-->
<!-- <record model="ir.actions.act_window" id="act_session_graph">-->
<!-- <field name="name">act.session.graph</field>-->
<!-- <field name="res_model">crm</field>-->
<!-- <field name="view_type">form</field>-->
<!-- <field name="view_mode">graph</field>-->
<!-- <field name="view_id"-->
<!-- ref="crm.crm_activity_report_view_graph"/>-->
<!-- </record>-->
<!--引用日历视图-->
<!-- <record model="ir.actions.act_window" id="act_session_calendar">-->
<!-- <field name="name">act.session.calendar</field>-->
<!-- <field name="res_model">calendar</field>-->
<!-- <field name="view_type">form</field>-->
<!-- <field name="view_mode">calendar</field>-->
<!-- <field name="view_id" ref="calendar.view_calendar_event_calendar"/>-->
<!-- </record>-->
<!--引用模型列表/表单视图-->
<!-- <record model="ir.actions.act_window" id="act_course_list">-->
<!-- <field name="name">Courses</field>-->
<!-- <field name="res_model">yuthon.reconcil</field>-->
<!-- <field name="view_type">form</field>-->
<!-- <field name="view_mode">tree,form</field>-->
<!-- </record>-->
<!--定义仪表板form表单-->
<record model="ir.ui.view" id="board_session_form">
<field name="name">仪表板</field>
<field name="model">board.board</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Dashboard">
<board style="2-1">
<!-- //有好几种样式:1,1-1,2-1和1-1-1,可以在odoo里面点击切换-->
<column>
<!-- //一列-->
<action
string="视图一"
name="%(yuthon_account.yuthon_reconcil_action)d"
height="150"
width="510"/>
<!-- <action-->
<!-- string="视图二"-->
<!-- name="%(act_session_calendar)d"/>-->
</column>
<column>
<!-- //第二列-->
<!-- <action-->
<!-- string="视图三"-->
<!-- name="%(act_session_graph)d"/>-->
<action
string="视图二"
name="%(act_session_calendar)d"/>
</column>
</board>
</form>
</field>
</record>
<!--定义动作打开仪表板form视图-->
<record model="ir.actions.act_window" id="open_board_session">
<field name="name">Session Dashboard</field>
<field name="res_model">board.board</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="usage">menu</field>
<field name="view_id" ref="board_session_form"/>
</record>
<!--在odoo原生仪表板菜单下,定义子菜单,把仪表板打开动作绑定到菜单项-->
<!-- <menuitem-->
<!-- name="Session Dashboard" parent="base.menu_reporting_dashboard"-->
<!-- action="open_board_session"-->
<!-- sequence="1"-->
<!-- id="menu_board_session" icon="terp-graph"/>-->
<menuitem
id="menu_board_session"
name="工作台"
parent="account.menu_finance_entries_actions"
sequence="90"
action="open_board_session"/>
</data>
</odoo>