Skip to Content
Menu
This question has been flagged
1 Reply
1958 Views

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 

  


Avatar
Discard
Best Answer

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 (
)
""")

                                                                                          

Avatar
Discard