Change substring to to_char for pg8.3

bzr revid: ced-f3042f838a20469fbb6d73f3cd3b143302bf0e69
This commit is contained in:
ced 2008-01-10 09:23:07 +00:00
parent 22bdd227b5
commit 7b8c388bbd
6 changed files with 20 additions and 20 deletions

View File

@ -59,7 +59,7 @@ class report_crm_case_user(osv.osv):
create or replace view report_crm_case_user as (
select
min(c.id) as id,
substring(c.create_date for 7)||'-01' as name,
to_char(c.create_date, 'YYYY-MM-01') as name,
c.state,
c.user_id,
c.section_id,
@ -71,7 +71,7 @@ class report_crm_case_user(osv.osv):
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_case c
group by substring(c.create_date for 7), c.state, c.user_id, c.section_id
group by to_char(c.create_date, 'YYYY-MM-01'), c.state, c.user_id, c.section_id
)""")
report_crm_case_user()
@ -97,7 +97,7 @@ class report_crm_case_categ(osv.osv):
create or replace view report_crm_case_categ as (
select
min(c.id) as id,
substring(c.create_date for 7)||'-01' as name,
to_char(c.create_date, 'YYYY-MM-01') as name,
c.state,
c.categ_id,
c.section_id,
@ -109,6 +109,6 @@ class report_crm_case_categ(osv.osv):
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_case c
group by substring(c.create_date for 7), c.state, c.categ_id, c.section_id
group by to_char(c.create_date, 'YYYY-MM-01'), c.state, c.categ_id, c.section_id
)""")
report_crm_case_categ()

View File

@ -74,7 +74,7 @@ class report_intrastat(osv.osv):
cr.execute("""
create or replace view report_intrastat as (
select
substring(m.create_date for 7)||'-01' as name,
to_char(m.create_date, 'YYYY-MM-01') as name,
min(m.id) as id,
pt.intrastat_id as intrastat_id,
case when l.usage in ('supplier', 'customer') then upper(pc.code) else upper(c.code) end as code,
@ -122,7 +122,7 @@ class report_intrastat(osv.osv):
and ((l.usage in ('supplier', 'customer') and dl.usage not in ('supplier', 'customer'))
or (dl.usage in ('supplier', 'customer') and l.usage not in ('supplier', 'customer')))
and (c.intrastat is not null or pc.intrastat is not null)
group by substring(m.create_date for 7), pt.intrastat_id, c.code, pc.code, l.usage, dl.usage, ppl.currency_id, spl.currency_id
group by to_char(m.create_date, 'YYYY-MM-01'), pt.intrastat_id, c.code, pc.code, l.usage, dl.usage, ppl.currency_id, spl.currency_id
)""")
report_intrastat()

View File

@ -49,7 +49,7 @@ class report_project_task_user(osv.osv):
create or replace view report_project_task_user as (
select
min(t.id) as id,
substring(date_close for 7)||'-01' as name,
to_char(date_close, 'YYYY-MM-01') as name,
count(distinct t.id) as task_closed,
t.user_id,
t.project_id,
@ -62,7 +62,7 @@ class report_project_task_user(osv.osv):
where
t.state='done'
group by
substring(date_close for 7),t.user_id,project_id
to_char(date_close, 'YYYY-MM-01'),t.user_id,project_id
)
""")
report_project_task_user()
@ -87,7 +87,7 @@ class report_project_task(osv.osv):
create or replace view report_project_task as (
select
min(t.id) as id,
substring(date_close for 7)||'-01' as name,
to_char(date_close, 'YYYY-MM-01') as name,
count(distinct t.id) as task_closed,
t.project_id,
sum(planned_hours) as hours_planned,
@ -99,7 +99,7 @@ class report_project_task(osv.osv):
where
t.state='done'
group by
substring(date_close for 7),project_id
to_char(date_close, 'YYYY-MM-01'),project_id
)
""")
report_project_task()

View File

@ -61,7 +61,7 @@ class report_purchase_order_product(osv.osv):
create or replace view report_purchase_order_product as (
select
min(l.id) as id,
substring(s.date_order for 7)||'-'||'01' as name,
to_char(s.date_order, 'YYYY-MM-01') as name,
s.state,
l.product_id,
sum(l.product_qty*u.factor) as quantity,
@ -71,7 +71,7 @@ class report_purchase_order_product(osv.osv):
from purchase_order s
left join purchase_order_line l on (s.id=l.order_id)
left join product_uom u on (u.id=l.product_uom)
group by l.product_id, substring(s.date_order for 7),s.state
group by l.product_id, to_char(s.date_order, 'YYYY-MM-01'),s.state
)
""")
report_purchase_order_product()
@ -104,7 +104,7 @@ class report_purchase_order_category(osv.osv):
create or replace view report_purchase_order_category as (
select
min(l.id) as id,
substring(s.date_order for 7)||'-'||'01' as name,
to_char(s.date_order, 'YYYY-MM-01') as name,
s.state,
t.categ_id as category_id,
sum(l.product_qty*u.factor) as quantity,
@ -116,7 +116,7 @@ class report_purchase_order_category(osv.osv):
left join product_product p on (p.id=l.product_id)
left join product_template t on (t.id=p.product_tmpl_id)
left join product_uom u on (u.id=l.product_uom)
group by t.categ_id, substring(s.date_order for 7),s.state
group by t.categ_id, to_char(s.date_order, 'YYYY-MM-01'),s.state
)
""")
report_purchase_order_category()

View File

@ -57,7 +57,7 @@ class report_sale_order_product(osv.osv):
create or replace view report_sale_order_product as (
select
min(l.id) as id,
substring(s.date_order for 7)||'-'||'01' as name,
to_char(s.date_order, 'YYYY-MM-01') as name,
s.state,
l.product_id,
sum(l.product_uom_qty*u.factor) as quantity,
@ -67,7 +67,7 @@ class report_sale_order_product(osv.osv):
from sale_order s
right join sale_order_line l on (s.id=l.order_id)
left join product_uom u on (u.id=l.product_uom)
group by l.product_id, substring(s.date_order for 7),s.state
group by l.product_id, to_char(s.date_order, 'YYYY-MM-01'),s.state
)
""")
# Done in the _auto_init
@ -109,7 +109,7 @@ class report_sale_order_category(osv.osv):
create or replace view report_sale_order_category as (
select
min(l.id) as id,
substring(s.date_order for 7)||'-'||'01' as name,
to_char(s.date_order, 'YYYY-MM-01') as name,
s.state,
t.categ_id as category_id,
sum(l.product_uom_qty*u.factor) as quantity,
@ -121,7 +121,7 @@ class report_sale_order_category(osv.osv):
left join product_product p on (p.id=l.product_id)
left join product_template t on (t.id=p.product_tmpl_id)
left join product_uom u on (u.id=l.product_uom)
group by t.categ_id, substring(s.date_order for 7),s.state
group by t.categ_id, to_char(s.date_order, 'YYYY-MM-01'),s.state
)
""")
report_sale_order_category()

View File

@ -74,14 +74,14 @@ class report_timesheet_account(osv.osv):
create or replace view report_timesheet_account as (
select
min(id) as id,
substring(create_date for 7)||'-01' as name,
to_char(create_date, 'YYYY-MM-01') as name,
user_id,
account_id,
sum(unit_amount) as quantity
from
account_analytic_line
group by
substring(create_date for 7), user_id, account_id
to_char(create_date, 'YYYY-MM-01'), user_id, account_id
)
""")
report_timesheet_account()