From d85eb848aff331bc1653291d23ddcb7f93b48947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 28 Jun 2015 22:59:02 +0200 Subject: [PATCH] Update opportunity amount only if changed Otherwise it generates unnecessary history entries. issue4700 review15361002 --- opportunity.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/opportunity.py b/opportunity.py index f57bddfa81..3f79a30550 100644 --- a/opportunity.py +++ b/opportunity.py @@ -341,6 +341,7 @@ class SaleOpportunity(Workflow, ModelSQL, ModelView): Date = pool.get('ir.date') cls.write(filter(lambda o: o.is_forecast, opportunities), { 'end_date': Date.today(), + 'state': 'won', }) @classmethod @@ -350,6 +351,7 @@ class SaleOpportunity(Workflow, ModelSQL, ModelView): Date = Pool().get('ir.date') cls.write(filter(lambda o: o.is_forecast, opportunities), { 'end_date': Date.today(), + 'state': 'lost', }) @classmethod @@ -404,7 +406,9 @@ class SaleOpportunity(Workflow, ModelSQL, ModelView): lost = [] converted = [] for opportunity in opportunities: - opportunity.amount = opportunity.sale_amount + sale_amount = opportunity.sale_amount + if opportunity.amount != sale_amount: + opportunity.amount = sale_amount if opportunity.is_won(): won.append(opportunity) elif opportunity.is_lost():