def init(self,cr):
tools.sql.drop_view_if_exists(cr, 'custrom_product_infomation_report')
cr.execute("""
create or replace view custrom_product_infomation_report as (
select t0.id,t0.hpartner_id as hpartner_id, t0.khwl_code as khwl_code,t1.product_tmpl_id as productn,
t3.pname,t3.material,t3.spec,
t4.id as name_uom, t5.price as custo_price,t0.product_meno as product_meno ,t0.meno as meno,t5.date_from,t5.date_to
from product_custo_info t0
LEFT JOIN product_product t1 on t0.product_tmpl_id=t1.product_tmpl_id
LEFT JOIN product_template t3 on t3.id=t1.product_tmpl_id
LEFT JOIN res_partner t2 on t2.id=t0.hpartner_id
LEFT JOIN product_uom t4 on t3.uom_id=t4.id
left join partner_product_price t5 on t5.ppp_line_id=t0.id )
""") sql语句当该前时间对比: select * from (select  t1.id,t0.product_meno,
 t0.hpartner_id,t0.khwl_code ,t0.name_uom,t0.custo_price  
,t0.product_meno,t0.meno,t2.pname ,t0.date_from,t0.date_to
from cust_product_info_report  t0  
LEFT JOIN product_product t1 on t1.product_tmpl_id=t0.productn  
LEFT JOIN product_template t2  on t1.product_tmpl_id=t2.id
where  (now()>=t0.date_from  and now()<=t0.date_to) or  (t0.date_from is null and t0.date_to is null )  or
(t0.date_from is null and (now()<=t0.date_to))  or (t0.date_to is null and (now()>=t0.date_from))
 )
 as p where  hpartner_id='16404'  
 order by pname sql 中 : case ........when........... then.......
else....... end
方法: case tt3.send_invoice_type WHEN '1' then  '汽车零担' WHEN '2' then  '苏通快运'
WHEN '3' then  '顺丰速运' WHEN '4' then  '德邦快递' WHEN '5' then  '优速快递'
WHEN '6' then  '佳吉物流' WHEN '7' then  '中通物流' WHEN '8' then  '下午车'
else '' end 发运方式,

python init 方法 与 sql语句当前时间对比的更多相关文章

  1. SQL语句更新时间字段的年份、月份、天数、时、分、秒

    SQL语句更新时间字段的年份.月份.天数.时.分.秒 --修改d表日期字段的年份update dset birth=STUFF(convert(nvarchar(23),birth,120),1,4, ...

  2. ACCESS与MSSQL比较:SQL语句关于时间格式使用的注意点

    ACCESS与MSSQL比较:SQL语句关于时间字符串的使用:ACCESS数据库使用 # 来控制时间格式字符串:mssql数据库使用单引号 ' 来控制时间格式字符串.例: ACCESS版本:UPDAT ...

  3. 自己写的Python数据库连接类和sql语句拼接方法

    这个工具类十分简单和简洁. sql拼接方法 # encoding=utf-8 from django.http import HttpResponse from anyjson import seri ...

  4. 查询sql语句所花时间

    --1:下面这种是SQL Server中比较简单的查询SQL语句执行时间方法,通过查询前的时间和查询后的时间差来计算的: declare @begin_date datetime declare @e ...

  5. 优化数据库的方法及SQL语句优化的原则

    优化数据库的方法: 1.关键字段建立索引. 2.使用存储过程,它使SQL变得更加灵活和高效. 3.备份数据库和清除垃圾数据. 4.SQL语句语法的优化.(可以用Sybase的SQL Expert,可惜 ...

  6. SQL SERVER 查看SQL语句IO,时间,索引消耗

    1.查看SQL语句IO消耗 set statistics io on     select * from dbo.jx_order where order_time>'2011-04-12 12 ...

  7. mysql 修改表名的方法:sql语句

    在使用mysql时,经常遇到表名不符合规范或标准,但是表里已经有大量的数据了,如何保留数据,只更改表名呢? 可以通过建一个相同的表结构的表,把原来的数据导入到新表中,但是这样视乎很麻烦. 能否简单使用 ...

  8. 如何在python文件中测试sql语句

    在manage.py的同级目录下新建一个run.py import os if __name__ == '__main__': #加载Django项目的配置信息 os.environ.setdefau ...

  9. SQL语句获取时间的方法

    1. 当前系统日期.时间select getdate() 2. dateadd 在向指定日期加上一段时间的基础上,返回新的 datetime 值例如:向日期加上2天select dateadd(day ...

随机推荐

  1. node.js入门学习笔记整理

    (1)node Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境. Node与javaScript的区别在于,javaScript的顶层对象是window,而no ...

  2. React 入门学习笔记整理(五)—— state

    1.state 1)组件本省也是有状态的,定义在组件内部的state中,state的状态只能由组件自身改变,任何其他组件都不能改变. 当需要改变state时,通过调用setState方法来改变,set ...

  3. Android开发专业名词及工具概述

    前言: 系统的学习下Android开发中涉及到的一些专业名词 和Android开发工具 名词: 一.SDK(Software Development Kit) 软件开发工具包:一般都是一些软件工程师为 ...

  4. HBuilder开发ios App离线打包启动画面无效的解决方法

    其中容易忽略的一点是manifest.json文件.plus下加入如下配置: "splashscreen": { "autoclose": false,/*如果 ...

  5. Kotlin入门(2)让App开发变得更容易

    上一篇文章介绍了如何搭建Kotlin的开发环境,可是这个开发环境依然基于Android Studio,而在Android Studio上使用Java进行编码,本来就是理所应当的,何必还要专门弄个Kot ...

  6. Linux笔记(二): WIN 10 Ubuntu 双系统

    (一)  说明 记录一次ubuntu安装过程及遇到的问题. 环境:WIN 10 单硬盘 (二)  ubuntu ISO文件下载 ubuntu 18.04 https://www.ubuntu.com/ ...

  7. Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

    在主工程(ASP.NET WEB/WCF等)的NuGet里引用 System.Data.SQLite.Core 不仅仅是Service需要引用,主工程即使不直接使用SQLite的库,也需要引用. 若使 ...

  8. 【HANA系列】SAP HANA XS使用服务器JavaScript Libraries详解

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列]SAP HANA XS使用服务器 ...

  9. MySQL复制ERROR 1794 (HY000): Slave is not configured or failed to initialize properly.

    ERROR 1794 (HY000): Slave is not configured or failed to initialize properly. You must at least set  ...

  10. 基于python的快速傅里叶变换FFT(二)

    基于python的快速傅里叶变换FFT(二)本文在上一篇博客的基础上进一步探究正弦函数及其FFT变换. 知识点  FFT变换,其实就是快速离散傅里叶变换,傅立叶变换是数字信号处理领域一种很重要的算法. ...