mirror of
https://gitlab.com/flectra-community/l10n-switzerland-flectra.git
synced 2024-12-24 13:21:46 +00:00
14a109dc87
[ADD] l10n_ch_zip [ADD] l10n_ch_bank_statement_import_postfinance
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
# Copyright 2017 Camptocamp SA
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
|
|
from flectra import models, fields, api
|
|
from flectra.exceptions import UserError
|
|
|
|
|
|
class ISRBatchPrintWizard(models.TransientModel):
|
|
|
|
_name = 'isr.batch.print.wizard'
|
|
|
|
invoice_ids = fields.Many2many(comodel_name='account.move',string='Invoices',ondelete ='cascade')
|
|
error_message = fields.Text('Errors', readonly=True)
|
|
|
|
@api.model
|
|
def default_get(self, fields):
|
|
res = super(ISRBatchPrintWizard, self).default_get(fields)
|
|
active_ids = self.env.context.get('active_ids')
|
|
if active_ids:
|
|
invoices = self.env['account.invoice'].browse(active_ids)
|
|
msg = self.check_generatable(invoices)
|
|
if msg:
|
|
res['error_message'] = msg
|
|
res['invoice_ids'] = active_ids
|
|
return res
|
|
|
|
@api.model
|
|
def check_generatable(self, invoices):
|
|
try:
|
|
invoices._check_isr_generatable()
|
|
except UserError as e:
|
|
return e.name
|
|
|
|
#@api.multi
|
|
def print_payment_slips(self):
|
|
if self.invoice_ids:
|
|
return self.invoice_ids.print_isr()
|
|
else:
|
|
return {'type': 'ir.actions.act_window_close'}
|