admin管理员组

文章数量:1389768

I'm new in odoo, and I want to create widget to show stage_target in CRM module. When I run my code I got error

I want to make stage target like this image in CRM module

This is my js code :


    import { Field } from "@web/views/fields/field";
    import { registry } from "@web/core/registry";
    
    class StageTargetWidget extends Field {
        get stages() {
            const stageTargets = this.props.record.data[this.props.name];
            return stageTargets ? stageTargets.records : [];
        }
    }
    
    StageTargetWidget.template = "widget_crm.StageTargetWidget";
    StageTargetWidget.props = ["*"];
    
    registry.category("fields").add("stage_target_widget", StageTargetWidget);

This is my XML template code:


    <?xml version="1.0" encoding="UTF-8"?>
    <templates>
        <t t-name="widget_crm.StageTargetWidget">
            <div class="stage-targets">
                <t t-foreach="stages" t-as="stage" t-key="stage.resId">
                    <div class="stage-item">
                        <strong t-esc="stage.data.stage_id[1]"/>
                        <span t-esc="stage.data.due_date"/>
                    </div>
                </t>
            </div>
        </t>
    </templates>

And this is my crm lead XML code:

    <?xml version="1.0" encoding="utf-8"?>
    <odoo>
        <record id="crm_lead_view_form_inherit" model="ir.ui.view">
            <field name="name">crm.lead.view.form.inherit</field>
            <field name="model">crm.lead</field>
            <field name="inherit_id" ref="crm.crm_lead_view_form"/>
            <field name="arch" type="xml">
                <!-- Add a custom header with 5 columns -->
                <xpath expr="//header" position="after">
                   <field name="stage_target_ids" widget="stage_target_widget" />
                </xpath>
            </field>
        </record>
    </odoo>

本文标签: python 3xCaused by TypeError Cannot read properties of undefined (reading 39name39)Stack Overflow