Ir al contenido
Menú
Se marcó esta pregunta

Hello Odoo Community,

I am looking to customize the Probability field in Odoo CRM so that it dynamically updates based on the selected Stage in the pipeline. Each stage in the pipeline corresponds to a specific probability percentage. For example:

  • Introduction Meeting Scheduled: 15%
  • Proposal / Quotation Issued: 50%

What I’ve Tried:

  1. Automation Rules:
    • I created an automation rule to update the probability when the stage changes. While this works, it feels rigid and doesn't allow for easy modifications or new stage additions.
  2. Compute Field in Studio:
    • I attempted to define the probability field as a computed field in Studio with dependencies on stage_id. However, since probability is a base field, Odoo does not allow this and prompts me to use Python code instead.

Goal:

I want to achieve the following:

  • Automatically set the Probability field based on the selected Stage.
  • Use a mapping between stages and probabilities to make this behavior easy to manage and update.
  • Ensure that the probability recalculates dynamically whenever the stage changes.

Questions:

  1. How can I make the probability field dynamic based on the stage?
  2. Is there a recommended way to manage stage-to-probability mappings to ensure flexibility (e.g., via database records instead of hardcoding)?
  3. What are the best practices for implementing this while ensuring compatibility with future Odoo updates?

Thank you for your help! Any suggestions or code snippets would be greatly appreciated. 😊

Avatar
Descartar
Autor Mejor respuesta

Thank you for taking the time!

I am currently using Automation but I was wondering if Computed field would be more efficient since the page tends to slowdown because of the automation.

Best regards

Avatar
Descartar
Mejor respuesta

Hi,

You can achieve this by following:

  1. Go to CRM->Configuration->Stages
  2. Open any stage record and from studio, add Float field "Stage Probability" to preferred place in form view
  3. Modify this Stage Probability field with your value in all stages
  4. Go CRM->Pipeline and from Studio go to "Automation Rules" and create one like below


And your code would be for "Execute Code" like below:

for rec in records:
    if rec.type == 'opportunity' and rec.stage_id and rec.stage_id.x_studio_stage_probability > 0:
        rec.write({'probability': rec.stage_id.x_studio_stage_probability})
Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
mar 15
7933
0
feb 22
8162
1
dic 21
3912
1
ago 21
2986
CSV Upload Resuelto
1
dic 20
3285