コンテンツへスキップ
メニュー
この質問にフラグが付けられました
14 返信
48934 ビュー

Hi,

My question is how to add new tab or (tabs) in my module or existing module

I know the we need to inherit the module we want to add some things and do our changes (As what I do previously (adding one2may & many2one fields))

see below picture will explain what I need

image description

Thank you in advance

アバター
破棄
最善の回答

To add page in employee after personal information tab you need to inherit the employee form view in xml like,

 <record id="view_employee_form" model="ir.ui.view">
   	<field name="name">hr.employee.form</field>
    <field name="model">hr.employee</field>
    <field name="inherit_id" ref="view_employee_form"/>
    <field name="arch" type="xml">
	    <xpath expr="//page[@string='Personal Information']" position='after'>
	    	<page string='My new tab'>
	    		
	    	</page>
	    </xpath>
    </field>
</record>
アバター
破棄

It didn't work for me initially in Odoo 13. I needed to edit this: expr="//page[@string='Personal Information']"

After changing @string to @name and then changing "Personal Information" to the proper name value of the page, it worked. Thanks Atul!

@Bienvenido Villabroza, yes you are correct, @sting is not working on the newer version. my above answer will perfectly in v8 or lower version

what should i do if i want to show this tab only for the sales department

最善の回答

In form view, inside <notebook> tag you can add as many pages(TAB) by this syntax

 <notebook>
     <page string="Your Tab1">
         <field name="..."/>
     </page>  
     <page string="Your Tab2">
         <field name="..."/>
     </page>   
 </notebook>
アバター
破棄
最善の回答

hello Math

Here for you I'm adding new tab in "Quotations" of "sale" module,this is similar to your requirement

Example.py

from openerp import fields, models, api, _

class class_name(models.Model):

    _inherit = 'sale.order'
    <fields name="..."/>

Example.xml

<record id="view_sale_order_tree" model="ir.ui.view">
<field name="name">view.sale.order.tree</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">

<xpath expr="//page[@string='Other Information']" position="after">
<page string="My_New_Tab">
<field name='My_new_fields'/>
</page>
   </xpath>

</field>
</record>


アバター
破棄
最善の回答

inside <notebook> tag, after <page string="Personal Information"> </page> put your new tab, <page string="My Tab"> </page>

アバター
破棄
最善の回答

You need to add a new page in the notebook in the View. Are you creating an own Addon/Module to alter the partner page?

In case of you do please take a look on that: You need to inherit from the partner view in maybe partner_view.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <!--
    Partners Extension
  -->

    <record id="view_partner_property_form" model="ir.ui.view">
        <field name="name">res.partner.stock.property.form.inherit</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="product.view_partner_property_form"/>
        <field name="arch" type="xml">
            <notebook position="inside">
                <page string="My New Tab">
                    <field name="..."/>
                </page>
            </notebook>
        </field>
    </record>

  </data>
</openerp>
アバター
破棄
著作者

What I do without inherit view (inherit the module) <!-- ============== student================= --> <!-- 1st part of the sim_view start--> <record model="ir.ui.view" id="student_form"> <field name="name">Student</field> <field name="model">sim77.student</field> <field name="type">form</field> <field name="arch" type="xml"> <form string="Student"> <field name="name"/> <field name="student_name"/>

<field name="gender"/> <field name="contract_id"/> </form> </field> </record> <!-- 1st part of the sim_view end--> can you help ? where I put code of new page?

Then add a notebook to your view. That looks exactly as above code just without the "inherit_id" tag nor the position attribute in <notebook>. Notebook adds the Space for your Tabs to the form.

You put the code of the new File in a separate .xml file. Then you need to add the .xml in your __openerp__.py under "update_xml". Just take a look to other addons therefor.

Did that solved your Problem? If it does please mark one of the correct answers to help others to find the solution faster

Great, this works fine for me. I have a one2many field in the partner model that creates a relationship with custom model. How can I add a "Create" button to the tab so that it pop up the view of the custom model?

最善の回答

How can we set one tab or page as default, i.e., when i open the screen that that tab opens by default

 

アバター
破棄

I would want to know too!

Put it the first not the last hhhh ;)

最善の回答

For adding a new tab your xpath had to be like this

<xpath expr="//page[2]" position='after'>
1,2,3 depending the number of your tab in the view.
アバター
破棄
関連投稿 返信 ビュー 活動
0
5月 22
2485
0
7月 24
1919
1
11月 20
4036
1
10月 20
4667
1
1月 20
4619