mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
add ui and widget
This commit is contained in:
@@ -25,7 +25,27 @@
|
||||
'summary': 'UI Enhance for Odoo',
|
||||
'description': """
|
||||
|
||||
Search by date or number range in List view and Pivot view
|
||||
1.Search by date or number range in List view and Pivot view
|
||||
--------------------------------------------------
|
||||
2.Instructions for Activating List background color property
|
||||
|
||||
Just add tree attribute like style and colors with condition you want.
|
||||
|
||||
bg_colors="grey:state=='cancel';green:state=='draft';blue:state in ('done');red:state in ('waiting')"
|
||||
|
||||
|
||||
eg.
|
||||
|
||||
<record id="view_demo_tree" model="ir.ui.view">
|
||||
<field name="name">demo.tree</field>
|
||||
<field name="model">demo.model</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree bg_colors="grey:state=='cancel';green:state=='draft';blue:state in ('done');red:state in ('waiting')" name="demo_tree">
|
||||
<field name="name" string="Appointment" />
|
||||
<field name="state" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
--------------------------------------------------
|
||||
|
||||
""",
|
||||
@@ -33,6 +53,7 @@ Search by date or number range in List view and Pivot view
|
||||
'data': [
|
||||
'views/app_ui_config_settings_view.xml',
|
||||
'views/template_view.xml',
|
||||
'views/web_list_bg_color_view.xml',
|
||||
# data
|
||||
'data/ir_config_parameter.xml',
|
||||
],
|
||||
|
||||
@@ -62,6 +62,39 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oe_container">
|
||||
<div class="oe_row oe_spaced" style="max-width: 800px;">
|
||||
<div class="oe_span12">
|
||||
<h2 class="oe_slogan">Web list View Background Color</h2>
|
||||
<div class="oe_demo" style=" margin: 30px auto 0; padding: 0 15px 0 0; border:none; width: 96%;">
|
||||
<p>This module changes the line color of records based on condition like state of a record and helps distinguish between different sets of
|
||||
records based on condition.</p>
|
||||
<a href="http://www.sunpop.cn" target="_blank">
|
||||
<img src="web_bg_color_change.png" width="100%">
|
||||
<p>Set Backgroud color to filed in list view based on condition same as colors and style attributes of tree view.</p>
|
||||
</a>
|
||||
<h3># Instructions for Activating List background color property</h3>
|
||||
<p>
|
||||
Just add tree attribute like style and colors with condition you want.
|
||||
</p>
|
||||
<pre>bg_colors="grey:state=='cancel';green:state=='draft';blue:state in ('done');red:state in ('waiting')"</pre>
|
||||
<h3>eg.</h3>
|
||||
<pre class="">
|
||||
<record id="view_demo_tree" model="ir.ui.view">
|
||||
<field name="name">demo.tree</field>
|
||||
<field name="model">demo.model</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree bg_colors="grey:state=='cancel';green:state=='draft';blue:state in ('done');red:state in ('waiting')" name="demo_tree">
|
||||
<field name="name" string="Appointment" />
|
||||
<field name="state" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="oe_container oe_dark">
|
||||
<div class="oe_row oe_spaced text-center">
|
||||
|
||||
BIN
app_ui_enhance/static/description/web_bg_color_change.png
Normal file
BIN
app_ui_enhance/static/description/web_bg_color_change.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 88 KiB |
7
app_ui_enhance/static/src/css/web_list_bg_color.css
Normal file
7
app_ui_enhance/static/src/css/web_list_bg_color.css
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
.oe_list_field_bg_color div{
|
||||
display: inline-block;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
57
app_ui_enhance/static/src/js/web_list_bg_color.js
Normal file
57
app_ui_enhance/static/src/js/web_list_bg_color.js
Normal file
@@ -0,0 +1,57 @@
|
||||
odoo.define('app_ui_enhance.list_bg_color', function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require('web.core');
|
||||
var common = require('web.form_common');
|
||||
var Model = require('web.Model');
|
||||
var time = require('web.time');
|
||||
var ListView = require('web.ListView');
|
||||
var session = require('web.session');
|
||||
var compatibility = require('web.compatibility');
|
||||
|
||||
ListView.include({
|
||||
willStart: function() {
|
||||
if (this.fields_view.arch.attrs.bg_colors) {
|
||||
this.bg_colors = _(this.fields_view.arch.attrs.bg_colors.split(';')).chain()
|
||||
.compact()
|
||||
.map(function(color_pair) {
|
||||
var pair = color_pair.split(':'),
|
||||
color = pair[0],
|
||||
expr = pair[1];
|
||||
return [color, py.parse(py.tokenize(expr)), expr];
|
||||
}).value();
|
||||
|
||||
if (!this.colors) { this.colors = [] }
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
|
||||
style_for: function (record) {
|
||||
var len, style= '';
|
||||
|
||||
var context = _.extend({}, record.attributes, {
|
||||
uid: session.uid,
|
||||
current_date: moment().format('YYYY-MM-DD')
|
||||
// TODO: time, datetime, relativedelta
|
||||
});
|
||||
|
||||
var i;
|
||||
var pair;
|
||||
var expression;
|
||||
style = this._super(record);
|
||||
|
||||
if (!this.bg_colors) { return style; }
|
||||
for(i=0, len=this.bg_colors.length; i<len; ++i) {
|
||||
pair = this.bg_colors[i];
|
||||
var color = pair[0];
|
||||
expression = pair[1];
|
||||
if (py.PY_isTrue(py.evaluate(expression, context))) {
|
||||
return style += 'background-color: ' + color + ';';
|
||||
}
|
||||
}
|
||||
return style;
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
11
app_ui_enhance/views/web_list_bg_color_view.xml
Normal file
11
app_ui_enhance/views/web_list_bg_color_view.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="assets_backend" name="web_field_bg_color assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<link rel="stylesheet" href="/app_ui_enhance/static/src/css/web_list_bg_color.css"/>
|
||||
<script type="text/javascript" src="/app_ui_enhance/static/src/js/web_list_bg_color.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user