From 0a05656bde763dee71b47fadd97682ddde3bbc55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 10 Apr 2020 18:53:44 +0200 Subject: [PATCH] Add employee on document for some states issue8969 review276621002 --- CHANGELOG | 1 + subscription.py | 9 +++++++++ view/subscription_form.xml | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 71e1b68093..a75bdb0f5f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add employee on subscriptions for some states * Use greatest end date of lines for closed date * Add contact and invoice party on subscription * Allow invoices to be created in advance diff --git a/subscription.py b/subscription.py index c2e0a78871..c6b0ee2a53 100644 --- a/subscription.py +++ b/subscription.py @@ -18,6 +18,8 @@ from trytond.transaction import Transaction from trytond.wizard import Wizard, StateView, StateAction, StateTransition, \ Button +from trytond.modules.company.model import ( + employee_field, set_employee, reset_employee) from trytond.modules.product import price_digits from .exceptions import InvoiceError @@ -141,6 +143,10 @@ class Subscription(Workflow, ModelSQL, ModelView): }, depends=['state']) + quoted_by = employee_field( + "Quoted By", states=['quotation', 'running', 'closed', 'canceled']) + run_by = employee_field( + "Run By", states=['running', 'closed', 'canceled']) state = fields.Selection([ ('draft', "Draft"), ('quotation', "Quotation"), @@ -273,18 +279,21 @@ class Subscription(Workflow, ModelSQL, ModelView): @classmethod @ModelView.button @Workflow.transition('draft') + @reset_employee('quoted_by', 'run_by') def draft(cls, subscriptions): pass @classmethod @ModelView.button @Workflow.transition('quotation') + @set_employee('quoted_by') def quote(cls, subscriptions): cls.set_number(subscriptions) @classmethod @ModelView.button @Workflow.transition('running') + @set_employee('run_by') def run(cls, subscriptions): pool = Pool() Line = pool.get('sale.subscription.line') diff --git a/view/subscription_form.xml b/view/subscription_form.xml index aec6def396..c883e6d030 100644 --- a/view/subscription_form.xml +++ b/view/subscription_form.xml @@ -40,6 +40,11 @@ this repository contains the full copyright notices and license terms. -->