Skip to content

Commit

Permalink
[FIX] crm: stage auto-probability not taken into account when creatin…
Browse files Browse the repository at this point in the history
…g an opportunity from kanban view

1. on CRM module -> Select Pipeline -> Create a column (e.g. 'Test')
2. Edit this Stage
3. Toggle on the field 'Change Probability Automatically'
4. Set a stage probability (e.g. 50%)
5. Create an opportunity on this stage, using the quick create widget of the kanban view
=> The probability of the newly created opportunity is not 50%, as it should be expected

It takes the default_probability, using a default_stage_id, which is the 'New' column having initially a probability of 10%. The stage_id is correctly assigned to the newly created opportunity thanks to environment variable 'default_stage_id', but not the probability.

We solved this bug by updating the probability of the opportunity, after creating the object. We cannot do it at the same time, because BaseObject.create parse the missing fields in an order where probability comes before stage_id.

This fix is limited to the quick creation of opportunity by means of its name only. In particular, it doesn't overwrite the input of the user in the form view.

opw-772310
  • Loading branch information
alexkuhn committed Oct 17, 2017
1 parent 671c205 commit bfbed53
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions addons/crm/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ def _onchange_next_activity_id(self):
# ORM override (CRUD, fields_view_get, ...)
# ----------------------------------------

@api.model
def name_create(self, name):
res = super(Lead, self).name_create(name)

# update the probability of the lead if the stage is set to update it automatically
self.browse(res[0])._onchange_stage_id()
return res

@api.model
def create(self, vals):
# set up context used to find the lead's sales team which is needed
Expand Down

0 comments on commit bfbed53

Please sign in to comment.