콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
10474 화면

I'm using Odoo v10 and I'm trying to customize existing view (base.view_partner_form). Here are my model and view:

class add_supplier1099(models.Model):
    # _name = 'add.supplier1099'     
    _inherit = ['res.partner']     
    _description = "Add Checkbox and TaxID Field if Supplier Requires 1099"    
    supp_test_field = fields.Char(string="test field")
<odoo>      
    <data>
        <record id="add_supplier1099_view_inherit" model="ir.ui.view">
        <field name="name">res.partner.form</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">     
            <xpath expr="//field[@name='phone']" position="after">                
                <field name="supp_test_field"/>     
            </xpath>
        </field>        
        </record>    
    </data>
</odoo>

This code works and it adds "supp_test_field" to the form. But if you uncomment # _name = 'add.supplier1099' (I thinks it should add my new field to an existing table of "res.partner" model) it'll through an error:

ValueError: Can't validate view:
Field `supp_test_field` does not exist

I also tried to go with "_name = res.partner" (I thinks it should create a new table with my new field and fields from res.partner model), but I was getting the same error. Any ideas why i'm getting this error in the above cases and not getting an error when I comment out "_name" attribute?

아바타
취소
베스트 답변

When you declare '_name' attribute with '_inherit' you're creating a new model which gets all fields of the inherited one. in this case you have to use the new model name to call it from the view.

But when you use only '_inherit' attribute your model replace the original one 'res.partner', this is why you can call it with 'res.partner' model name from the view.

The error is because you created a new model ( add.supplier1099 = res.partner + supp_test_field) and you're calling supp_test_field from the 'res.partner' view, which doesn't exist.

So for you're purpose, if you'd like to use 'add.supplier1099' name instead of 'res.partner'. Just replace model name in the view :

<field name="model">add.supplier1099</field>

hope this helps.

regards.


아바타
취소
베스트 답변

View Inheritance and xpath locators (position attribute): Odoo Inheritance

아바타
취소
관련 게시물 답글 화면 활동
0
12월 24
1332
4
3월 24
3356
1
3월 24
2399
1
10월 23
5324
1
6월 23
12422