Skip to Content
Menú
This question has been flagged
1 Respondre
1699 Vistes

Like i want to show a single summary on all form view do not want to add multiple of time but i cant use t-call because it does not work in odoo form:

xml version="1.0" encoding="UTF-8"?>
id="template" xml:space="preserve">

t-name="EcSummaryBoardCustom">
class="p-3">

Hello World





id="ec_medical_first_consultation_form_view" model="ir.ui.view">
name="name">ec.first.consultation.form
name="model">ec.first.consultation
name="arch" type="xml">
string="First Consultation">
t-call="EcSummaryBoardCustom"/>









Avatar
Descartar
Best Answer

Hi,

You can try the following

js>>

import { registry } from '@web/core/registry';

import { formView } from '@web/views/form/form_view';

import { FormController } from '@web/views/form/form_controller';


export class FormClassController extends FormController {

    setup() {

        super.setup();

        console.log(this,'FormClassController',this.template)

        owl.onMounted(() => {

            let textField = this.__owl__.bdom.el.querySelector('.text-field')

            textField.innerHTML = 'Hello World';

        })

    }

}

registry.category('views').add('form_class', {

    ...formView,

    Controller: FormClassController,

});


xml>>

<field name="model">project.task.details</field>

        <field name="arch" type="xml">

            <form js_class="form_class">

                <div class="text-field"/>

    </div>

    </form>

    </field>


 Js_class allows you to access the backend view and customize it according to your needs. Now every time you create a form view just add the js_class of 'form_class' and add a div of class 'text-field' or you can find an alternative way to show your view using the `js_class`

Hope it helps

Avatar
Descartar
Related Posts Respostes Vistes Activitat
0
de gen. 25
692
1
de març 25
652
2
d’ag. 22
7157
8
de juny 20
20791
1
d’abr. 20
53