Community: Framework mailing list archives

expert-framework@mail.odoo.com

RE: fields_view_get issue

by
Christian
- 09/14/2016 04:20:03

Hi Jean-Paul,

    The view ID’s are correct.

 

When I look at the print, I got the following results:

 

Il context

None

search

480

2016-09-14 10:15:17,489 13632 INFO bellinitest werkzeug: 127.0.0.1 - - [14/Sep/2016 10:15:17] "POST /web/action/load HTTP/1.1" 200 -

Il context

2

search

480

2016-09-14 10:15:17,805 13632 INFO bellinitest werkzeug: 127.0.0.1 - - [14/Sep/2016 10:15:17] "POST /web/dataset/call_kw/sale.order/fields_view_get HTTP/1.1" 200 -

Il context

2

tree

512

Order Tree

 

The first time it calls a search view (for some reason, one time without context, then with it), then it gets the tree form. The ID 512 is the correct one.

 

So, if I understand correctly, I should pass the correct view ID in the parent call?

 

Kind Regards / Met vriendelijke groet,

Christian Valsecchi
Mobile +31 627565200

 

From: Jean-Paul Robineau [mailto:jprobineau@yahoo.com]
Sent: Wednesday, September 14, 2016 9:36 AM
To: Community: Framework <expert-framework@mail.odoo.com>
Subject: Re: fields_view_get issue

 

Christian,

 

In the fields view get (parent) he will try to get the view by the id, and then take 'arch', Nonetype means there its empty

 

My idea is that the id you pass is incorrect and he can't find it. Are you sure it is the right ID? (the id from ir.ui.view model?)

 

Maybe its safer to get the id by a search on ir.ui.view with the right criteria. By that you are sure about the ID and also if for some reason later on you migrate to another version and you get an other ID you are safe there aswell.

 

 

Get a look at addons/openerp/models.py in def fields_view_get.

 

You can see if there is a view_id passed, he will try to read it. And when he doesn't find it he will give you the error you have.

 

 

 

Kind regards

Jean-Paul Robineau

Lead Developer

Apertoso NV

Deinze, Belgium

 

 

On Wednesday, September 14, 2016 9:15 AM, Christian Valsecchi <christian.valsecchi@outlook.com> wrote:



Hi Jean-Paul,

   Indeed I tried to get the super first and then replace the arch, but then the view wasn’t working. So I tried creating a new view and call the correct view depending on the context.

See the code below.

 

 

From the menu, first a tree view is called, then the form view. The error appear on the tree view.

 

 

    @api.model

    def fields_view_get(self, view_id=None, view_type=None, context=None, toolbar=False, submenu=False):

         

        context = self._context.get('show')

        

        print('Il context')

        print(context)

        print(view_type)

        print(view_id)

   

        if context == 2 and view_type == 'form':

            print('Order form')

            view_id = 593

            res = super(SaleOrder, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=False)

        elif context == 1 and view_type == 'form':

            print('Offerta Form')

            view_id = 511              

            res = super(SaleOrder, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=False)

        elif context == 1 and view_type == 'tree':   

            print('Offerta Tree')

            res = super(SaleOrder, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=False)       

        elif context == 2 and view_type == 'tree':   

            print('Order Tree')

            res = super(SaleOrder, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=False)

 

 

thanks

Kind Regards / Met vriendelijke groet,

Christian Valsecchi
Mobile +31 627565200

 

From: Jean-Paul Robineau [mailto:jprobineau@yahoo.com]
Sent: Wednesday, September 14, 2016 7:43 AM
To: Community: Framework <expert-framework@mail.odoo.com>
Subject: Re: fields_view_get issue

 

Dear Christian,

 

Its a bit difficult to say what is wrong without seeing your code. But i pressume you didn't called a super first. For Fields view get you better call the super first, and then you adapt the res['arch'] and return the res.

 

If this didn't work can you please send a bit of the code so we can see what happend?

 

Kind regards, Met vriendelijke groeten

 

Jean-Paul Robineau

Lead Developer

Apertoso NV

Deinze, Belgium

 

On Tuesday, September 13, 2016 5:32 PM, Christian Valsecchi <christian.valsecchi@outlook.com> wrote:



Hi there,

    I’m trying the fields_view_get override to use different views depending on different context.

 

I keep having this error: Uncaught TypeError: Cannot read property 'arch' of undefined.

Does someone have some ideas on how to fix it? I’m quite lost.

 

Thanks

 

Kind Regards / Met vriendelijke groet,

Christian Valsecchi
IT Manager & Consultant - Technology

 

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe



_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe



_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe