From 194c38f09d2a76aaec6a514f86484eb8e9b6e08c Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Mon, 18 Sep 2017 22:00:37 +0200 Subject: [PATCH] [REF] account, sale: some minor refactoring that would allow to easily overwrite the printed report name and invoice/sale reports --- addons/account/models/account_invoice.py | 12 +++++++++++ addons/account/views/account_report.xml | 20 ++----------------- addons/account/views/report_invoice.xml | 2 +- .../sale/report/invoice_report_templates.xml | 2 +- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 1e76dbc4b63..5f9b93f0d85 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -431,6 +431,18 @@ class AccountInvoice(models.Model): sequence = journal_sequence._get_current_sequence() sequence.number_next = int(result.group(2)) + @api.multi + def _get_printed_report_name(self): + self.ensure_one() + return self.type == 'out_invoice' and self.state == 'draft' and _('Draft Invoice') or \ + self.type == 'out_invoice' and self.state in ('open','paid') and _('Invoice - %s') % (self.number) or \ + self.type == 'out_refund' and self.state == 'draft' and _('Credit Note') or \ + self.type == 'out_refund' and _('Credit Note - %s') % (self.number) or \ + self.type == 'in_invoice' and self.state == 'draft' and _('Vendor Bill') or \ + self.type == 'in_invoice' and self.state in ('open','paid') and _('Vendor Bill - %s') % (self.number) or \ + self.type == 'in_refund' and self.state == 'draft' and _('Vendor Credit Note') or \ + self.type == 'in_refund' and _('Vendor Credit Note - %s') % (self.number) + @api.model def create(self, vals): onchanges = { diff --git a/addons/account/views/account_report.xml b/addons/account/views/account_report.xml index c6f3ba536ff..6328d865c2c 100644 --- a/addons/account/views/account_report.xml +++ b/addons/account/views/account_report.xml @@ -10,15 +10,7 @@ name="account.report_invoice_with_payments" file="account.report_invoice_with_payments" attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')" - print_report_name="( - object.type == 'out_invoice' and object.state == 'draft' and 'Draft Invoice' or - object.type == 'out_invoice' and object.state in ('open','paid') and 'Invoice - %s' % (object.number) or - object.type == 'out_refund' and object.state == 'draft' and 'Credit Note' or - object.type == 'out_refund' and 'Credit Note - %s' % (object.number) or - object.type == 'in_invoice' and object.state == 'draft' and 'Vendor Bill' or - object.type == 'in_invoice' and object.state in ('open','paid') and 'Vendor Bill - %s' % (object.number) or - object.type == 'in_refund' and object.state == 'draft' and 'Vendor Credit Note' or - object.type == 'in_refund' and 'Vendor Credit Note - %s' % (object.number))" + print_report_name="(object._get_printed_report_name())" /> - +
diff --git a/addons/sale/report/invoice_report_templates.xml b/addons/sale/report/invoice_report_templates.xml index bf806ebce3b..672fc817422 100644 --- a/addons/sale/report/invoice_report_templates.xml +++ b/addons/sale/report/invoice_report_templates.xml @@ -13,7 +13,7 @@ !sale.group_sale_layout - +
Description