Merge branch 'master' into dev_zhou
# Conflicts: # yuthon_base/views/ir_ui_menu_views.xml
This commit is contained in:
@@ -468,6 +468,12 @@
|
||||
.logo {
|
||||
background: #fff;
|
||||
}
|
||||
#company_logo {
|
||||
display: none;
|
||||
}
|
||||
#company_name_logo {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
/* =============== topbar ================= */
|
||||
nav.o_main_navbar {
|
||||
|
||||
@@ -39,6 +39,7 @@ patch(FormController.prototype, {
|
||||
});
|
||||
// 监听resId变化
|
||||
useEffect(() => {
|
||||
console.log("[editButtonState] useEffect 触发, resId:", this.model?.root?.resId);
|
||||
this.editButtonState();
|
||||
}, () => [this.model?.root?.resId]);
|
||||
// end edit
|
||||
@@ -94,37 +95,40 @@ patch(FormController.prototype, {
|
||||
async editButtonState() {
|
||||
this.buttonState.showEditButton = true;
|
||||
try {
|
||||
console.log("[editButtonState] === 开始检查 ===");
|
||||
console.log("[editButtonState] isAdmin (session.is_system):", this.isAdmin);
|
||||
|
||||
if (this.isAdmin) {
|
||||
console.log("[editButtonState] 管理员,直接显示编辑按钮");
|
||||
this.buttonState.showEditButton = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const resModel = this.model.config.resModel || this.model.root.resModel || this.props.resModel;
|
||||
const resId = this.model.config.resId || this.model.root.resId || this.props.resId;
|
||||
const currentUserId = this.env.services.user.userId;
|
||||
console.log("[editButtonState] resModel:", resModel, "| resId:", resId, "| currentUserId:", currentUserId, "(session.uid:", session.uid, ")");
|
||||
|
||||
if (resModel && resId) {
|
||||
// 1. 判断 self_users_ids(经办人)— 不依赖 view fields,直接 ORM 读取
|
||||
// 因为 self_users_ids 可能不在表单视图里渲染,fields 元数据会缺失
|
||||
// 1. 判断 self_users_ids(经办人)— 调用模型方法,避免触发 mixin 里 read() 的日志副作用
|
||||
try {
|
||||
const result = await this.orm.read(resModel, [resId], ["self_users_ids", "work_end"]);
|
||||
const selfUsers = result[0]?.self_users_ids || [];
|
||||
// 经办人列表有值时,当前用户不在里面就隐藏编辑按钮
|
||||
if (selfUsers.length > 0 && !selfUsers.includes(currentUserId)) {
|
||||
this.buttonState.showEditButton = false;
|
||||
return;
|
||||
}
|
||||
// 2. work_end 判断(同一次 ORM 读取,减少请求)
|
||||
if (result[0]?.work_end === true) {
|
||||
const state = await this.orm.call(resModel, "get_edit_button_state", [[resId]]);
|
||||
console.log("[editButtonState] get_edit_button_state 返回:", JSON.stringify(state));
|
||||
if (state && state.show_edit === false) {
|
||||
console.log("[editButtonState] ❌ 不是经办人或流程已结束,隐藏编辑按钮");
|
||||
this.buttonState.showEditButton = false;
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
// 模型没有 self_users_ids / work_end 字段,跳过检查,正常显示编辑按钮
|
||||
console.log("[editButtonState] get_edit_button_state 调用失败(模型可能没有该方法):", e?.message || e);
|
||||
}
|
||||
// 3. 以上条件都不满足,显示编辑按钮
|
||||
console.log("[editButtonState] ✅ 显示编辑按钮");
|
||||
this.buttonState.showEditButton = true;
|
||||
} else {
|
||||
console.log("[editButtonState] resModel 或 resId 为空,跳过检查,显示编辑按钮");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("检查编辑按钮状态:", error);
|
||||
console.error("[editButtonState] 检查编辑按钮状态出错:", error);
|
||||
this.buttonState.showEditButton = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,29 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
target_logs.write({'approval_state': '1'})
|
||||
return super(SoongWorkflowMixin, self).read(fields=fields, load=load)
|
||||
|
||||
def get_edit_button_state(self):
|
||||
"""供前端判断编辑按钮是否显示,避免触发 read() 重写里的日志副作用。"""
|
||||
self.ensure_one()
|
||||
# 没有 self_users_ids / work_end 字段的模型不做限制
|
||||
if not hasattr(self, 'self_users_ids') or not hasattr(self, 'work_end'):
|
||||
return {'show_edit': True}
|
||||
is_current_user = self.env.user.id in self.self_users_ids.ids
|
||||
# is_modify=True 且当前用户是流程创建人时也允许编辑
|
||||
is_modify_creator = False
|
||||
if hasattr(self, 'is_modify') and self.is_modify:
|
||||
workflow_record = self.env["soong.workflow.record"].search(
|
||||
[("res_model", "=", self._name), ("res_id", "=", self.id), ('reclaim_state', '=', False)], limit=1)
|
||||
if workflow_record and workflow_record.create_uid.id == self.env.user.id:
|
||||
is_modify_creator = True
|
||||
show_edit = (is_current_user and not self.work_end) or is_modify_creator
|
||||
return {
|
||||
'show_edit': show_edit,
|
||||
'self_users_ids': self.self_users_ids.ids,
|
||||
'work_end': self.work_end,
|
||||
'is_modify': hasattr(self, 'is_modify') and self.is_modify,
|
||||
'is_modify_creator': is_modify_creator,
|
||||
}
|
||||
|
||||
# @api.model
|
||||
# def write(self, vals):
|
||||
# res = super(SoongWorkflowMixin, self).write(vals)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<!-- 注释掉:继承 base.ir_cron_view_tree 的 xpath 不匹配,导致升级报错
|
||||
<record id="inherit_act_view_ir_cron_tree" model="ir.ui.view">
|
||||
<field name="name">ir.cron.tree.inherit</field>
|
||||
<field name="model">ir.cron</field>
|
||||
@@ -11,6 +12,8 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
-->
|
||||
<!-- 注释掉:继承 base.ir_cron_view_form 的 xpath 不匹配
|
||||
<record id="inherit_act_view_ir_cron_form" model="ir.ui.view">
|
||||
<field name="name">ir.cron.form.inherit</field>
|
||||
<field name="model">ir.cron</field>
|
||||
@@ -22,6 +25,7 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
-->
|
||||
<record id="ir_cron_type_tree" model="ir.ui.view">
|
||||
<field name="name">ir.cron.type.tree</field>
|
||||
<field name="model">ir.cron.type</field>
|
||||
|
||||
Reference in New Issue
Block a user