mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
add row num
This commit is contained in:
0
app_web_list_row_number/__init__.py
Normal file
0
app_web_list_row_number/__init__.py
Normal file
39
app_web_list_row_number/__manifest__.py
Normal file
39
app_web_list_row_number/__manifest__.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# author: 'Nilesh Sheliya',
|
||||
|
||||
# Created on 2018-09-30
|
||||
# author: 广州尚鹏,http://www.sunpop.cn
|
||||
# email: 300883@qq.com
|
||||
# resource of Sunpop
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
# Odoo在线中文用户手册(长期更新)
|
||||
# http://www.sunpop.cn/documentation/user/10.0/zh_CN/index.html
|
||||
|
||||
# Odoo10离线中文用户手册下载
|
||||
# http://www.sunpop.cn/odoo10_user_manual_document_offline/
|
||||
# Odoo10离线开发手册下载-含python教程,jquery参考,Jinja2模板,PostgresSQL参考(odoo开发必备)
|
||||
# http://www.sunpop.cn/odoo10_developer_document_offline/
|
||||
# description:
|
||||
|
||||
|
||||
{
|
||||
'name': "App Row Number in tree list view",
|
||||
'version': '11.0.9.30',
|
||||
'summary': 'Show row number in tree/list view. list number, list row number',
|
||||
'category': 'Other',
|
||||
'description': """By installing this module, user can see row number in Odoo backend tree view.""",
|
||||
'author': 'Sunpop.cn',
|
||||
"depends": ['web'],
|
||||
'data': [
|
||||
'views/listview_templates.xml',
|
||||
],
|
||||
"images": ["static/description/screen1.png"],
|
||||
'license': 'LGPL-3',
|
||||
'qweb': [
|
||||
],
|
||||
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'auto_install': False,
|
||||
}
|
||||
BIN
app_web_list_row_number/static/description/icon.png
Normal file
BIN
app_web_list_row_number/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
76
app_web_list_row_number/static/description/index.html
Normal file
76
app_web_list_row_number/static/description/index.html
Normal file
@@ -0,0 +1,76 @@
|
||||
<section class="oe_container app">
|
||||
<div class="oe_row oe_spaced" style="max-width: 95%;">
|
||||
<div class="oe_span12">
|
||||
<h2 class="oe_slogan">App Show Number in List/Tree View</h2>
|
||||
<div class="oe_demo" style=" margin: 30px auto 0; padding: 0 15px 0 0; border:none; width: 96%;">
|
||||
<p>You can see the row number in tree/list view in Odoo backend list views.</p>
|
||||
<div class="row">
|
||||
<h1 class="col-md-6 text-primary">More Powerful addons:</h1>
|
||||
<div class="col-md-6">
|
||||
<a class="btn btn-block btn-success mt16 mb16" href="http://www.odoo.com/apps/modules/browse?author=Sunpop.cn">Sunpop.cn Awesome Odoo Addons</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="oe_row oe_spaced" style="max-width: 95%;">
|
||||
<div class="oe_demo"
|
||||
style="margin: 20px auto; padding: 0 15px 0 0; border:none; border-top:solid 1px #dedede; width: 96%;">
|
||||
<h2 class='oe_mt32'>Show # number in listveiw</h2>
|
||||
</div>
|
||||
<div class="oe_demo oe_screenshot">
|
||||
<img src="s1.jpg" style="border:1px solid black"/>
|
||||
</div>
|
||||
<div class="oe_demo"
|
||||
style="margin: 20px auto; padding: 0 15px 0 0; border:none; border-top:solid 1px #dedede; width: 96%;">
|
||||
<h2 class='oe_mt32'>Show # number in one2many detail listveiw</h2>
|
||||
</div>
|
||||
<div class="oe_demo oe_screenshot">
|
||||
<img src="s2.jpg" style="border:1px solid black"/>
|
||||
</br>
|
||||
</div>
|
||||
<div class="oe_demo"
|
||||
style="margin: 20px auto; padding: 0 15px 0 0; border:none; border-top:solid 1px #dedede; width: 96%;">
|
||||
<h2 class='oe_mt32'>Show # number in grouped listveiw</h2>
|
||||
</div>
|
||||
<div class="oe_demo oe_screenshot">
|
||||
<img src="s3.jpg" style="border:1px solid black"/>
|
||||
</br>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="oe_container oe_dark">
|
||||
<div class="oe_row oe_spaced text-center">
|
||||
<div class="oe_span12">
|
||||
<h2 class="oe_slogan">Technical Help & Support</h2>
|
||||
</div>
|
||||
<div class="col-md-12 pad0">
|
||||
<div class="oe_mt16">
|
||||
<p><h4>
|
||||
For any type of technical help & support requests, Feel free to contact us</h4></p>
|
||||
<a style="background: #002e5a none repeat scroll 0% 0%; color: rgb(255, 255, 255);position: relative; overflow: hidden;"
|
||||
class="btn btn-warning btn-lg" rel="nofollow" href="mailto:guohuadeng@hotmail.com"><span
|
||||
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
|
||||
<i class="fa fa-envelope"></i> guohuadeng@hotmail.com</a>
|
||||
<p><h4>
|
||||
Via QQ: 300883</h4></p>
|
||||
<a style="background: #002e5a none repeat scroll 0% 0%; color: rgb(255, 255, 255);position: relative; overflow: hidden;"
|
||||
class="btn btn-warning btn-lg" rel="nofollow" href="mailto:300883@qq.com"><span
|
||||
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
|
||||
<i class="fa fa-envelope"></i> 300883@qq.com</a>
|
||||
</div>
|
||||
<div class="oe_mt16">
|
||||
<p><h4>
|
||||
Visit our website for more support.</h4></p>
|
||||
<a style="background: #002e5a none repeat scroll 0% 0%; color: rgb(255, 255, 255);position: relative; overflow: hidden;"
|
||||
class="btn btn-warning btn-lg" rel="nofollow" href="http://www.sunpop.cn" target="_blank"><span
|
||||
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
|
||||
<i class="fa fa-web"></i>http://www.sunpop.cn</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
BIN
app_web_list_row_number/static/description/s1.jpg
Normal file
BIN
app_web_list_row_number/static/description/s1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 161 KiB |
BIN
app_web_list_row_number/static/description/s2.jpg
Normal file
BIN
app_web_list_row_number/static/description/s2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 148 KiB |
BIN
app_web_list_row_number/static/description/s3.jpg
Normal file
BIN
app_web_list_row_number/static/description/s3.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 164 KiB |
115
app_web_list_row_number/static/src/js/list_view.js
Normal file
115
app_web_list_row_number/static/src/js/list_view.js
Normal file
@@ -0,0 +1,115 @@
|
||||
odoo.define('app_web_list_row_number.ListNumber', function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require('web.core');
|
||||
var ListRenderer = require('web.ListRenderer');
|
||||
var _t = core._t;
|
||||
|
||||
ListRenderer.include({
|
||||
_getNumberOfCols: function () {
|
||||
var columns = this._super();
|
||||
columns +=1;
|
||||
return columns;
|
||||
},
|
||||
_renderFooter: function (isGrouped) {
|
||||
var $footer = this._super(isGrouped);
|
||||
$footer.find("tr").prepend($('<td>'));
|
||||
return $footer;
|
||||
},
|
||||
_renderGroupRow: function (group, groupLevel) {
|
||||
var $row = this._super(group, groupLevel);
|
||||
if (this.mode !== 'edit' || this.hasSelectors){
|
||||
$row.find("th.o_group_name").after($('<td>'));
|
||||
}
|
||||
return $row;
|
||||
},
|
||||
_renderGroups: function (data, groupLevel) {
|
||||
var self = this;
|
||||
var _self = this;
|
||||
groupLevel = groupLevel || 0;
|
||||
var result = [];
|
||||
var $tbody = $('<tbody>');
|
||||
_.each(data, function (group) {
|
||||
if (!$tbody) {
|
||||
$tbody = $('<tbody>');
|
||||
}
|
||||
$tbody.append(self._renderGroupRow(group, groupLevel));
|
||||
if (group.data.length) {
|
||||
result.push($tbody);
|
||||
// render an opened group
|
||||
if (group.groupedBy.length) {
|
||||
// the opened group contains subgroups
|
||||
result = result.concat(self._renderGroups(group.data, groupLevel + 1));
|
||||
} else {
|
||||
// the opened group contains records
|
||||
var $records = _.map(group.data, function (record,index) {
|
||||
//Nilesh
|
||||
if (_self.mode !== 'edit' || _self.hasSelectors){
|
||||
return self._renderRow(record).prepend($('<th>').html(index+1)).prepend($('<td>'));
|
||||
}
|
||||
else{
|
||||
return self._renderRow(record).prepend($('<td>'));
|
||||
}
|
||||
|
||||
});
|
||||
result.push($('<tbody>').append($records));
|
||||
}
|
||||
$tbody = null;
|
||||
}
|
||||
});
|
||||
if ($tbody) {
|
||||
result.push($tbody);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
_renderHeader: function (isGrouped) {
|
||||
var $header = this._super(isGrouped);
|
||||
if (this.hasSelectors) {
|
||||
$header.find("th.o_list_record_selector").before($('<th class="o_list_row_number_header">').html('#'));
|
||||
var advance_search = $header.find("tr.advance_search_row")
|
||||
if(advance_search.length && advance_search.find('td.o_list_row_number_header').length==0){
|
||||
advance_search.prepend($('<td class="o_list_row_number_header">').html(' '));
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (this.mode !== 'edit'){
|
||||
$header.find("tr").prepend($('<th>').html('#'));
|
||||
}
|
||||
}
|
||||
//$header.find("tr").prepend($('<th>').html('#'));
|
||||
return $header;
|
||||
},
|
||||
_renderRow: function (record) {
|
||||
var $row = this._super(record);
|
||||
if (this.mode !== 'edit' && this.state.groupedBy.length==0){
|
||||
var index = this.state.data.findIndex(function(e){return record.id===e.id})
|
||||
if (index!==-1){
|
||||
$row.prepend($('<td>').html('<strong>' + (index+1).toString() +'</strong>'));
|
||||
}
|
||||
}
|
||||
return $row;
|
||||
|
||||
},
|
||||
/*_renderRows: function () {
|
||||
var $rows = this._super();
|
||||
var total_rows = $rows.length - 1;
|
||||
var _self = this;
|
||||
if (this.mode !== 'edit' || this.hasSelectors){
|
||||
$.each($rows,function(index){
|
||||
var $row = $rows[index];
|
||||
if (total_rows===index && _self.addCreateLine){
|
||||
$row.prepend($('<th>').html(' '));
|
||||
}
|
||||
else{
|
||||
$row.prepend($('<th>').html(index+1));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return $rows;
|
||||
},*/
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
10
app_web_list_row_number/views/listview_templates.xml
Normal file
10
app_web_list_row_number/views/listview_templates.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="assets_backend" name="app_web_list_row_number assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/app_web_list_row_number/static/src/js/list_view.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user