跳至內容
選單
此問題已被標幟
1 回覆
2289 瀏覽次數

Hi all, 

I am newbie so excuse me for my mistakes 

i want to create a custom postgresql view when i install my custom view 

i use a code like : 

@api.model_cr
def init(self):
tools.drop_view_if_exists(self._cr, 'report_sql_test') 
self._cr.execute("""CREATE or REPLACE VIEW report_sql_test ​AS (SELECT MIN(id) as id, product_id as product_id From table1) """)

i got the error model_cr not recognized even if a used 

from openerp import api, fields, models,tools
please help me on how can i do it 
Many thanks 

  


頭像
捨棄
最佳答案

Hi

  if you are using version 9,try this

def init(self, cr):
"""Initialize the sql view """
tools.drop_view_if_exists(cr, 'view_name')
cr.execute(""" CREATE VIEW view_name AS (
)
""")

                                                                                          

頭像
捨棄