跳至內容
選單
此問題已被標幟
4 回覆
7081 瀏覽次數

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>

頭像
捨棄
作者 最佳答案

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>

 

頭像
捨棄
最佳答案

You need to put your field definitions in _columns dictionary:

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


頭像
捨棄
最佳答案

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).

頭像
捨棄
最佳答案

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
3月 20
3670
12
12月 18
35047
1
7月 16
7232
8
8月 15
16711
1
3月 15
7919