From b2e4d2b7544605bac3166c8390bfd51eb221a4cc Mon Sep 17 00:00:00 2001 From: Xavier Codinas Date: Thu, 22 Sep 2016 12:25:16 +0200 Subject: [PATCH] Simplify default employee issue4793 review33351002 --- opportunity.py | 9 +-------- tests/scenario_sale_opportunity.rst | 1 + 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/opportunity.py b/opportunity.py index 70a0ccfe0c..e76d3b358d 100644 --- a/opportunity.py +++ b/opportunity.py @@ -216,14 +216,7 @@ class SaleOpportunity(Workflow, ModelSQL, ModelView): @staticmethod def default_employee(): - User = Pool().get('res.user') - - if Transaction().context.get('employee'): - return Transaction().context['employee'] - else: - user = User(Transaction().user) - if user.employee: - return user.employee.id + return Transaction().context.get('employee') @classmethod def default_payment_term(cls): diff --git a/tests/scenario_sale_opportunity.rst b/tests/scenario_sale_opportunity.rst index c64db634b8..30f4e7e3e1 100644 --- a/tests/scenario_sale_opportunity.rst +++ b/tests/scenario_sale_opportunity.rst @@ -98,6 +98,7 @@ Create an lead:: >>> config.user = sale_opportunity_user.id >>> Opportunity = Model.get('sale.opportunity') >>> opportunity = Opportunity() + >>> opportunity.employee = employee >>> opportunity.description = 'Opportunity' >>> opportunity.save() >>> opportunity.state