notebook增加字段背景色示例
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
<field name="name" string="房产名称" width="600px" />
|
||||
<field name="expected_price" string="预期价格" />
|
||||
<field name="selling_price" string="成交价格" />
|
||||
<field name="tag_ids" widget="many2many_tags" context="{'open_form_view': 'estate.estate_property_tag_view_form02'}"/>
|
||||
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}" context="{'open_form_view': 'estate.estate_property_tag_view_form02'}"/>
|
||||
<field name="bedrooms" string="卧室数" />
|
||||
<field name="living_area" string="面积(㎡)" />
|
||||
<field name="state" string="状态" />
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "Issue Tracker",
|
||||
"version": "17.0.1.0.0",
|
||||
"summary": "内部问题追踪与处理",
|
||||
"category": "Productivity",
|
||||
"author": "Your Name",
|
||||
"depends": ["base", "mail"],
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"views/issue_ticket_views.xml",
|
||||
"views/issue_ticket_menus.xml",
|
||||
],
|
||||
"assets": {
|
||||
"web.assets_backend": [
|
||||
"issue/static/src/**/*",
|
||||
],
|
||||
},
|
||||
"installable": True,
|
||||
"application": True,
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
from . import issue_ticket
|
||||
from . import issue_ticket_tag
|
||||
from . import issue_ticket_detail
|
||||
@@ -0,0 +1,50 @@
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class IssueTicket(models.Model):
|
||||
_name = "issue.ticket"
|
||||
_description = "问题单"
|
||||
_inherit = ["mail.thread", "mail.activity.mixin"]
|
||||
_order = "priority desc, create_date desc"
|
||||
|
||||
name = fields.Char(string="问题标题", required=True, tracking=True)
|
||||
description = fields.Text(string="问题描述")
|
||||
reporter_id = fields.Many2one(
|
||||
"res.users", string="报告人", default=lambda self: self.env.user
|
||||
)
|
||||
assigned_id = fields.Many2one("res.users", string="负责人", tracking=True)
|
||||
priority = fields.Selection(
|
||||
[("0", "低"), ("1", "普通"), ("2", "高"), ("3", "紧急")],
|
||||
default="1",
|
||||
string="优先级",
|
||||
tracking=True,
|
||||
)
|
||||
state = fields.Selection(
|
||||
[
|
||||
("draft", "草稿"),
|
||||
("open", "已打开"),
|
||||
("in_progress", "处理中"),
|
||||
("done", "已解决"),
|
||||
("cancelled", "已取消"),
|
||||
],
|
||||
default="draft",
|
||||
string="状态",
|
||||
tracking=True,
|
||||
)
|
||||
deadline = fields.Date(string="截止日期")
|
||||
tag_ids = fields.Many2many("issue.ticket.tag", string="标签")
|
||||
work_end=fields.Boolean(string="工作结束", default=False, tracking=True)
|
||||
remark=fields.Html(string="备注")
|
||||
# 新增:问题明细关联
|
||||
line_ids = fields.One2many(
|
||||
"issue.ticket.detail", "ticket_id", string="问题明细", copy=True
|
||||
)
|
||||
|
||||
@api.constrains("deadline")
|
||||
def _check_deadline(self):
|
||||
for rec in self:
|
||||
if rec.deadline and rec.deadline < fields.Date.today():
|
||||
raise ValidationError("截止日期不能早于今天。")
|
||||
def action_set_draft(self):
|
||||
self.state = "draft"
|
||||
@@ -0,0 +1,18 @@
|
||||
from odoo import models, fields, api
|
||||
|
||||
class IssueTicketDetail(models.Model):
|
||||
_name = "issue.ticket.detail"
|
||||
_description = "问题明细"
|
||||
_order = "sequence, create_date"
|
||||
|
||||
ticket_id = fields.Many2one(
|
||||
"issue.ticket", string="问题单", required=True, ondelete="cascade", index=True
|
||||
)
|
||||
sequence = fields.Integer(string="序号", default=10)
|
||||
name = fields.Char(string="明细标题", required=True)
|
||||
description = fields.Text(string="明细描述")
|
||||
user_id = fields.Many2one("res.users", string="负责人", default=lambda self: self.env.user)
|
||||
is_done = fields.Boolean(string="已完成", default=False)
|
||||
planned_hours = fields.Float(string="预计小时数")
|
||||
spent_hours = fields.Float(string="已用小时数")
|
||||
note = fields.Html(string="备注")
|
||||
@@ -0,0 +1,9 @@
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class IssueTicketTag(models.Model):
|
||||
_name = "issue.ticket.tag"
|
||||
_description = "问题标签"
|
||||
|
||||
name = fields.Char(string="标签名称", required=True)
|
||||
color = fields.Integer(string="颜色")
|
||||
@@ -0,0 +1,4 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_issue_ticket_user,access.issue.ticket.user,model_issue_ticket,,1,1,1,1
|
||||
access_issue_ticket_tag_user,access.issue.ticket.tag.user,model_issue_ticket_tag,,1,1,1,1
|
||||
access_issue_ticket_detail_user,access.issue.ticket.detail.user,model_issue_ticket_detail,,1,1,1,1
|
||||
|
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -0,0 +1,6 @@
|
||||
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200">
|
||||
<path d="M650.24 896H211.2a48 48 0 0 1-48.64-48V176A48.64 48.64 0 0 1 211.2 128h543.36a48.64 48.64 0 0 1 48.64 48v301.44a32 32 0 0 0 32 32 32.64 32.64 0 0 0 32-32V176A112 112 0 0 0 754.56 64H211.2a112 112 0 0 0-112.64 112v669.44A112 112 0 0 0 211.2 960h439.04a32 32 0 0 0 32-32 32.64 32.64 0 0 0-32-32zM819.84 861.44a46.08 46.08 0 1 0 46.08 46.08 46.08 46.08 0 0 0-46.08-46.08z" fill="#d4237a"/>
|
||||
<path d="M403.84 266.24h256V332.8h-256z" fill="#1296db"/>
|
||||
<circle cx="321.28" cy="298.88" r="44.8" fill="#f4ea2a"/>
|
||||
<path d="M403.84 460.16h256v66.56h-256zM320 448a44.8 44.8 0 1 0 44.8 44.8A44.8 44.8 0 0 0 320 448zM403.84 652.8h190.72v66.56H403.84zM320 640a45.44 45.44 0 1 0 44.8 45.44A45.44 45.44 0 0 0 320 640zM819.2 549.12a104.96 104.96 0 0 0-107.52 103.04 32 32 0 0 0 32 32 32 32 0 0 0 32-32 42.24 42.24 0 0 1 43.52-39.04 39.68 39.68 0 0 1 42.24 39.04c0 12.16-5.12 17.92-21.76 33.92a138.24 138.24 0 0 0-51.2 111.36 32 32 0 0 0 32 32 32 32 0 0 0 32-32 77.44 77.44 0 0 1 32-64 106.88 106.88 0 0 0 40.96-80 103.68 103.68 0 0 0-106.24-104.32z" fill="#1296db"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,8 @@
|
||||
.issue_ticket_detail_page td[name="name"] {
|
||||
background-color: gray !important;
|
||||
color: white !important;
|
||||
}
|
||||
.issue_ticket_detail_page td[name="name"]:hover {
|
||||
background-color: black !important;
|
||||
color: white !important;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/** @odoo-module **/
|
||||
import { Component } from "@odoo/owl";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
|
||||
export class Version extends Component {
|
||||
static template = "base_foundation.version";
|
||||
static props = ["*"];
|
||||
|
||||
setup() {
|
||||
this.actionService = useService("action");
|
||||
}
|
||||
|
||||
async openDialog(size) {
|
||||
const action = {
|
||||
name: 'Mitchell Admin',
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: 'res.users',
|
||||
res_id: 2,
|
||||
views: [[162, 'form']],
|
||||
target: 'new',
|
||||
context: {
|
||||
dialog_size: size,
|
||||
},
|
||||
};
|
||||
this.actionService.doAction(action);
|
||||
}
|
||||
|
||||
async openSmall() {
|
||||
this.openDialog("small");
|
||||
}
|
||||
|
||||
async openMedium() {
|
||||
this.openDialog("medium");
|
||||
}
|
||||
|
||||
async openLarge() {
|
||||
this.openDialog("large");
|
||||
}
|
||||
|
||||
async openExtraLarge() {
|
||||
this.openDialog("extra-large");
|
||||
}
|
||||
|
||||
async openFullscreen() {
|
||||
this.openDialog("fullscreen");
|
||||
}
|
||||
}
|
||||
|
||||
registry.category("actions").add("issue.version", Version);
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="base_foundation.version">
|
||||
<h1>Hello Dialog</h1>
|
||||
<div class="d-flex flex-column gap-2">
|
||||
<button class="btn btn-secondary" t-on-click="openSmall">点击 Small 小号</button>
|
||||
<button class="btn btn-primary" t-on-click="openMedium">点击 Medium 中等</button>
|
||||
<button class="btn btn-success" t-on-click="openLarge">点击 Large 大号</button>
|
||||
<button class="btn btn-warning" t-on-click="openExtraLarge">点击 Extra-Large 超大号</button>
|
||||
<button class="btn btn-danger" t-on-click="openFullscreen">点击 Fullscreen 全屏</button>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
@@ -0,0 +1,21 @@
|
||||
<odoo>
|
||||
<menuitem id="menu_issue_root" name="问题管理" sequence="10"
|
||||
web_icon="issue,static/description/icon.png" />/>
|
||||
<record id="menu_issue_ticket_action"
|
||||
model="ir.actions.act_window">
|
||||
<field name="name">所有问题</field>
|
||||
<field name="res_model">issue.ticket</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem id="menu_issue_tickets" name="问题单"
|
||||
parent="menu_issue_root" sequence="1" action="menu_issue_ticket_action" />
|
||||
<!-- 子菜单:版本控制 -->
|
||||
<record model="ir.actions.client" id="Issversion">
|
||||
<field name="name">Version Control</field>
|
||||
<field name="tag">issue.version</field>
|
||||
</record>
|
||||
<menuitem id="menu_version_Control" name="版本控制"
|
||||
parent="menu_issue_root"
|
||||
action="Issversion"
|
||||
sequence="30"/>
|
||||
</odoo>
|
||||
@@ -0,0 +1,94 @@
|
||||
<odoo>
|
||||
<record id="view_issue_ticket_form" model="ir.ui.view">
|
||||
<field name="name">问题单表单视图</field>
|
||||
<field name="model">issue.ticket</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="问题单">
|
||||
<header>
|
||||
<field name="state" widget="statusbar"/>
|
||||
<button type="object" name="action_set_draft" class="btn btn-primary">Primary</button>
|
||||
<button type="object" name="action_set_draft" class="btn btn-secondary">Secondary</button>
|
||||
<button type="object" name="action_set_draft" class="btn btn-success">Success</button>
|
||||
<button type="object" name="action_set_draft" class="btn btn-danger">Danger</button>
|
||||
<button type="object" name="action_set_draft" class="btn btn-warning">Warning</button>
|
||||
<button type="object" name="action_set_draft" class="btn btn-info">Info</button>
|
||||
</header>
|
||||
<sheet>
|
||||
<h1>
|
||||
<field name="name"/>
|
||||
</h1>
|
||||
<group>
|
||||
<group>
|
||||
<field name="reporter_id" readonly="1"/>
|
||||
<field name="assigned_id"/>
|
||||
<field name="priority"/>
|
||||
<field name="work_end"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="deadline"/>
|
||||
<field name="tag_ids" widget="many2many_tags"/>
|
||||
<field name="state"/>
|
||||
<field name="description"/>
|
||||
</group>
|
||||
<field name="remark" widget="tinymce"/>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="明细" >
|
||||
<field name="line_ids" class="issue_ticket_detail_page">
|
||||
<tree editable="bottom">
|
||||
<field name="sequence"/>
|
||||
<field name="name"/>
|
||||
<field name="user_id"/>
|
||||
<field name="is_done"/>
|
||||
<field name="planned_hours"/>
|
||||
<field name="spent_hours"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_issue_ticket_tree" model="ir.ui.view">
|
||||
<field name="name">问题单列表视图</field>
|
||||
<field name="model">issue.ticket</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="name"/>
|
||||
<field name="priority"/>
|
||||
<field name="state"/>
|
||||
<field name="assigned_id"/>
|
||||
<field name="deadline"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_issue_ticket_search" model="ir.ui.view">
|
||||
<field name="name">问题单搜寻视图</field>
|
||||
<field name="model">issue.ticket</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="问题单查找">
|
||||
<header_search class="custom-search">
|
||||
<quick_filter string="状态筛选" and_or="or">
|
||||
<filter name="draft" shownumber="true" string="草稿" domain="[('state', '=', 'draft')]"/>
|
||||
<filter name="open" shownumber="true" string="已打开" domain="[('state', '=', 'open')]"/>
|
||||
<filter name="low" string="低" domain="[('priority', '=', '0')]"/>
|
||||
<filter name="smo" shownumber="true" string="高" domain="[('priority', '=', '2')]"/>
|
||||
</quick_filter>
|
||||
<select_date_filter allow_date_fields="create_date,write_date" />
|
||||
<field name="priority" string="优先级"/>
|
||||
<field name="reporter_id" string="报告人"/>
|
||||
</header_search>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_issue_ticket" model="ir.actions.act_window">
|
||||
<field name="name">问题单</field>
|
||||
<field name="res_model">issue.ticket</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="search_view_id" ref="view_issue_ticket_search"/>
|
||||
<field name="help" type="html">
|
||||
<p>使用此模块创建与管理问题记录。</p>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user