Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
1214 Vizualizări

I'm extending gantt view to add new button. The button is working. The problem is when i try to use RPC or ORM, I got this error

`Uncaught Promise > Cannot read properties of null (reading 'component')` 

I think GanttController is extending AbstractController



Here is the javascript 


/** @odoo-module */

import { _t } from 'web.core';
import { useService } from "@web/core/utils/hooks";

export const ControllerMixin = {
    async _onMovePlanClick(ev) {
        // const rpc = useService('rpc');
        ev.preventDefault();
        $.exposed = {
            this:this,
            useService:useService
        };
        console.log(
            'ControllerMixin._onMovePlanClick'
        );
        const orm = useService("orm");
        const project_id = await orm.call('project.task', 'get_project_id', [this.context.active_id])
        this.do_action({
            name: _t('Move Plan'),
            type: 'ir.actions.act_window',
            res_model: 'project.task.move.plan.wizard',
            views: [[false, 'form']],
            target: 'new',
            context: {'default_project_id': project_id},
        })
       
    },

};

This is the python



class Task(models.Model):
    _inherit = "project.task"

    def get_project_id(self):
        return self.project_id.id



I test it without calling const orm = useService("orm");​. It's working fine. So the problem is when defining orm or rpc variable


In other case, I'm extending CharField and ORM is working fine



Imagine profil
Abandonează
Autor Cel mai bun răspuns

I see some code in the odoo base and it use this._rpc​. Anyway if anyone curious on how to use it

    this._rpc({
      model: "project.project",
      method: "get_project_id",
      args: [this.context.active_id],
    }).then((res) => {
// res is the return value from the model
    });




Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
aug. 24
729
0
nov. 23
1716
1
iul. 24
1458
1
mar. 22
4187
1
iun. 21
2708