İçereği Atla
Menü
Bu soru işaretlendi
4 Cevaplar
7050 Görünümler

hello,I want a "prototype inheritance " of customer billing view from accounting model to another custom module that i called test!but it doesn't work!!can anybody help me please!this is my code:

class test_test(models.Model):

_name = 'test.test'

_inherit = 'account.invoice'

de = fields.Text(string='Des', required=True)

and the xml :

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

<field name="name">module.name.account.invoice.tree</field>

<field name="model">test.test</field>

<field name="inherit_id" ref="account.invoice_tree" />

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

<field name="state" position="after">

<field name="de" /> </field> </field> </record>

help please!!!i get this erreur:

ParseError: "ValidateError

Field(s) `arch` failed against a constraint: Invalid view definition

Error details:

Field `de` does not exist

Error context:

View `account.invoice.form.inherit`

[view_id: 1092, xml_id: test.view_account_invoice_inherit_form, model: account.invoice, parent_id: 638]" while parsing file:///C:/Workspace/Odoov8/odoo/addons/test/views/dimo_view.xml:27, near

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

<field name="name">account.invoice.form.inherit</field>

<field name="model">account.invoice</field>    <!------ -----  ----   ---   --    -     -->

<field name="type">form</field>

<field name="inherit_id" ref="account.invoice_form"/>

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

<field name="partner_id" position="after">

<field name="de"/>

</field>

</field>

</record>

Avatar
Vazgeç
Üretici En İyi Yanıt

hi again Temur, i already tried that but it's not woking it doenst show the "custumer invoice view" that i want!it show another view i dont even know!!

thanks Jaakko for your help!

Update (Takwa)

hey again, well i actually found the problem i think i need to specify which view to open for which view mode and i tried to solve it mysef  thanks every one for your help 

so this is my code again :

    <menuitem name="Test" id="menu_test_root"/>

        <record model="ir.actions.act_window" id="action_test1_form">

            <field name="name">test.test.action</field>

            <field name="res_model">test.test</field>

            <field name="view_type">form</field>

            <field name="view_mode">tree,form</field>

        </record>  

        <menuitem name="Clients" id="menu_test_test" parent="menu_test_root"/>

        <menuitem name="factures clients" id="menu_formation_formation2" action="action_test1_form" parent="menu_test_test"/>

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

        <field name="name">my.module.name.tree.inherit</field>

        <field name="model">test.test</field> 

        <field name="inherit_id" ref="account.invoice_tree" />

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

            <field name="state" position="after">

                <field name="de" /> </field> </field></record>

    <!-- les formulaire -->

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

        <field name="name">my.module.name.form.inherit</field>

        <field name="model">test.test</field>

        <field name="type">form</field>

        <field name="inherit_id" ref="account.invoice_form"/> 

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

             <field name="partner_id" position="after">

             <field name="de"/></field> </field></record>

      <record model="ir.actions.act_window.view" id="action_test_tree">

        <field name="sequence" eval="1"/>

        <field name="view_mode">tree</field>

        <field name="view_id" ref="view_account_invoice_inherit_tree"/>

        <field name="act_window_id" ref="action_test1_form"/>

    </record>     

    <record model="ir.actions.act_window.view" id="action_test_form">

        <field name="sequence" eval="1"/>

        <field name="view_mode">form</field>

        <field name="view_id" ref="view_account_invoice_inherit_form"/>

        <field name="act_window_id" ref="action_test1_form"/> </record>

 

Avatar
Vazgeç
En İyi Yanıt

You need to put your field definitions in _columns dictionary:

_columns = { 
'de':fields.text('des',required=True)
}


Avatar
Vazgeç
En İyi Yanıt

in XML record from your error log, in C:/Workspace/Odoov8/odoo/addons/test/views/dimo_view.xml replace account.invoice with test.test 

Error message says: 
Field `de` does not exist
-yes, 'de' does not exist in the account.invoice model, but in test.test model... you forgot to rename account.invoice to test.test in XML (you renamed in tree view part, but not in form view part).

Avatar
Vazgeç
En İyi Yanıt

replace models.Model by osv.osv andi add in the top from openerp import osv

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
View inheritance Çözüldü
1
Mar 20
3663
12
Ara 18
35031
1
Tem 16
7224
8
Ağu 15
16708
1
Mar 15
7911