Skip to Content
Menu
This question has been flagged
1 Reply
3470 Views

Hi, i'm newbie in using of Odoo and i understood that in version 9 of Odoo, massive changes applied to this and concurrently don't generated any documentation for this.

I try to add a checkbox on the settings > users > an user > preferences part below of language, all code ran correct and no exception raise but, no any element adding below language. and in debug menu > Fields View Get i see that my field not added.

i show related parts of my module for you

_openerp_.py:

# -*- coding: utf-8 -*-

{

    'name': "JalaliDateView",

    'summary': """Show dates and date-picker as Jalali date""",

    'description': "Show dates and date-picker as Jalali date",

    'author': "Mohsen Javidpanah",

    'website': "http://www.xyz.ir",

    'category': 'Uncategorized',

    'version': '0.1',

    'depends': ['base', 'web'],

    'data': [

        'security/ir.model.access.csv',

        'views/views.xml',

        'views/templates.xml',

        'views/user_profile.xml',

    ],

    'demo': [

        'demo/demo.xml',

    ],

}


__init__.py:

from . import models, user_profile


user_profile.py:

from openerp import models, fields

import werkzeug.local

_request_stack = werkzeug.local.LocalStack()

request = _request_stack()

class res_users(models.Model):

     _inherit = "res.users"

    _name = "jdv.users"

    context_jdv = fields.Boolean(string='Show calendar as Jalali?', help="Using jalali calendar throughout views.")

    _defaults = {

        'context_jdv': True,

    }

res_users()


userprofile.xml:

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

<openerp>

     <data>

        <record model="ir.rule" id="ir_values_jdv_users_rule">

             <field name="name">Jalali Date view Users Rules</field>

             <field name="model_id" ref="model_jdv_users"/>

             <field name="domain_force">[('field','operator','value'),('user_id','=',user.id)]</field>

             <field name="perm_read" eval="True"/>

             <field name="perm_write" eval="True"/>

             <field name="perm_unlink" eval="True"/>

            <field name="perm_create" eval="True"/>

        </record>

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

            <field name="name">res.users.preferences.form.jdv</field>

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

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

            <field name="priority" eval="120"></field>

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

               <data>

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

                       <field name="context_jdv" string="Show Jalali Calculator?" readonly="0"/>

                   </xpath>

               </data>

           </field>

        </record>

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

            <field name="name">res.users.preferences.form.jdv</field>

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

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

            <field name="priority" eval="220"></field>

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

                <data>

                    <xpath expr='//field[@name="lang"]' position="after">

                        <field name="context_jdv" string="Show Jalali Calculator?" readonly="0"/>

                    </xpath>

               </data>

            </field>

        </record>

    </data>

</openerp>

Avatar
Discard
Best Answer

Hello,

If you'd like to add a new filed to the res.user in the original model; I think you don't need to add 

_name = "jdv.users"

So try to remove it from the 

user_profile.py & your views

also use res.users instead of jdv.users in the xml views:

<field name="model">jdv.users</field>
to be 

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

Hope this will helps




Avatar
Discard
Related Posts Replies Views Activity
1
Jul 19
6809
1
Nov 20
3141
0
Jun 20
5467
0
Dec 24
37
0
Jul 24
186