From 0f223d5b73cd5e0dd6726a551ded1fab35b4cacc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 4 Sep 2026 22:10:07 +0200 Subject: [PATCH] Permit the selection of companies for which to create direct debits Closes #15067 --- modules/account_payment/CHANGELOG | 1 + modules/account_payment/account.py | 19 ++++++++++++++++++- .../move_line_create_direct_debit_form.xml | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/account_payment/CHANGELOG b/modules/account_payment/CHANGELOG index cacd855a45..4cdbe7a1e5 100644 --- a/modules/account_payment/CHANGELOG +++ b/modules/account_payment/CHANGELOG @@ -1,3 +1,4 @@ +* Permit the selection of companies for which to create direct debits Version 8.0.0 - 2026-04-20 -------------------------- diff --git a/modules/account_payment/account.py b/modules/account_payment/account.py index 180081f027..455cf216eb 100644 --- a/modules/account_payment/account.py +++ b/modules/account_payment/account.py @@ -351,7 +351,14 @@ class CreateDirectDebit(Wizard): def do_create_(self, action): pool = Pool() Line = pool.get('account.move.line') - payments = Line.pay_direct_debit(date=self.start.date) + User = pool.get('res.user') + transaction = Transaction() + + companies = {c.id for c in self.start.companies} + companies &= set(User.get_companies()) + + with transaction.set_context(_companies=companies): + payments = Line.pay_direct_debit(date=self.start.date) action['domains'] = [] return action, { 'res_id': [p.id for p in payments], @@ -364,11 +371,21 @@ class CreateDirectDebitStart(ModelView): date = fields.Date( "Date", required=True, help="Create direct debit for lines due up to this date.") + companies = fields.Many2Many( + 'company.company', None, None, "Companies", required=True, + domain=[ + ('id', 'in', Eval('context', {}).get('companies', [])), + ], + help="Limit to lines from these companies.") @classmethod def default_date(cls): return Pool().get('ir.date').today() + @classmethod + def default_companies(cls): + return Transaction().context.get('companies') + class PayLineStart(ModelView): __name__ = 'account.move.line.pay.start' diff --git a/modules/account_payment/view/move_line_create_direct_debit_form.xml b/modules/account_payment/view/move_line_create_direct_debit_form.xml index f5ef7eccbb..8c6e01accd 100644 --- a/modules/account_payment/view/move_line_create_direct_debit_form.xml +++ b/modules/account_payment/view/move_line_create_direct_debit_form.xml @@ -6,5 +6,7 @@ this repository contains the full copyright notices and license terms. -->