From 822fbaad041c90de4222c8374139b476c70cf48c Mon Sep 17 00:00:00 2001 From: git_admin Date: Fri, 1 May 2026 14:19:51 +0000 Subject: [PATCH] Tower: upload om_recurring_payments 1.0.0 (via marketplace) --- .../models/recurring_template.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 addons/om_recurring_payments/models/recurring_template.py diff --git a/addons/om_recurring_payments/models/recurring_template.py b/addons/om_recurring_payments/models/recurring_template.py new file mode 100644 index 0000000..99410e1 --- /dev/null +++ b/addons/om_recurring_payments/models/recurring_template.py @@ -0,0 +1,42 @@ +from dateutil.relativedelta import relativedelta +from odoo import models, fields, api + + +class AccountRecurringTemplate(models.Model): + _name = 'account.recurring.template' + _description = 'Recurring Template' + _rec_name = 'name' + + name = fields.Char('Name', required=True) + journal_id = fields.Many2one('account.journal', 'Journal', required=True) + recurring_period = fields.Selection(selection=[('days', 'Days'), + ('weeks', 'Weeks'), + ('months', 'Months'), + ('years', 'Years')], store=True, required=True) + description = fields.Text('Description') + state = fields.Selection(selection=[('draft', 'Draft'), + ('done', 'Done')], default='draft', string='Status') + journal_state = fields.Selection(selection=[('draft', 'Un Posted'), + ('posted', 'Posted')], + required=True, default='draft', string='Generate Journal As') + recurring_interval = fields.Integer('Recurring Interval', default=1, required=True) + company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.company.id) + + @api.depends('date_begin', 'date_end') + def _compute_next_call(self): + for rec in self: + exec_date = rec.date_begin + relativedelta(days=rec.recurring_interval) + if exec_date <= rec.date_end: + rec.next_call = exec_date + else: + rec.state = 'done' + + def action_draft(self): + for rec in self: + rec.state = 'draft' + + def action_done(self): + for rec in self: + rec.state = 'done' + +