add row num

This commit is contained in:
ivan deng
2018-09-30 05:22:35 +08:00
parent 329a88a3e0
commit f2ae0915ea
14 changed files with 276 additions and 26 deletions

View File

View 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,
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

View 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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

View 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('&nbsp;'));
}
}
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('&nbsp;'));
}
else{
$row.prepend($('<th>').html(index+1));
}
});
}
return $rows;
},*/
});
});

View 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>