diff --git a/modules/account_dunning/CHANGELOG b/modules/account_dunning/CHANGELOG index 7fe3eef840..46766038d1 100644 --- a/modules/account_dunning/CHANGELOG +++ b/modules/account_dunning/CHANGELOG @@ -1,3 +1,4 @@ +* Permit the selection of companies for which to create dunnings Version 8.0.0 - 2026-04-20 -------------------------- diff --git a/modules/account_dunning/dunning.py b/modules/account_dunning/dunning.py index f42d9b07ea..78d6e0a723 100644 --- a/modules/account_dunning/dunning.py +++ b/modules/account_dunning/dunning.py @@ -335,12 +335,22 @@ class CreateDunningStart(ModelView): __name__ = 'account.dunning.create.start' date = fields.Date('Date', required=True, help="Create dunning 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.") @staticmethod def default_date(): Date = Pool().get('ir.date') return Date.today() + @classmethod + def default_companies(cls): + return Transaction().context.get('companies') + class CreateDunning(Wizard): __name__ = 'account.dunning.create' @@ -354,7 +364,14 @@ class CreateDunning(Wizard): def do_create_(self, action): pool = Pool() Dunning = pool.get('account.dunning') - Dunning.generate_dunnings(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): + Dunning.generate_dunnings(date=self.start.date) return action, {} diff --git a/modules/account_dunning/view/dunning_create_start_form.xml b/modules/account_dunning/view/dunning_create_start_form.xml index d92b879436..c5d4e0ff73 100644 --- a/modules/account_dunning/view/dunning_create_start_form.xml +++ b/modules/account_dunning/view/dunning_create_start_form.xml @@ -6,5 +6,7 @@ this repository contains the full copyright notices and license terms. -->