Odoo Help

Welcome!

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.

0

How to add extra field in users (like notify_email) and show in User Preferences then make it WRITEABLE_FIELDS for all user??

By
Amit Kumar
on 5/30/16, 6:34 AM 245 views

Here is my code :

I have added to two fields in res.users and shown in User Preferences view but still these fields are readonly. How to make these fields WRITEABLE_FIELDS for all users??

#####Python Code#######

class res_users(models.Model):

    _inherit = 'res.users'

    notify_sms = fields.Boolean(string='Receive Notification by SMS')

    mob_number = fields.Char(string="Mobile Number")

     def __init__(self, pool, cr):

            """ Override of __init__ to add access rights on notification_email_send and alias fields. Access rights are disabled by                      default, but allowed  on some specific fields defined in self.SELF_{READ/WRITE}ABLE_FIELDS."""

            init_res = super(res_users, self).__init__(pool, cr)

            self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)

            self.SELF_WRITEABLE_FIELDS.extend(['notify_sms',"mob_number"])

            return init_res

######XML#####

<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<record id="add_to_user_preferences" model="ir.ui.view">

<field name="name">Inhetitance In Preference</field>

<field name="model">res.users</field>

<field name="inherit_id" ref="base.view_users_form"/>

<field name="arch" type="xml">

<xpath expr="//page/group/field[@name='signature']" position="before">

<field name="notify_sms"/>

<field name="mob_number" class="oe_inline" placeholder="e.g. +919898989898" attrs="{'invisible': [('notify_sms', '=', False)]}"/>

</xpath>

</field>

</record>

<record id="add_to_user_preferences2" model="ir.ui.view">

<field name="name">Inhetitance In Preference2</field>

<field name="model">res.users</field>

<field name="inherit_id" ref="base.view_users_form_simple_modif"/>

<field name="arch" type="xml">

<xpath expr="/form/group[@name='preferences']" position="after">

<group string="SMS Preferences" col='4'>

<field name="notify_sms"/>

<field name="mob_number" placeholder="e.g. +919898989898" attrs="{'invisible': [('notify_sms', '=', False)]}"/>

</group>

</xpath>

</field>

</record>

</data>

</openerp>


Please suggest me the solution.

Thanks in advance 

1
Sarga
On 11/9/16, 10:00 AM

Hi,

Just include readonly="0" for the new fields in user preference xml file

Like <field name="notify_sms" readonly="0"/>

In my case it worked. Hope this would help u :)

thanks sarga

Amit Kumar
on 11/17/16, 12:29 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

2 follower(s)

Stats

Asked: 5/30/16, 6:34 AM
Seen: 245 times
Last updated: 11/17/16, 12:29 PM