本文整理汇总了Python中openerp.tools.drop_view_if_exists方法的典型用法代码示例。如果您正苦于以下问题:Python tools.drop_view_if_exists方法的具体用法?Python tools.drop_view_if_exists怎么用?Python tools.drop_view_if_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openerp.tools
的用法示例。
在下文中一共展示了tools.drop_view_if_exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
"""
???
"""
tools.drop_view_if_exists(cr, 'stock_day_line_report')
cr.execute("""
create or replace view stock_day_line_report as (
select
min(q.id) as id,
q.close as close,
to_char(q.date, 'YYYY-mm-dd') as date,
q.stock_id as stock_id
from
stock_basics_day_line q
where q.date > '2015-10-05'
group by
q.close,
q.date,
q.stock_id
)""")
示例2: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
# select other_money_order_line?other_money_order
tools.drop_view_if_exists(cr, 'other_money_statements_report')
cr.execute("""
CREATE or REPLACE VIEW other_money_statements_report AS (
SELECT omol.id,
omo.date,
omo.name,
(CASE WHEN omo.type = 'other_get' THEN '????' ELSE '????' END) AS type,
omol.category_id,
(CASE WHEN omo.type = 'other_get' THEN omol.amount ELSE 0 END) AS get,
(CASE WHEN omo.type = 'other_pay' THEN omol.amount ELSE 0 END) AS pay,
omo.partner_id,
omol.note
FROM other_money_order_line AS omol
LEFT JOIN other_money_order AS omo ON omol.other_money_id = omo.id
ORDER BY date)
""")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
示例3: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (
%s
FROM %s%s%s
)""" % (self._table, self._select(), self._from(), self._where(), self._group_by()))
示例4: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (
select id, id as partner_id, customer, supplier, user_id
from res_partner
)""" % (self._table, ))
示例5: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
try:
with cr.savepoint():
cr.execute("CREATE EXTENSION tablefunc")
except psycopg2.Error:
pass
# View
tools.drop_view_if_exists(cr, self._table)
_sql = """
select aml.id, aml.id as move_line_id,
aml.date_maturity, aml.date, aml.partner_id,
aa.type account_type, new_title,
case when letter.l1 is not null then true else false end as l1,
letter.l1 l1_date,
case when letter.l2 is not null then true else false end as l2,
letter.l2 l2_date,
case when letter.l3 is not null then true else false end as l3,
letter.l3 l3_date
from account_move_line aml
join account_account aa on aa.id = aml.account_id
join res_partner rp on rp.id = aml.partner_id
left outer join pabi_dunning_config_title pdct
on rp.title = pdct.title_id
-- Crosstab table
left outer join (
select move_line_id, l1, l2, l3
from crosstab('
select move_line_id, letter_type, date_run
from pabi_partner_dunning_letter_line order by 1, 2
') AS final_result(
move_line_id integer, l1 date, l2 date, l3 date)
)as letter on letter.move_line_id = aml.id
where aml.state = 'valid' and aa.type in ('receivable', 'payable')
and aml.date_maturity is not null
and aml.partner_id is not null
"""
cr.execute("""CREATE or REPLACE VIEW %s as (%s)""" %
(self._table, _sql,))
示例6: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (
SELECT
pp.name_template AS product_name,
po.name AS po_name,
pol.price_unit AS pol_price,
prql.price_unit AS pr_price,
po.date_order,
trim(concat(rp.title,' ',rp.name)) AS partner_name,
rcp.name AS province,
extract(year from age(aaa.warranty_expire_date,
aaa.warranty_start_date))*12 +
extract(month from age(aaa.warranty_expire_date,
aaa.warranty_start_date)) AS warranty,
aaa.name AS note,
sm.name AS description
FROM
account_asset aaa
LEFT JOIN product_product pp ON pp.id = aaa.product_id
LEFT JOIN stock_move sm ON sm.id = aaa.move_id
LEFT JOIN stock_picking sp ON sp.id = sm.picking_id
LEFT JOIN purchase_order po ON po.name = sp.origin
LEFT JOIN res_partner rp ON rp.id = po.partner_id
LEFT JOIN res_country_province rcp ON rcp.id = rp.province_id
LEFT JOIN purchase_order_line pol ON pol.order_id = po.id
LEFT JOIN purchase_requisition_line prl
ON pol.requisition_line_id = prl.id
LEFT JOIN purchase_request_purchase_requisition_line_rel prprl
ON prl.id = purchase_requisition_line_id
LEFT JOIN purchase_request_line prql
ON prprl.purchase_request_line_id = prql.id
WHERE po.order_type = 'purchase_order'
and prl.is_standard_asset != True
ORDER BY po.name, pol.id
)""" % (self._table, ))
示例7: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (
select
wa.id,
rp.search_key as partner_code,
concat(rpt.name,' ',rp.name) as partner_name,
po.name as po_no,
wa.name as wa_no,
wa.date_contract_end,
wa.date_receive,
wa.eval_service,
wa.eval_quality,
wa.eval_receiving,
case
when (-1 * DATE_PART('day', wa.date_contract_end ::timestamp -
wa.date_receive::timestamp)) > 0
then
-1 * DATE_PART('day', wa.date_contract_end ::timestamp -
wa.date_receive::timestamp)
else
0
end
as delay_day
from purchase_work_acceptance wa
left join purchase_order po on po.id = wa.order_id
left join res_partner rp on rp.id = po. partner_id
left join res_partner_title rpt on rpt.id = rp.title
)""" % (self._table, ))
示例8: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (
SELECT
to_char(pd.create_date,'YYYY') year_name,
ou.name ou_name,
pm.name method,
COUNT(pd.id) pd_count,
SUM(pd.amount_total) amount_total,
rc.name currency,
(SELECT af.id FROM account_fiscalyear af
WHERE af.name = to_char(pd.create_date,'YYYY')) fiscalyear_id
FROM purchase_requisition pd
LEFT JOIN operating_unit ou
ON ou.id = pd.operating_unit_id
LEFT JOIN purchase_method pm
ON pm.id = pd.purchase_method_id
LEFT JOIN res_currency rc
ON rc.id = pd.currency_id
WHERE pd.purchase_method_id IS NOT NULL
GROUP BY ou.id,
pm.name,
rc.name,
to_char(pd.create_date,'YYYY'),
(SELECT af.id FROM account_fiscalyear af
WHERE af.name = to_char(pd.create_date,'YYYY'))
ORDER BY ou.id
)""" % (self._table, ))
示例9: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (
SELECT
pp.name_template AS product_name,
po.name AS po_name,
pol.price_unit AS pol_price,
prql.price_unit AS pr_price,
po.date_order,
trim(concat(rp.title,' ',rp.name)) AS partner_name,
rcp.name AS province,
extract(year from age(aaa.warranty_expire_date,
aaa.warranty_start_date))*12 +
extract(month from age(aaa.warranty_expire_date,
aaa.warranty_start_date)) AS warranty,
aaa.name AS note,
sm.name AS description
FROM
account_asset aaa
LEFT JOIN product_product pp ON pp.id = aaa.product_id
LEFT JOIN stock_move sm ON sm.id = aaa.move_id
LEFT JOIN stock_picking sp ON sp.id = sm.picking_id
LEFT JOIN purchase_order po ON po.name = sp.origin
LEFT JOIN res_partner rp ON rp.id = po.partner_id
LEFT JOIN res_country_province rcp ON rcp.id = rp.province_id
LEFT JOIN purchase_order_line pol ON pol.order_id = po.id
LEFT JOIN purchase_requisition_line prl
ON pol.requisition_line_id = prl.id
LEFT JOIN purchase_request_purchase_requisition_line_rel prprl
ON prl.id = purchase_requisition_line_id
LEFT JOIN purchase_request_line prql
ON prprl.purchase_request_line_id = prql.id
WHERE po.order_type = 'purchase_order'
and prl.is_standard_asset = True
ORDER BY po.name, pol.id
)""" % (self._table, ))
示例10: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (
SELECT string_agg(po.id::varchar,',') po_id,
pd.name as pd_number,
CONCAT((SELECT pt.name FROM purchase_type pt WHERE
pt.id = pd.purchase_type_id),' ',pd.objective) objective,
(SELECT COUNT(*) FROM purchase_requisition_line pdl
WHERE pdl.requisition_id = pd.id) qty,
pd.amount_total,
pm.name as method,
(SELECT CONCAT(COALESCE(rpt.name || ' ',''),rp.name)
FROM res_partner rp
LEFT JOIN res_partner_title rpt
ON rpt.id = rp.title
WHERE rp.id = selected_po.partner_id) as rfq_supplier,
selected_po.amount_total as rfq_amount_total,
(SELECT psr.name FROM purchase_order rfq
LEFT JOIN purchase_select_reason psr ON psr.id = rfq.select_reason
WHERE rfq.order_type = 'quotation' AND
rfq.order_id = selected_po.id) reason,
pd.create_date::date
FROM purchase_requisition pd
LEFT JOIN operating_unit ou
ON ou.id = pd.operating_unit_id
LEFT JOIN purchase_method pm
ON pm.id = pd.purchase_method_id
LEFT JOIN purchase_price_range ppr
ON ppr.id = pd.purchase_price_range_id
LEFT JOIN purchase_order po
ON po.requisition_id = pd.id AND po.order_type = 'quotation'
LEFT join purchase_order selected_po
ON selected_po.requisition_id = pd.id AND
selected_po.order_type LIKE 'purchase_order' AND
selected_po.state NOT LIKE 'cancel'
WHERE pd.state = 'done'
GROUP BY pd.id, pd.name, pd.objective, pd.amount_total, pm.name,
selected_po.partner_id, selected_po.amount_total,
selected_po.id
)""" % (self._table, ))
示例11: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
_sql = """
select min(id) as id, asset_id, fiscalyear_id,
sum(amount) as amount_depreciate
from account_asset_line a
where type = 'depreciate' and fiscalyear_id is not null
group by asset_id, fiscalyear_id
"""
tools.drop_view_if_exists(cr, self._table)
cr.execute(
"""CREATE or REPLACE VIEW %s as (%s)""" %
(self._table, _sql,))
示例12: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (%s)""" %
(self._table, self._get_sql_view(),))
示例13: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
tools.drop_view_if_exists(cr, self._table)
_sql = """
select * from (
(select 1 seq, 'sc:' as type, 'res.section' as model,
id+1000000 as id, id as res_id, code, name, name_short, costcenter_id
from res_section where active=true)
union all
(select 2 seq, 'pj:' as type, 'res.project' as model,
id+2000000 as id, id as res_id, code, name, name_short, costcenter_id
from res_project where active=true)
union all
(select 3 seq, 'cp:' as type, 'res.invest.construction.phase' as model,
p.id+3000000 as id, p.id as res_id, p.code, c.name as name,
phase as name_short, costcenter_id
from res_invest_construction_phase p join res_invest_construction c on
c.id = p.invest_construction_id where p.active=true)
union all
(select 4 seq, 'ia:' as type, 'res.invest.asset' as model,
id+4000000 as id, id as res_id, code, name, name_short, costcenter_id
from res_invest_asset where active=true)
union all
(select 5 seq, 'pc:' as type, 'res.personnel.costcenter' as model,
id+5000000 as id, id as res_id, code, name, name_short, costcenter_id
from res_personnel_costcenter where active=true)
) a
"""
cr.execute("""CREATE or REPLACE VIEW %s as (%s)""" %
(self._table, _sql,))
示例14: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
_sql = """
select min(id) as id, invest_construction_phase_id as phase_id,
fiscalyear_id, sum(amount_plan) as amount_plan
from res_invest_construction_phase_plan
group by invest_construction_phase_id, fiscalyear_id
"""
tools.drop_view_if_exists(cr, self._table)
cr.execute(
"""CREATE or REPLACE VIEW %s as (%s)""" %
(self._table, _sql,))
示例15: init
# 需要导入模块: from openerp import tools [as 别名]
# 或者: from openerp.tools import drop_view_if_exists [as 别名]
def init(self, cr):
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (
select min(l.id) id, budget_id, activity_group_id, l.budget_method,
sum(m1) m1, sum(m2) m2, sum(m3) m3, sum(m4) m4,
sum(m5) m5, sum(m6) m6, sum(m7) m7, sum(m8) m8, sum(m9) m9,
sum(m10) m10, sum(m11) m11, sum(m12) m12
from account_budget_line l
group by budget_id, activity_group_id, l.budget_method
)""" % (self._table, ))