Odoo Events将字段添加到表单

时间:2019-05-15 19:24:14

标签: odoo odoo-11 odoo-view

我正在使用Odoo 11,并且试图在事件注册表单中添加一个字段。注册表实际上在网站上。 enter image description here

我能够添加到与会者表单,但这未显示在网站注册表单上。

模型

class EventRegistration(models.Model):

    _inherit = "event.registration"

    firstname = fields.Char(
        string="Firstname",
        index=True,
    )
    lastname = fields.Char(
        string="Lastname",
        index=True,
    )
    name = fields.Char(
        string="Name",
        compute="_compute_name",
        readonly=True,
        store=True
    )
    team = fields.Char(
        string="Team",
        store=True,
    )

查看文件

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record model="ir.ui.view" id="view_event_registration_form_inherit_firstname">
        <field name="name">event.registration.form</field>
        <field name="model">event.registration</field>
        <field name="inherit_id" ref="event.view_event_registration_form" />
        <field name="name">event.registration.view.form.inherit.firstname</field>
        <field name="arch" type="xml">
            <field name="name" position="attributes">
                <attribute name="invisible">1</attribute>
            </field>
            <field name="name" position="after">
                <field name="firstname"/>
                <field name="lastname"/>
                <field name="team"/>
            </field>
        </field>
    </record>


    <record model="ir.ui.view" id="view_event_registration_tree_inherit_firstname">
        <field name="name">event.registration.tree</field>
        <field name="model">event.registration</field>
        <field name="inherit_id" ref="event.view_event_registration_tree" />
        <field name="arch" type="xml">
            <field name="name" position="attributes">
                <attribute name="invisible">1</attribute>
            </field>
            <field name="name" position="after">
                <field name="firstname"/>
                <field name="lastname"/>
                <field name="team"/>
            </field>
            <field name="partner_id" position="attributes">
                <attribute name="invisible">1</attribute>
            </field>
        </field>
    </record>

    <record model="ir.ui.view" id="view_registration_search_inherit_firstname">
        <field name="name">event.registration.search</field>
        <field name="model">event.registration</field>
        <field name="inherit_id" ref="event.view_registration_search" />
        <field name="arch" type="xml">
            <xpath expr="//search/filter[last()]" position="after">
                <field name="firstname" string="Firstname" filter_domain="[('firstname', 'ilike', self)]"/>
                <field name="lastname" string="Lastname" filter_domain="[('lastname', 'ilike', self)]"/>
            </xpath>
            <xpath expr="//search/group" position="inside">
                <filter string="Lastname" domain="[]" context="{'group_by': 'lastname'}"/>
                <filter string="Firstname" domain="[]" context="{'group_by': 'firstname'}"/>
            </xpath>
        </field>
    </record>
</odoo>

当我单击立即注册时,我想添加现场团队。从图片中可以看到,代码将添加到与会者页面。

enter image description here

1 个答案:

答案 0 :(得分:1)

要将字段添加到事件注册表单,您必须继承模板“ registration_attendee_details ”。外部ID为website_event.registration_attendee_details