快捷预览支持指定窗口
This commit is contained in:
@@ -15,6 +15,37 @@
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<!-- Form视图 -->
|
||||
<record id="estate_property_tag_view_form01" model="ir.ui.view">
|
||||
<field name="name">estate.property.tag.form</field>
|
||||
<field name="model">estate.property.tag</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<h1>我是From01</h1>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="color"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="estate_property_tag_view_form02" model="ir.ui.view">
|
||||
<field name="name">estate.property.tag.form</field>
|
||||
<field name="model">estate.property.tag</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<h1>我是From02</h1>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="color"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<!-- 搜索视图配置 -->
|
||||
<record id="estate_property_tag_search_view" model="ir.ui.view">
|
||||
<field name="name">estate.property.tag.search</field>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<field name="name" string="房产名称" />
|
||||
<field name="expected_price" string="预期价格" />
|
||||
<field name="selling_price" string="成交价格" />
|
||||
<field name="tag_ids" widget="many2many_tags"/>
|
||||
<field name="tag_ids" widget="many2many_tags" context="{'open_form_view': 'estate.estate_property_tag_view_form02'}"/>
|
||||
<field name="bedrooms" string="卧室数" />
|
||||
<field name="living_area" string="面积(㎡)" />
|
||||
<field name="state" string="状态" />
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import models
|
||||
@@ -1,25 +1,21 @@
|
||||
{
|
||||
'name': 'Many2Many Quick Preview',
|
||||
'author': 'Odoo Hub',
|
||||
'category': 'Tools',
|
||||
'summary': 'Provides quick preview of records in many2many_tags, many2many preview many2many clickable odoo record preview many2many field preview many2many field clickable many2many tags clickable many2many_tags clickable many2many_tags preview tags preview tags clickable clickable tag quick preview odoo many2many quick view instant record preview odoo related records preview many2many smart preview preview related records odoo many2many instant access many2many detail preview many2many inline preview quick access to records odoo productivity enhancement odoo preview without opening record preview on hover odoo ui enhancement many2many relation preview clickable many2many tags many2many record access preview in tags odoo improve navigation many2many quick detail view',
|
||||
'description': """
|
||||
Many2Many Quick Preview is an Odoo app that allows users to instantly preview related records in many2many fields directly from the many2many_tags.
|
||||
This app improves navigation and productivity by providing quick access to record details without having to open them individually.
|
||||
""",
|
||||
'maintainer': 'Odoo Hub',
|
||||
'website': 'https://apps.odoo.com/apps/modules/browse?author=Odoo%20Hub',
|
||||
'version': '1.0',
|
||||
'depends': ['base', 'web'],
|
||||
'assets': {
|
||||
'web.assets_backend': [
|
||||
'many2many_quick_preview/static/src/js/many2many_tags_field.js',
|
||||
"name": "Many2Many Quick Preview",
|
||||
"author": "Odoo Hub",
|
||||
"category": "Tools",
|
||||
"summary": "Many2Many快速预览",
|
||||
"description": "Many2Many快速预览",
|
||||
"maintainer": "Odoo Hub",
|
||||
"website": "#",
|
||||
"version": "17.0.0.1",
|
||||
"depends": ["base", "web"],
|
||||
"assets": {
|
||||
"web.assets_backend": [
|
||||
"many2many_quick_preview/static/src/js/many2many_tags_field.js",
|
||||
],
|
||||
},
|
||||
'images': ['static/description/banner.png'],
|
||||
'live_test_url': 'https://youtu.be/dNF106wVNX0',
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'auto_install': False,
|
||||
'license': 'LGPL-3',
|
||||
"images": ["static/description/banner.png"],
|
||||
"installable": True,
|
||||
"application": True,
|
||||
"auto_install": False,
|
||||
"license": "LGPL-3",
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from . import ir_ui_view
|
||||
@@ -0,0 +1,17 @@
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class IrUiView(models.Model):
|
||||
_inherit = "ir.ui.view"
|
||||
|
||||
@api.model
|
||||
def get_view_id_from_xmlid(self, xmlid):
|
||||
"""根据 xmlid 返回 ir.ui.view 的 id"""
|
||||
if not xmlid or "." not in xmlid:
|
||||
return False
|
||||
try:
|
||||
record = self.env.ref(xmlid)
|
||||
return record.id if record and record._name == "ir.ui.view" else False
|
||||
except ValueError:
|
||||
# xmlid 不存在时 env.ref 会抛异常
|
||||
return False
|
||||
@@ -28,17 +28,30 @@ patch(Many2ManyTagsField.prototype, {
|
||||
return props;
|
||||
},
|
||||
|
||||
onTagClick(ev, record) {
|
||||
async onTagClick(ev, record) {
|
||||
// 阻止默认的标签点击行为
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
const context = record.evalContext?.context || {};
|
||||
let viewId = false;
|
||||
if (context.open_form_view) {
|
||||
try {
|
||||
viewId = await this.orm.call(
|
||||
"ir.ui.view",
|
||||
"get_view_id_from_xmlid",
|
||||
[context.open_form_view]
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("获取指定 XML ID 的视图 ID 失败:", context.open_form_view, error);
|
||||
}
|
||||
}
|
||||
// 执行自定义动作
|
||||
this.env.services.action.doAction({
|
||||
type: "ir.actions.act_window",
|
||||
name: record?.data?.display_name,
|
||||
res_model: this.relation,
|
||||
res_id: record.resId,
|
||||
views: [[false, "form"]],
|
||||
views: [[viewId, "form"]],
|
||||
target: "new",
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user