From ed5b129685412e656c69b4a7e0a4e4001f6c4ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 31 Mar 2015 10:03:28 +0200 Subject: [PATCH] Create commission only the first time invoice is posted The invoice can go back to posted state when paid if the payment is unreconciled. issue4682 review12071002 --- invoice.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/invoice.py b/invoice.py index 3f1be7e05e..3b4bc20a2b 100644 --- a/invoice.py +++ b/invoice.py @@ -29,8 +29,11 @@ class Invoice: @ModelView.button @Workflow.transition('posted') def post(cls, invoices): + # Create commission only the first time the invoice is posted + to_commission = [i for i in invoices + if i.state not in ['posted', 'paid']] super(Invoice, cls).post(invoices) - cls.create_commissions(invoices) + cls.create_commissions(to_commission) @classmethod def create_commissions(cls, invoices):