Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

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

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
kanbanodooOWL
1 Răspunde
3344 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Dan
Autor Cel mai bun răspuns

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
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Editable Kanban form
kanban OWL
Imagine profil
0
feb. 25
1402
Odoo 16 : How to use message_post() to send message in the chatter? Rezolvat
odoo OWL
Imagine profil
Imagine profil
Imagine profil
2
aug. 23
13069
Pass values ​​from one stage to another in kanban view, odoo 14[SOLVED] Rezolvat
kanban odoo
Imagine profil
Imagine profil
1
iun. 23
3487
How to add an existing field validation with OWL?
javascript odoo OWL
Imagine profil
Imagine profil
Imagine profil
2
oct. 25
1200
Odoo 16 - Using an Odoo module to attach a very basic click handler
odoo OWL odoo16features
Imagine profil
Imagine profil
1
iul. 23
3020
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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