Skip to Content
Menu
This question has been flagged
2 Replies
3596 Views

Hello

I dev a custom module with this model:

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

Here is the associated view:

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <data>
        <record id="adherent_menu_action" model="ir.actions.act_window">
            <field name="name">Adhérents</field>
            <field name="res_model">adherent.adherent</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[]</field>
            <field name="help" type="html">
                <p class="oe_view_nocontent_create">Créer le premier adhérent
                </p>
            </field>
        </record>   
        <menuitem id="adherent_menu"
                  name="Adhérent"
                  />
        <menuitem id="adherent_adherent_menu"
                  parent="adherent_menu"
                  name="Adhérent"
                  action="adherent_menu_action"/>
                 
        <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">
                        <field name = "name"/>
                    </field>
        </record>                 
    </data>
</odoo>

Impossible to install the module:

The field active does not exist

Could u help me to fix this issue?

Thks in advance

Bruno

Avatar
Discard
Best Answer

You forgot '_' in front of inherit: _inherit = ['res.partner']

Avatar
Discard
Author

ok thanks a lot

I modified my model & form view but I still get an error in launching my form view:

TypeError: Widget is not a constructor

Whats wrong?

Code:

model:

class Adherent(models.Model):

_name = 'adherent.adherent'

_inherit = ['res.partner', 'mail.thread', 'mail.activity.mixin']

name = fields.Char(string='Nom', required=True)

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>

<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"/>&#x2063;

<field name="id" class="oe_read_only" attrs="{'readonly':True}"/>

<group string="Adherent">

<group>

<field name="active"/>

</group>

</group>

<div class="oe_chatter">

<field name="message_follower_ids" widget="mail_followers"/>

<field name="activity_ids" widget="mail_activity"/>

<field name="message_ids" widget="mail_thread"/>

</div>

</sheet>

</form>

</field>

</record>

Author Best Answer

ok thanks a lot

I modified my model & form view but I still get an error in launching my form view:

TypeError: Widget is not a constructor

Whats wrong?

Code:

model:

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

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>
                                <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"/>&#x2063;
                                <field name="id" class="oe_read_only" attrs="{'readonly':True}"/>
                                <group string="Adherent">
                                     <group>
                                         <field name="active"/>   
                                    </group>
                                </group>
                                <div class="oe_chatter">
                                    <field name="message_follower_ids" widget="mail_followers"/>
                                    <field name="activity_ids" widget="mail_activity"/>
                                    <field name="message_ids" widget="mail_thread"/>
                                </div>                         
                            </sheet>
                        </form>   
                    </field>               
            </record> 

Avatar
Discard