Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
kanbanodooOWL
1 Odpoveď
3333 Zobrazenia
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
Zrušiť
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
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Editable Kanban form
kanban OWL
Avatar
0
feb 25
1401
Odoo 16 : How to use message_post() to send message in the chatter? Solved
odoo OWL
Avatar
Avatar
Avatar
2
aug 23
13023
Pass values ​​from one stage to another in kanban view, odoo 14[SOLVED] Solved
kanban odoo
Avatar
Avatar
1
jún 23
3484
How to add an existing field validation with OWL?
javascript odoo OWL
Avatar
Avatar
Avatar
2
okt 25
1191
Odoo 16 - Using an Odoo module to attach a very basic click handler
odoo OWL odoo16features
Avatar
Avatar
1
júl 23
3016
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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