تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
7986 أدوات العرض

Hello

I created a very simple module with the following model:

class Adherent(models.Model):
    _name = 'adherent.adherent'
    _inherit = ['res.partner']
    name = fields.Char(string='Nom', required=True)

and a custom form view:

        <record id = "adherent_adherent_form_view" model = "ir.ui.view">
                    <field name = "name">add.fields</field>
                    <field name = "model">adherent.adherent</field>
                    <field name = "inherit_id" ref = "base.view_partner_form"/>
                    <field name = "arch" type = "xml">
                        <form>
                            <sheet>
                                <field name="name" class="oe_read_only"/>&#x2063;
                                <field name="id" class="oe_read_only" attrs="{'readonly':True}"/>
                                <group string="Adherent">
                                     <group>
                                         <field name="active"/>   
                                    </group>
                                </group>
                            </sheet>
                        </form>   
                    </field>               
            </record> 

In launching the form view I got this error:

TypeError: Widget is not a constructor

Could u help me to fix this issue?

thks in advance,

Bruno
الصورة الرمزية
إهمال
الكاتب أفضل إجابة

Hello

thks for replying to me

So I removed the inheritance in the view

here is the minimal and working view I created:

<?xml version="1.0"?>
<form>
                    <sheet>
                        <div class="oe_button_box" name="button_box">
                            <button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive">
                                  <field name="active" widget="boolean_button" options="{&quot;terminology&quot;: &quot;archive&quot;}"/>
                            </button>
                          </div>
                        <field name="name" class="oe_read_only"/>⁣
                        <field name="id" class="oe_read_only" attrs="{'readonly':True}"/>                   
                    </sheet>
</form>

الصورة الرمزية
إهمال
أفضل إجابة

Hello,

The inheritance that you made will create a new model from "res.partner" model, keep all the existing fields and methods of the original model (res.partner), adding new information to the copy (adherent.adherent) but leaving the original (res.partner) module as-is.
In this case you can't use the inheritance view, because your new model (adherent.adherent) is ignored by existing res.partner views.

Solution: You need to create your own views

This link can help you to know more:

https://www.odoo.com/documentation/11.0/reference/orm.html#inheritance-and-extension 


Thank you.

الصورة الرمزية
إهمال