Hi all,
Thanks in advance for your answers.
I created a class with a model with fields
like :
class odoo_model(models.Model):
_name = 'sql_model'
_description = 'values from database'
field1 = fields.Char(string="sql value", required=True, )
i created also a database view with the same fields
like :
create view sql_values as
select field1 from table1
i want to update my odoo class model with values on my database view
how can i do that ?
please give me also a sample
Thanks a lot.
Hi Vishnu,
i am using odoo version 9
i got error that modul dont have attribute _cr
for the init
@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) """)
You didn't mentioned the Version first time so i updated the 12 code. Now check the answer i have updated.
Watch: https://www.youtube.com/watch?v=_KIsGo4sttQ