Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

How to extend the setup of a kanban component and pass data to a new form in Odoo?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
kanbanodooOWL
1 Respondre
3339 Vistes
Avatar
Dan

Hello, I need some help with a custom plugin for Odoo 16. 

I want to create a feature that when I drag a card to a certain column in kanban, it will show a confirmation window and if I agree, it will move the card to the desired column and open a new form from another custom plugin with filled fields that match the fields of the card in kanban. 

The main problem is that I don’t understand how to properly extend the setup in the extended component and get and pass the data to the new form (as I understand, the standard approach is to use default_)

My current code is something like this:

** @odoo-module **/
import { KanbanDynamicGroupList, KanbanModel } from “@web/views/kanban/kanban_model”;
export class LeadKanbanModel extends KanbanModel {}
class LeadKanbanDynamicGroupList extends KanbanDynamicGroupList {

    /**
* @param {string} dataRecordId
* @param {string} dataGroupId
* @param {string} refId
* @param {string} targetGroupId
*/


async moveRecord(dataRecordId, dataGroupId, refId, targetGroupId) {
    const targetGroup = this.groups.find((g) => g.id === targetGroupId);
    const sourceGroup = this.groups.find((g) => g.id === dataGroupId);

    if (!sourceGroup || !targetGroup) {
        return; // Groups have been re-rendered, old ids are ignored
    }

    if (targetGroup.displayName == "Завершён") {
        const record = sourceGroup.list.records.find((r) => r.id === dataRecordId);
        if (!record) return;
       
        let that = this;
        const superMoveRecord = super.moveRecord.bind(this);

        var Dialog = require('web.Dialog');
        var myDialog = new Dialog(this, {
            title: 'Do you want to complete the lead?',
            size: 'medium',
            $content: $('
').css({
                display: 'flex',
                alignItems: 'center',
                flexWrap: 'nowrap',
            })
            .append($('').text('Close the lead and open the work order')).css({ whiteSpace: 'nowrap' }),
            buttons: [
                {text: 'Yes', classes: 'btn-primary', close: true, click: function() {
// here
superMoveRecord(dataRecordId, dataGroupId, refId, targetGroupId);
},
                {text: 'No', classes: 'btn-primary', close: true, click: () => {
}}
            ]
        });
      myDialog.open();
        return true;
  } return await super.moveRecord(dataRecordId, dataGroupId, refId, targetGroupId);   
}
}

LeadKanbanModel.DynamicGroupList = LeadKanbanDynamicGroupList;



0
Avatar
Descartar
Avatar
Dan
Autor Best Answer

UPD: This is indeed a very crooked solution, but to be honest the OWL documentation is a bit of a pain.  

So far, my solution is to use relatively pure js, because it is easier as strange as it sounds. in custom_addons\market-crm\static\src\components\leads_kanban\kanban_model.js I wrote the opening of the window and storing the context in local storage: 

...

var Dialog = require('web.Dialog');
            var myDialog = new Dialog(this, {
                title: 'Do you want to complete the lead?',
                size: 'medium',
                $content: $('
').css({
                    display: 'flex',
                    alignItems: 'center',
                    flexWrap: 'nowrap',
                })
                .append($('').text('Close the lead and open the order form')).css({ whiteSpace: 'nowrap' }),
                buttons: [
                    {text: 'Yes', classes: 'btn-primary', close: true, click: () => {
                        superMoveRecord(dataRecordId, dataGroupId, refId, targetGroupId);
                        var currentUrl = window.location.href;
                        var index = currentUrl.indexOf("/web#");
                        var baseUrl = currentUrl.slice(0, index);
                        var newUrl = baseUrl + "/web#cids=1&menu_id=214&action=319&model=idiamarket_sale.order&view_type=form";
                        localStorage.setItem ("contact_number", record.data.contact_number);
                        localStorage.setItem ("contact_name", record.data.contact_name);
                        window.open(newUrl, "_blank");
                    },
                },
...

and in the form that should open custom_addons\market_sale\static\src\components\order_form\form_controller.js we get the data from local storage and substitute. 
UPD: problems with isDirty etc, kind of fix:


** @odoo-module **/
import {FormController} from "@web/views/form/form_controller";
import {onRendered, onMounted, onWillPatch, onPatched, onWillUnmount} from "@odoo/owl";
import {ADD_PRODUCT_CHANNEL} from "../order_fake_product_tree_view/constants";
import core from "web.core";
export class CustomFormController extends FormController {
    setup() {
        super.setup();
        onRendered(() => {
            var input_phone = document.getElementById("partner_phone");
            if (input_phone) {
                input_phone.addEventListener("input", () => {
                    var new_contact_number = input_phone.value;
                    localStorage.setItem("contact_number", new_contact_number);
                  });
            }
          });
        onMounted(async () => {
            core.bus.on(ADD_PRODUCT_CHANNEL, this, this.addRecordToList);
            var contact_name = localStorage.getItem ("contact_name");
            var input = document.getElementById("partner");
            if (input) {
                input.value = contact_name;
            }
            var contact_number = localStorage.getItem ("contact_number");
            var input_phone = document.getElementById("partner_phone");
            if (input_phone) {
                input_phone.value = contact_number;
            }
        })
        onPatched(() => {
            var contact_name = localStorage.getItem ("contact_name");
            var input = document.getElementById("partner");
            if (input && !input.value) {
                input.value = contact_name;
            }
            var new_contact_number = localStorage.getItem ("contact_number");
            var input_phone = document.getElementById("partner_phone");
            if (input_phone) {
                input_phone.value = new_contact_number;
            }
          });
        onWillUnmount(() => {
            core.bus.off(ADD_PRODUCT_CHANNEL, this, this.addRecordToList);
            localStorage.removeItem("contact_number");
            localStorage.removeItem("contact_name");
        })
    }
    async addRecordToList() {
        await this.model.load();
    }
}


0
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
Editable Kanban form
kanban OWL
Avatar
0
de febr. 25
1402
Odoo 16 : How to use message_post() to send message in the chatter? Solved
odoo OWL
Avatar
Avatar
Avatar
2
d’ag. 23
13059
Pass values ​​from one stage to another in kanban view, odoo 14[SOLVED] Solved
kanban odoo
Avatar
Avatar
1
de juny 23
3487
How to add an existing field validation with OWL?
javascript odoo OWL
Avatar
Avatar
Avatar
2
d’oct. 25
1200
Odoo 16 - Using an Odoo module to attach a very basic click handler
odoo OWL odoo16features
Avatar
Avatar
1
de jul. 23
3019
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now