last day (14 days later) » 

11:57 AM
0
A: Pivot in custom module odoo 9

Emipro Technologies Pvt. Ltd.You need to manage one api on above of the init as like below. @api.model_cr def init(self): print(self) tools.drop_view_if_exists(self._cr, self._table) self._cr.execute(""" CREATE view %s as %s FROM my_table pn ...

 
Hello, after add @api.model_cr before init get error AttributeError: 'module' object has no attribute 'model_cr'
When put api.model get erro return old_api(self, *args, **kwargs) TypeError: old_api() takes at least 3 arguments (2 given)
 
Make sure api must be there in import statement, fields, models, api all those three must be there.
 
On the top I have from openerp import tools, api, osv, fields, models, _
 
Please have a look inside updated answer.
 
With old api ProgrammingError: syntax error at or near "FROM" LINE 7: FROM my_table pn ^
 
11:57 AM
Please do the small changes inside "init" method as updated inside answer for OLD api.
ok.
 
Ok, I will try now
 
Table "putni_nalog_nvo" exist in my database I don't know where is problem
 
Write down directly as like below inside execute.
cr.execute(".......SELECT pn.name, pn.date, pn.user_id from putni_nalog_nvo pn group by pn.name")
"CREATE or REPLACE VIEW report_my_module_user as select pn.name, pn.date, pn.user_id from putni_nalog_nvo pn group by pn.name"

Put this inside execute
 
ok
ProgrammingError: relation "report_project_nvo_user" does not exist
LINE 3: FROM "report_project_nvo_user"
I will print screan full code
.py file --> imgur.com/a/XJIxN
.xml file --> imgur.com/a/yJPPJ
Sorry my mistake I'm update cr.execute to:
cr.execute("CREATE or REPLACE VIEW report_project_nvo_user as SELECT pn.name, pn.datum, pn.radnik_id from putni_nalog_nvo pn group by pn.id") #% (self._select(), self._group_by())
 
12:30 PM
cr.execute("CREATE or REPLACE VIEW report_project_nvo_user as select pn.name, pn.datum, pn.randik_id from putni_nalog_nvo pn group by pn.id")
Write down as like this.
yes, that was I want to tell you for creating view.
Is it working ?
 
Not working again :(
 
cr.execute("CREATE or REPLACE VIEW report_project_nvo_user as select min(pn.id) as id, pn.name, pn.datum, pn.randik_id from putni_nalog_nvo pn group by pn.id")
You need to give id column inside the select query...
Otherwise it is going to take from the model and currently model is not there...
Just change inside query.
 
Tnx for help, finally small pivot view is open, Now I will add other field
 
Tnx men a lot of....
My respect... +1
Send me your email I will buy a caffe over paypal!!!
 

last day (14 days later) »