跳至内容
菜单
此问题已终结
4 回复
7073 查看

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
3669
12
12月 18
35046
1
7月 16
7232
8
8月 15
16711
1
3月 15
7917