Permit the selection of companies for which to create direct debits

Closes #15067
This commit is contained in:
Cédric Krier
2026-09-04 22:10:07 +02:00
parent e428655c1e
commit 0f223d5b73
3 changed files with 21 additions and 1 deletions
+1
View File
@@ -1,3 +1,4 @@
* Permit the selection of companies for which to create direct debits
Version 8.0.0 - 2026-04-20
--------------------------
+18 -1
View File
@@ -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'
@@ -6,5 +6,7 @@ this repository contains the full copyright notices and license terms. -->
<group col="2" xexpand="1" id="create_date">
<label string="Create Direct Debit for date" id="create"/>
<field name="date"/>
<field name="companies" colspan="2"/>
</group>
</form>