在odoo中,通过iframe嵌入 html,页面数据则通过controllers获取,使用jinja2模板传值渲染

html页面分页内容,这里写了判断逻辑

<!-- 分页 -->
<ul id="ty_paging">
<li class="home" id="home"><a href="/car/budget/report/1"></a>首页</li>
{% if current_page == 1 %}
<li class="prev" id="prev"><</li>
{% else %}
<li class="prev" id="prev"><a href="/car/budget/report/{{current_page - 1}}"><</a></li>
{% endif %}
{% if current_page == total_page %}
<li class="next" id="next">></li>
{% else %}
<li class="next" id="next"><a href="/car/budget/report/{{current_page + 1}}">></a></li>
{% endif %}
<li class="max">共{{total_page}}页</li>
<li class="max">第{{current_page}}页</li>
<input type="number" min="1" value="1" class="inputPage" id="inputPage"/>
<li class="jump" id="jump"><a id="add" href="javascript:void(0)" onclick="subNmbr()">跳转</a></li> </ul> 在,odoo的controllers中的逻辑
class CarBudgetReport(http.Controller):
@http.route('/car/budget/report/<int:page>', auth='public')
def index(self, page=1, **kw):
data1 = request.env['lims.car.scheme'].get_first_budget()
total_page = int(len(data1) / 10) + 1
if page > total_page:
data = []
else:
data = data1[(page - 1) * 10: page * 10]
return env.get_template(HTML_FIEL_NAME).render({'data': data, 'current_page': page, 'total_page': total_page})

 CSS文件:

/* 分页功能的通用样式 */
#ty_paging {
overflow: hidden;
display: block;
width: 100%;
margin-top: 20px;
text-align: center;
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
font-size: 14px;
color: #000000;
background-color: #FFFFFF; }
#ty_paging li {
display: inline-block;
height: 32px;
width: 32px;
line-height: 32px;
margin: 0px 5px;
padding: 0px;
border: 1px solid #ddd;
border-radius: 2px;
cursor: pointer;
vertical-align: top;
text-align: center; }
#ty_paging .home,#ty_paging .jump {
width: 56px;
height: 32px; }
#ty_paging .max {
width: 60px;
border: none; }
#ty_paging .inputPage {
height: 32px;
width: 56px;
border: 1px solid #ddd;
border-radius: 2px;
text-align: center;
color: #000000; }

 在后台xml中需要将路由设置默认为1

<?xml version="1.0" encoding="UTF-8"?>

<templates id="template" xml:space="preserve">

        <t t-name="BudgettIframe">
<iframe src="car/budget/report/1" marginheight="0" marginwidth="0" width="100%" height="100%" />
</t>
</templates>
html 分页js代码
<script>
// 悬浮样式
$('#home, #jump').mouseover(function () {
// if ($(this).val() == ty_currentPage) return;
$(this).css({
'border-color': '#2db71a',
'color': '#000000',
// 'background-color': '#337ab7',
});
});
$('#home, #prev, #next, #jump').mouseout(function () {
// if ($(this).val() == ty_currentPage) return;
$(this).css({
'border-color': "#ddd",
'color': '#666',
// 'background-color': '#ffffff',
});
}); $('#up, #down').mouseover(function () {
// if ($(this).val() == ty_currentPage) return;
$(this).css({
'border-color': '#337ab7',
'color': '#ffffff',
'background-color': '#2db71a',
});
});
$('#up, #down').mouseout(function () {
// if ($(this).val() == ty_currentPage) return;
$(this).css({
'border-color': "#000000",
'color': '#000000',
'background-color': '#ffffff',
});
}); // 点击跳转页面需要用到方法
function subNmbr() {
// 先获取到页面上input输入框中的值
var subNmbr = document.getElementById('inputPage').value;
// console.log(subNmbr);
// 在获取li的id,在点击时做一个动作
document.getElementById("jump").onclick = function () {
//根据a标签的id获取链接,设置href属性
var aObj = document.getElementById("add");
// 把要跳转的页面连接传入href
aObj.href = "/car/budget/report/" + subNmbr;
//根据id获取超链接,设置文字内容
aObj.innerText = "跳转";
};
} </script>
之后便可以进行数据的简单分页


Python odoo中嵌入html简单的分页功能的更多相关文章

  1. AngularJS实现简单的分页功能

    本篇文章由:http://xinpure.com/angularjs-simple-paging-functionality/ 初学 AngularJS, 尝试着写一些小功能 代码逻辑写得略粗糙,仅仅 ...

  2. python QQTableView中嵌入复选框CheckBox四种方法

    搜索了一下,QTableView中嵌入复选框CheckBox方法有四种: 第一种不能之前显示,必须双击/选中后才能显示,不适用. 第二种比较简单,通常用这种方法. 第三种只适合静态显示静态数据用 第四 ...

  3. 简单封装分页功能pageView.js

    分页是一个很简单,通用的功能.作为一个有经验的前端开发人员,有义务把代码中类似这样公共的基础性的东西抽象出来,一来是改善代码的整体质量,更重要的是为了将来做类似的功能或者类似的项目,能减少不必要的重复 ...

  4. Python: 字符串中嵌入变量

    问题:想创建一个内嵌变量的字符串,变量被它的值替换掉 解决方案: ①Python并没有对在字符串中简单替换变量值提供直接的支持,但是通过字符串的format()方法来解决这个问题 ②如果要被替换的变量 ...

  5. 作为一个Java程序员连简单的分页功能都会写,你好意思嘛!

    今天想说的就是能够在我们操作数据库的时候更简单的更高效的实现,现成的CRUD接口直接调用,方便快捷,不用再写复杂的sql,带吗简单易懂,话不多说上方法 1.Utils.java工具类中的方法 1 /* ...

  6. 在django中使用自定义标签实现分页功能

    效果演示: github地址:https://github.com/mncu/django_projects/tree/master/django_projects/pagination_test 本 ...

  7. django项目中使用bootstrap插件的分页功能。

    官网下载bootstrap插件放到项目中的static文件中 路由 path('blog-fullwidth/', login.fullwidth,name='fullwidth'), 前端页面引入 ...

  8. python模块——re模块(简单的计算器功能实现_eval版)

    #!/usr/bin/env python # -*- coding:utf-8 -*- __author__ = "loki" # Usage: Make a Diy Calcu ...

  9. python爬虫——写出最简单的网页爬虫

    在我们日常上网浏览网页的时候,经常会看到一些好看的图片,我们就希望把这些图片保存下载,或者用户用来做桌面壁纸,或者用来做设计的素材.我们可以通过python 来实现这样一个简单的爬虫功能,把我们想要的 ...

随机推荐

  1. SRDC - ORA-1628: Checklist of Evidence to Supply (Doc ID 1682729.1)

    SRDC - ORA-1628: Checklist of Evidence to Supply (Doc ID 1682729.1) Action Plan 1. Execute srdc_db_u ...

  2. 使用odbc从notes中导数据,配置odbc时报错

    上次在配置odbc从notes中导数据时一直报错(忘记是什么错误了),后来,尝试着把notes和notesSQL的路径加入到path中就OK了!

  3. Python—编码与解码(encode()和decode())

    编码与解码 decode英文意思是解码,encode英文原意是编码. Python 里面的编码和解码也就是 unicode 和 str 这两种形式的相互转化.编码是 unicode -> str ...

  4. emacs c/c++ 中使用的命令大杂烩

    emacs c/c++ 中使用的命令大杂烩 注释,缩进,光标移动等 键盘操作 键盘操作对应函数名 说明 ESC Ctrl \ indent-region 对光标和标记之间的每行文本进行缩进 ESC ; ...

  5. [MySQL] mysql地理位置服务geometry字段类型

    这个字段类型是mysql5.7新增的功能,主要就是解决坐标存储和距离计算的常见问题 创建表:CREATE TABLE `service` ( `id` bigint(20) NOT NULL AUTO ...

  6. conda基础命令

    1.首先在所在系统中安装Anaconda.可以打开命令行输入conda -V检验是否安装以及当前conda的版本. 2.conda常用的命令. 1)conda list 查看安装了哪些包. 2)con ...

  7. oracle并行模式

    参考链接:oracle并行模式(Parallel),深入理解Oracle的并行操作(原创),oracle使用并行踩过的坑 1. 语法(这个可以加到insert.delete.update.select ...

  8. CF-weekly4 F. Kyoya and Colored Balls

    https://codeforces.com/gym/253910/problem/F F. Kyoya and Colored Balls time limit per test 2 seconds ...

  9. [技术]SYZOJ 实现网站与评测端分离

    SYZOJ 实现分布式评测 这篇博客的起因是学校的OJ因为高考被切断了, 但是我的公网OJ是个实现很不清真的UOJ而且上面只有1core和1GB内存. 费了一些周折部署好syzoj之后大家喜闻乐见地被 ...

  10. 剑指offer:二叉搜索树的第k个结点(中序遍历)

    1. 题目描述 /* 给定一棵二叉搜索树,请找出其中的第k小的结点. 例如, (5,3,7,2,4,6,8) 中,按结点数值大小顺序第三小结点的值为4. */ 2. 思路 中序遍历二叉搜索树,第K个就 ...