Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


How do I view 1 single object in Form view only? [Closed]

Gavin Yap
on 8/5/15, 2:37 AM 534 views



Supposedly  if I have the following window action.

<record model="ir.actions.act_window" id="action_profile">
<field name="name">My Profile</field>
<field name="res_model">res.partner</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>

When a portal user logins, the portal user will only see the res.partner record  that is associate with the user account that was login to.

Now I want to have a Form view only,  so I remove the tree view from view_type..

<record model="ir.actions.act_window" id="action_profile">
<field name="name">My Profile</field>
<field name="res_model">res.partner</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>

Inside of display in the form view, it show a empty record.

To simplify, how do I view 1 selected record of an object in form view only.

Sorry i couldnt get you Gavin Yap

on 8/5/15, 3:16 AM

I rephrase my questions and title. In short, how do I view 1 selected record in form view only?

Gavin Yap
on 8/5/15, 5:06 AM

Give me your XML code

Drees Far
on 8/5/15, 5:47 AM

Drees Far, what xml code u need?

Gavin Yap
on 8/5/15, 8:02 AM

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 8/5/15, 6:15 AM

Try to use server action, to call your desired partner_id record to it.


        <record id="ir_actions_server_portal_res_partner" model="ir.actions.server">
            <field name="sequence" eval="5"/>
            <field name="state">code</field>
            <field name="type">ir.actions.server</field>
            <field name="model_id" ref="model_res_partner"/>
            <field name="code">action = self.open_address(cr, uid, None, context)</field>
            <field name="condition">True</field>
            <field name="name">My Addresses</field>
        <menuitem id="addresses_menu" name="Addresses" parent="portal.portal_orders" sequence="0"

In PY:

 class Partner(orm.Model):
    _inherit = 'res.partner'

    def open_address(self, cr, uid, ids, context=None):
        ir_model_data = self.pool.get('ir.model.data')
        if context is None:
            context = {}

        user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
        partner = user.partner_id
            view_form_id = ir_model_data.get_object_reference(
                cr, uid, 'base', 'view_partner_form')[1]
        except ValueError:
            view_form_id = False

        return {
            'name': _('Open Addresses'),
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'res.partner',
            'view_id': view_form_id,
            'res_id': partner.id,
            'type': 'ir.actions.act_window'

Thanks Atchuthan, although I have not tried the above code yet because am V8 user. Your code is helpful and make sense to me. Cheers.

Gavin Yap
on 8/5/15, 8:03 AM

Thanks again. I confirmed this solution works.

Gavin Yap
on 8/13/15, 10:58 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)


Asked: 8/5/15, 2:37 AM
Seen: 534 times
Last updated: 8/13/15, 10:58 PM