Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

Custom Code: How to reload the Kanban view in Odoo after moving a lead to a different stage?

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
development
2 Replies
2212 Rodiniai
Portretas
Martin Bando

I have transferred the _track_subtype method from the CRM module to my module and inserted the is_lost field, which changes the status to true when the lead is moved to the stage with the label lost. It is just that the state does not always change. If I now move it back to another stage, it remains lost with the heading at the top right. Only when I refresh the page is the state updated and the heading disappears. 


How can I reload the Kanban view in Odoo after moving a lead to a different stage?


class Lead(models.Model):

    _inherit = 'crm.lead'

   

    is_lost = fields.Boolean(string='Is Lost', default=False)

   

    def _track_subtype(self, init_values):

        self.ensure_one()


        if self.stage_id.name.find("Lost") != -1:

            # If a lead is moved to Lost, then set is_lost to True

            self.is_lost = True

           

        else:

            # For all other lead set is_lost to False           

            self.is_lost = False     

       

        if 'stage_id' in init_values and self.probability == 100 and self.stage_id:

            return self.env.ref('crm.mt_lead_won')

        elif 'lost_reason_id' in init_values and self.lost_reason_id:

            return self.env.ref('crm.mt_lead_lost')

        elif 'stage_id' in init_values:

            return self.env.ref('crm.mt_lead_stage')

        elif 'active' in init_values and self.active:

            return self.env.ref('crm.mt_lead_restored')

        elif 'active' in init_values and not self.active:

            return self.env.ref('crm.mt_lead_lost')

        return super(Lead, self)._track_subtype(init_values)


<record id="mymodule_crm_case_kanban_view_leads" model="ir.ui.view">

    <field name="name">mymodule.crm.lead.kanban.lead</field>

    <field name="model">crm.lead</field>

    <field name="inherit_id" ref="crm.crm_case_kanban_view_leads"/>

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

        <!--  Aperture with red background and white lettering 'Lost' in the window -->

        <xpath expr="//widget[@name='web_ribbon']" position="replace">

            <field name="is_lost" invisible="0"/>

            <widget name="web_ribbon" title="lost" bg_color="text-bg-danger" invisible="is_lost == False"/>

        </xpath>

    </field>

</record>

0
Portretas
Atmesti
Martin Bando
Autorius

Hi, there is still the error, now it is not updated when i move it back to lost. i think i have to use javascript here. i use odoo 18. how can i integrate javascript. i don't know anything about this. Could you describe this in detail.

Portretas
Martin Bando
Autorius Best Answer

I have tried to automatically reload the Kanban view in Odoo 18 when a data record (e.g. a lead) is moved via drag & drop:


Javascript:

import { patch } from '@web/core/utils/patch';


patch(KanbanController.prototype, {

    async dropRecord(record, targetColumn) {

        await this._super(...arguments);


        if (this.model.root.resModel === 'crm.lead') {

            await this.model.load(); 

            this.render(true);    

        }

    }

});


Manifest:'assets': {

    'web.assets_backend': [

        'my_module/static/src/js/kanban_stage_change_refresh.js',

    ],

},

This is a code that was created with Copilot. Is it sufficient to insert the Javscript and change the manifest? Because it doesn't work when I try.

0
Portretas
Atmesti
Portretas
Sergio Infante
Best Answer

Hey,

You’re on the right track by inheriting _track_subtype and managing the is_lost flag based on the stage. The behavior you’re seeing—where the ribbon doesn’t update until a page refresh—comes down to how Odoo handles view updates in the Kanban.

Odoo doesn’t automatically re-render the whole Kanban card when a field like is_lost is changed via Python unless that field is part of a computed or onchange method triggered by the UI. Since is_lost is being set in backend logic, the frontend doesn’t get the update immediately.

How to fix it?

To force the UI to reflect the is_lost status change immediately when you move the lead:

Use a computed field with store=True and make it depend on the stage_id. That way, the ORM knows to recompute and store the value when the stage changes.

@api.depends('stage_id')

def _compute_is_lost(self):

    for lead in self:

        lead.is_lost = 'lost' in (lead.stage_id.name or '').lower()


is_lost = fields.Boolean(string='Is Lost', compute='_compute_is_lost', store=True)

Make sure the Kanban view includes the is_lost field directly (which you’ve already done with the ribbon), so it knows to watch for updates on that field.

This way, as soon as you move the lead to a different stage, Odoo will recompute the is_lost value and update the UI accordingly—no need to manually refresh the page.

Let me know if you want to go one step further and make it dynamic with JS or override write() instead. But for 99% of cases, the computed field with store=True handles it perfectly.

0
Portretas
Atmesti
Enjoying the discussion? Don't just read, join in!

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

Registracija
Related Posts Replies Rodiniai Veikla
Feature Request: Native “Dialog Filters” in Search Panel
development
Portretas
0
lapkr. 25
140
Solution to the Getting Started tutorial from the official Odoo 16 documentation
development
Portretas
Portretas
Portretas
2
lapkr. 25
1513
How do I change the name of the module, or rather the name assigned to the module, after I created it in Odoo Studio?
development
Portretas
1
lapkr. 25
364
Guest House Module - Rental Search Bar
development
Portretas
Portretas
1
lapkr. 25
236
How to make all branches for user active automatically after login his account?
development
Portretas
Portretas
Portretas
3
lapkr. 25
429
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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