-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[17.0][UPD] advance_check_void: correct check numbers when multiple c…
…heck pages are used
- Loading branch information
Showing
3 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
import math | ||
from odoo import models, _ | ||
|
||
|
||
class PrintPreNumberedChecks(models.TransientModel): | ||
_inherit = 'print.prenumbered.checks' | ||
|
||
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: | ||
bills_per_check = self.env['ir.config_parameter'].sudo().get_param('advance_check_void.bills_per_check') or 9 | ||
payment.check_number = '%0{}d'.format(number_len) % check_number | ||
check_number += (math.ceil(len(payment.reconciled_bill_ids) / bills_per_check) or 1) | ||
return payments.do_print_checks() |