Task 2005940
account:
* Use stored compute methods instead of default for
{out,in}bound_payment_method_ids
* Track is_move_sent in the chatter
* Split 'Invoices' and 'Bills' in the smart button of payment form
* Because account.payment.method can be shown on the res.partner form,
we need to relax the security level to readonly for all users
account_check_printing:
* Add the preferred payment method for partners, with a related on
account move allowing to do a group by and doing payments in batch
* Add a constraint to forbid twice the same check number in the same
journal
* The amount in words is now readonly to prevent typos and mismatches
with the amount in digits
* Remove the field `check_number_int`. The check number is kept as Char
so that '000012345' is not displayed (and printed) as '12,345' but it
is parsed so that comparison and incrementation are possible.
closes odoo/odoo#56179
Related: odoo/upgrade#1669
Related: odoo/enterprise#12527
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
# -*- 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
|
|
return payments.do_print_checks()
|