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 a tab to the customer's notebook

By
Quentin
on 7/3/13, 7:56 AM 3,649 views

I developed a module and I would like add an item menu on the left and a tab to the customer's notebook.

For the menu on the left, I didn't try to find how to add this but I will see later (it's easier). For my tab I added a new view but it's not working (in comment inside my view.xml).

Could you help me.

This is my code :

my "password.py" :

from osv import osv
from osv import fields
class password(osv.osv):
 "'password Class"'

    _name='password'
    _columns=
    {
            'name':fiels.char("Name",size=128),
            'user':fields.char("Username",size=128),
            'host':fields.char("IP/HostName",size=128),
            'pass':fields.char("Password",size=128),
            'com':fields.char("Comment",size=128),            
    }
password()

my "password_view.xml ":

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

<openerp>
    <data>

        <record id="password_tree_view" model="ir.ui.view">
            <field name="name">password.tree</field>
                <field name="model">password</field>
                <field name="arch" type="xml">
                    <tree string="Password Tree">
                        <field name="name"/>
                <field name="user"/>
                        <field name="host"/>
                        <field name="pass"/>
                        <field name="com"/>
                    </tree>
                </field>
        </record>

        <record id="password_form_view" model="ir.ui.view">
            <field name="name">password.form</field>
                <field name="model">password</field>
                <field name="arch" type="xml">
                    <form string="Password Form">
                            <field name="name"/><field name="user"/>
                            <field name="host"/><field name="pass"/>
                            <field name="com"/>
                    </form>
                </field>
        </record>

        <!--<record id="password_partner_view" model="ir.ui.view">
            <field name="name">password.partner</field>
                <field name="inherit_id" ref="base.view_partner_form"/>
                <field name="model">view.partner</field>
                <field name="arch" type="xml">    
                    <xpath expr="//page[@string='Sales & Purchases']" position="after">
                        <field name="password"/>
                    </xpath>
                </field>
        </record>-->

        <record id="password_action" model="ir.actions.act_window">
            <field name="name">password</field>
            <field name="res_model">password</field>
            <field name="view_type">tree</field>
            <field name="view_mode">tree,form</field>
        </record>

    </data>
</openerp>

my __init__.py :

import password

and my __openerp__.py :

{
    'name': 'Password module',
    'version': '1.0',
    'category': 'Partner/Customer Management',
    'description': """""",
    'author': '',
    'website': '',
    'depends': ['base'],
    'data': ['password/password_view.xml'],

    'installable': True,
    'auto_install': False,
    'application': False,
}
2

Ghanshyam Prajapati

--Ghanshyam Prajapati--
1377
| 4 4 8
Pune, India
--Ghanshyam Prajapati--
OpenERP Developer
Ghanshyam Prajapati
On 7/3/13, 8:08 AM

Hi, Try Following, In your PY, class password(osv.osv): "'password Class"'

    _name='password'
    _inherit = "res.partner"

In your XML,

<record id="password_form_view" model="ir.ui.view">
    <field name="name">password.form</field>
        <field name="model">password</field>
        <field name="arch" type="xml">
        <field name="inherit_id" ref="base.view_partner_form" />                
                  <notebook position="inside">
                       <page string="Customer Notebook">
                       </page>
                       <page string = "Password Form">
                            <field name="name"/>
                            <field name="user"/>
                            <field name="host"/>
                            <field name="pass"/>
                            <field name="com"/>
                       </page>
                  </notebook>                            
            </form>
        </field>
</record>

Hope it work for you.

It doesn't work... "ValidateError Error occurred while validating the field(s) arch: Invalid XML for View Architecture!" I added <form string="Password Form"> before <notebook position="inside"> but It doesn't still work !

Quentin
on 7/3/13, 9:09 AM

Dear Quentin, You better edit the view file like: <code> <openerp> </data> <record id="view_partner_inherited_form" model="ir.ui.view"> <field name="name">partner.passwd</field> <field name="model">res.partner</field> <field name="type">form</field> <field name="inherit_id" ref="base.view_partner_form"/> <field name="arch" type="xml"> <notebook position="inside"> <page string="Password Form"> <field name="YOUR FIELDS" nolabel="1"/> </code>

and close each tag, appropriately..

GuruDev
on 7/3/13, 9:23 AM

Thank you for your help Ghanshyam Prajapati !

Quentin
on 7/3/13, 9:28 AM

Hi Quentin, If your problem is solved then please mark my answer as solved. Thanks.

Ghanshyam Prajapati
on 7/3/13, 9:33 AM

It's not still solved, but don't worry, I will if it solved !

Quentin
on 7/3/13, 11:41 AM

I have to replace my former form view or add this code as new view?

Quentin
on 7/3/13, 11:46 AM

Guys, did it work for you? because I can't fix it, I don't know why !

Quentin
on 7/3/13, 1:34 PM
1
GuruDev
On 7/3/13, 8:14 AM

Hi Quentin, I think, you need to inherit the

res.partner model into your password.py file. Then, __name field is not required.

I did but I saved _name

Quentin
on 7/3/13, 12:01 PM
0
Quentin
On 7/5/13, 6:22 AM

So this is my new password_view.xml and password.py. Some errors are not fixed but I'm on the right way :

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

<openerp>
    <data>

        <record id="view_password_form" model="ir.ui.view">
            <field name="name">Password Form</field>
                <field name="model">password.table</field>
                <field name="arch" type="xml">
                    <form string="Password Form">
                        <field name="name_pid"/>
                        <field name="user_pid"/>
                        <field name="host_pid"/>
                        <field name="pass_pid" password='True'/>
                        <field name="com_pid"/>
                    </form>
                </field>
        </record>

        <record id="view_password_tree" model="ir.ui.view">
            <field name="name">Password Tree</field>
                <field name="model">password.table</field>
                <field name="arch" type="xml">
                    <tree string="Password Tree">
                        <field name="name_pid"/>
                        <field name="host_pid"/>
                <field name="user_pid"/>
                        <field name="pass_pid" password='True'/>
                        <field name="com_pid"/>
                    </tree>
            </field>
        </record>

       <record id="view_password_partner_form" model="ir.ui.view">
            <field name="name">Password Partner Form</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//page[@string='Sales & Purchases']" position="after">
                        <page string="Password">
                        </page>
                    </xpath>
                    <xpath expr="//page[@string='Password']" position="inside">
                        <field name="passwords">
                        </field>
                    </xpath>
                </data>
            </field>
        </record>

        <record id="action_password" model="ir.actions.act_window">
            <field name="name">Password</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">password.table</field>
            <field name="view_type">form</field>
            <field name="view_mode">form,tree</field>
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                Click to save a new login.
              </p><p>
                OpenERP will save this login for you: Hostname, Username, Password.
              </p>
            </field>
        </record>

        <menuitem action="action_password" id="action_menu_password" parent="base.menu_sales" name="Password"/>

    </data>
</openerp>

...

from openerp.osv import osv, fields

class password(osv.osv):

    _inherit = 'res.partner'

    _columns = {
        'passwords': fields.one2many('password.table')

   }
password()

class password_table(osv.osv):
    _name="password.table"

    _columns = {
            'name_pid':fields.many2one('res.partner', 'name', required=True),
            'user_pid':fields.char("UserName",size=128, required=True),
            'host_pid':fields.char("IP/HostName",size=128, required=True),
            'pass_pid':fields.char("Password",size=128, required=True),
            'com_pid':fields.text("Comment")
        }
password_table()

The menu is working but my form view is always in editing mode by default. And I have some problems may be with postgresql. The error is following : 'HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.'

Somebody could help me?

Dear Quintin, Did you try like this?

<code> <record id="view_password_partner_form" model="ir.ui.view"> <field name="name">Password Partner Form</field> <field name="model">res.partner</field>

</code>

see the model name

GuruDev
on 7/9/13, 6:05 AM

I find how do for the tab. I have always to fix some issues about my item menu but I'm in the right way. I'll edit this answer with the latest code. Thank you GuruDev for your help.

Quentin
on 7/10/13, 9:48 AM

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

0 follower(s)

Stats

Asked: 7/3/13, 7:56 AM
Seen: 3649 times
Last updated: 3/16/15, 8:10 AM