在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. FileZilla搭建FTP服务器

    一.基础环境1.服务端机器:192.168.0.104 FillaZilla Server端下载2.客户端机器:192.168.0.100 FillaZilla客户端下载 !!!搭建FTP服务端的机器 ...

  2. SRDC - ORA-1548: Checklist of Evidence to Supply (Doc ID 1682693.1)

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

  3. Django框架(二十二)-- Django rest_framework-解析器

    一.解析器的作用 根据请求头 content-type 选择对应的解析器对请求体内容进行处理,将传过来的数据解析成字典 二.使用解析器 1.局部使用 在视图类中重定义parser_classes即可, ...

  4. PHP转Go系列:数组与切片

    数组的定义 用过PHP的同学应该很清楚,无论多么复杂的数据格式都可以用数组来表达,什么类型的数据都可以往里塞,它是工作必备的一部分,使用很简单,易用程度简直变态. $array = [1, 'name ...

  5. 13. 抽象类 & 接口

    一.抽象类 // 抽象类Shape public abstract class Shape { // 1. 成员变量 private String color; // 2. 初始化块 { System ...

  6. selenium截取元素

    http://www.mamicode.com/info-detail-2161474.html 常见问题 https://blog.csdn.net/u010616442/article/detai ...

  7. python如何实现元素等待

    一.为什么要元素等待? 在UI自动化过程中,元素的出现受网络环境.设备性能等多种元素影响.因此,元素加载和脚本运行到该元素的时间不一致,会报错:元素无法定位. 简单举下例子:实际UI自动化测试中,点击 ...

  8. 剑指Offer-3.从尾到头打印链表(C++/Java)

    题目: 输入一个链表,按链表从尾到头的顺序返回一个ArrayList. 分析: 很简单的一道题,其实也就是从尾到头打印链表,题目要求返回ArrayList,其实也就是一个数组. 可以将链表中的元素全部 ...

  9. 树莓派4b+linux

    用Win32DiskImager烧录系统 先在boot根目录下新建ssh空文件夹来开启ssh功能,否则ssh是关闭的,用putty一直连不上,显示拒绝连接 1.联网: 初次 (实践证明:直接在sd卡根 ...

  10. glade No package 'libxml-2.0' found

    ------------恢复内容开始------------ 今天突发奇想 root@Aja:~/下载/libxml2-master# glade 不会用纳 百度一下——————————>> ...