Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
7068 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
View inheritance แก้ไขแล้ว
1
มี.ค. 20
3667
12
ธ.ค. 18
35045
1
ก.ค. 16
7229
How to pass data from a class to another แก้ไขแล้ว
8
ส.ค. 15
16711
Problem with inheritance of a view. แก้ไขแล้ว
1
มี.ค. 15
7915