!5278 快捷预览支持指定窗口

Merge pull request !5278 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2025-09-21 16:31:15 +00:00
committed by Gitee
12 changed files with 352 additions and 1 deletions
@@ -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>
+1 -1
View File
@@ -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="状态" />
+2
View File
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models
+21
View File
@@ -0,0 +1,21 @@
{
"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"],
"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
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

@@ -0,0 +1,221 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
</head>
<body>
<!-- App Overview Section -->
<section class="container py-5">
<div class="row justify-content-center">
<div class="col-lg-10 col-md-12 col-sm-12 text-center shadow rounded-3">
<h2 class="text-primary my-5">App Overview</h2>
<p class="bg-primary text-light rounded-3 p-4 lead">
The Many2Many Quick Preview app enhances your Odoo experience by allowing users to instantly preview
related records
from many2many fields directly within the many2many tags. This app streamlines navigation and boosts
productivity
by providing quick access to related records, eliminating the need to open them individually.
</p>
<div class="card mb-4 bg-info text-light rounded-3 overflow-hidden">
<div class="card-body px-md-5 px-2">
<h4 class="card-title text-primary text-start mb-4">Key Features:</h4>
<ul class="list-unstyled text-start">
<li class="d-flex align-items-center mb-3">
<i class="fa fa-check-circle text-primary fs-4 me-3"></i>
<span class="fs-5">Instantly preview related records in many2many fields without opening them</span>
</li>
<li class="d-flex align-items-center mb-3">
<i class="fa fa-check-circle text-primary fs-4 me-3"></i>
<span class="fs-5">Quick access to detailed record information directly from the many2many tags</span>
</li>
<li class="d-flex align-items-center mb-3">
<i class="fa fa-check-circle text-primary fs-4 me-3"></i>
<span class="fs-5">Boost productivity by reducing time spent switching between records</span>
</li>
<li class="d-flex align-items-center mb-3">
<i class="fa fa-check-circle text-primary fs-4 me-3"></i>
<span class="fs-5">Improves user experience with faster, more efficient navigation</span>
</li>
<li class="d-flex align-items-center mb-3">
<i class="fa fa-check-circle text-primary fs-4 me-3"></i>
<span class="fs-5">Seamlessly integrates into existing Odoo many2many fields and views</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</section>
<!-- Watch Demo Section -->
<section class="container py-5">
<div class="row justify-content-center">
<div class="col-lg-10 col-sm-12 text-center shadow rounded-3">
<h2 class="text-primary my-5">Watch Demo</h2>
<p class="bg-primary text-light rounded-3 p-4 lead">
Check out our video for a detailed demonstration of how our Odoo apps work and how they can help you optimize your business.
</p>
<div class="card bg-info mb-4 text-light rounded-3 overflow-hidden">
<div class="card-body text-center position-relative">
<a href="https://youtu.be/dNF106wVNX0" target="_blank">
<img src="http://img.youtube.com/vi/dNF106wVNX0/mqdefault.jpg" class="img-fluid rounded" title="YouTube Video" alt="YouTube Video" />
<div class="play-button position-absolute top-50 start-50 translate-middle bg-dark bg-opacity-50 rounded-circle p-2">
<i class="fa fa-play-circle fa-3x text-light"></i>
</div>
</a>
</div>
</div>
</div>
</div>
</section>
<!-- Screenshots Section -->
<section class="container py-5">
<div class="row justify-content-center">
<div class="col-lg-10 text-center shadow rounded-3">
<h2 class="text-primary my-5">Screenshots</h2>
<p class="bg-primary text-light rounded-3 p-4 lead">
Explore how our app looks and functions! Here are some screenshots to give you a quick view of the
features.
</p>
<div class="row g-4 mb-4">
<div class="col-12">
<div class="card bg-primary text-light rounded-3 overflow-hidden">
<div class="card-header">Quick Preview</div>
<div class="card-body">
<img alt="Screenshot 1" class="img-fluid rounded" src="/many2many_quick_preview.gif">
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Our Service Section -->
<section class="container py-5">
<div class="row justify-content-center">
<div class="col-lg-10 col-md-12 col-sm-12 text-center shadow rounded-3">
<h2 class="text-primary my-5">Our Services</h2>
<p class="bg-primary text-light rounded-3 p-4 lead">
We offer a range of essential services designed to enhance your Odoo experience, including
customization, migration, and troubleshooting. Our goal is to ensure smooth integration and optimal
performance for your business.
</p>
<div class="row">
<div class="col-lg-4 col-md-6 mb-4">
<div class="card shadow-sm bg-info rounded-3 overflow-hidden h-100 d-flex flex-column">
<div class="card-body text-center d-flex flex-column">
<div class="mb-3">
<i class="fa fa-cogs text-primary fs-2"></i>
</div>
<h4 class="card-title text-primary">Customization</h4>
<p class="card-text flex-grow-1">
Tailor Odoo to meet your specific business needs with custom modules, workflows, and UI
adjustments.
We ensure that Odoo fits perfectly into your operations.
</p>
</div>
</div>
</div>
<div class="col-lg-4 col-md-6 mb-4">
<div class="card shadow-sm bg-info rounded-3 overflow-hidden h-100 d-flex flex-column">
<div class="card-body text-center d-flex flex-column">
<div class="mb-3">
<i class="fa fa-exchange text-primary fs-2"></i>
</div>
<h4 class="card-title text-primary">Migration</h4>
<p class="card-text flex-grow-1">
Upgrade your Odoo plugins from older versions to newer versions.
We ensure a smooth transition, preserving functionality and minimizing downtime.
</p>
</div>
</div>
</div>
<div class="col-lg-4 col-md-6 mb-4">
<div class="card shadow-sm bg-info rounded-3 overflow-hidden h-100 d-flex flex-column">
<div class="card-body text-center d-flex flex-column">
<div class="mb-3">
<i class="fa fa-bug text-primary fs-2"></i>
</div>
<h4 class="card-title text-primary">Troubleshooting</h4>
<p class="card-text flex-grow-1">
Encountering issues with your Odoo setup? Our troubleshooting service quickly identifies
and fixes
problems, ensuring minimal downtime and maximum productivity.
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- More Apps Section -->
<section class="container py-5">
<div class="row justify-content-center">
<div class="col-lg-10 col-sm-12 text-center shadow rounded-3">
<h2 class="text-primary my-5">Explore More Apps</h2>
<p class="bg-primary text-light rounded-3 p-4 lead">
Looking for more powerful tools to enhance your Odoo experience? Check out our complete collection of
apps
designed to help you get the most out of your Odoo environment.
</p>
<div class="card bg-info mb-4 text-light rounded-3 overflow-hidden">
<div class="card-body text-center">
<a class="btn btn-lg text-primary px-4"
href="https://apps.odoo.com/apps/modules/browse?author=Odoo%20Hub">
<i class="fa fa-cogs me-2"></i> Explore Our Apps
</a>
</div>
</div>
</div>
</div>
</section>
<!-- Help & Support Section -->
<section class="container py-5">
<div class="row justify-content-center">
<div class="col-lg-10 col-sm-12 text-center shadow rounded-3">
<h2 class="text-primary my-5">Help & Support</h2>
<p class="bg-primary text-light rounded-3 p-4 lead">
Having issues with the app? We offer <strong>free support</strong> to help with installation,
configuration, or any bugs you may encounter.
If you need further <strong>customizations</strong>, We are here to provide tailored solutions for your
needs.
</p>
<div class="card bg-info mb-4 text-light rounded-3 overflow-hidden">
<div class="card-body text-center">
<a class="btn btn-lg text-primary px-4" href="mailto:odoohubofficial@gmail.com">
<i class="fa fa-envelope me-2"></i> Email Us Now
</a>
</div>
</div>
</div>
</div>
</section>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 525 KiB

@@ -0,0 +1,58 @@
/** @odoo-module **/
import { Many2ManyTagsFieldColorEditable, Many2ManyTagsField } from "@web/views/fields/many2many_tags/many2many_tags_field";
import { patch } from "@web/core/utils/patch";
patch(Many2ManyTagsFieldColorEditable.prototype, {
setup() {
super.setup(...arguments);
},
onBadgeClick(ev, record) {
const onBadgeClick = super.onBadgeClick(ev, record);
var action = {
type: 'ir.actions.act_window',
res_model: record.resModel,
res_id: record.resId,
views: [[false, 'form']],
target: 'new',
};
this.env.model.action.doAction(action);
return onBadgeClick;
},
});
patch(Many2ManyTagsField.prototype, {
getTagProps(record) {
const props = super.getTagProps(record);
// 绑定点击事件(注意要接收 ev)
props.onClick = (ev) => this.onTagClick(ev, record);
return props;
},
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: [[viewId, "form"]],
target: "new",
});
},
});