Initial commit: Accounting packages

This commit is contained in:
Ernad Husremovic 2025-08-29 15:20:47 +02:00
commit 4ef34c2317
2661 changed files with 1709616 additions and 0 deletions

View file

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import print_prenumbered_checks

View file

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import re
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
class PrintPreNumberedChecks(models.TransientModel):
_name = 'print.prenumbered.checks'
_description = 'Print Pre-numbered Checks'
next_check_number = fields.Char('Next Check Number', required=True)
@api.constrains('next_check_number')
def _check_next_check_number(self):
for check in self:
if check.next_check_number and not re.match(r'^[0-9]+$', check.next_check_number):
raise ValidationError(_('Next Check Number should only contains numbers.'))
def print_checks(self):
check_number = int(self.next_check_number)
number_len = len(self.next_check_number or "")
payments = self.env['account.payment'].browse(self.env.context['payment_ids'])
payments.filtered(lambda r: r.state == 'draft').action_post()
payments.filtered(lambda r: r.state == 'posted' and not r.is_move_sent).write({'is_move_sent': True})
for payment in payments:
payment.check_number = '%0{}d'.format(number_len) % check_number
check_number += 1
checks_action = payments.do_print_checks()
checks_action.update({'close_on_report_download': True})
return checks_action

View file

@ -0,0 +1,22 @@
<?xml version="1.0" ?>
<odoo>
<record id="print_pre_numbered_checks_view" model="ir.ui.view">
<field name="name">Print Pre-numbered Checks</field>
<field name="model">print.prenumbered.checks</field>
<field name="arch" type="xml">
<form string="Print Pre-numbered Checks">
<p>Please enter the number of the first pre-printed check that you are about to print on.</p>
<p>This will allow to save on payments the number of the corresponding check.</p>
<group>
<field name="next_check_number"/>
</group>
<footer>
<button name="print_checks" string="Print" type="object" class="oe_highlight" data-hotkey="q"/>
<button string="Cancel" class="btn btn-secondary" special="cancel" data-hotkey="z"/>
</footer>
</form>
</field>
</record>
</odoo>