summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqdp-odoo <qdp@odoo.com>2017-09-18 22:00:37 +0200
committerqdp-odoo <qdp@odoo.com>2017-09-18 22:00:37 +0200
commit194c38f09d2a76aaec6a514f86484eb8e9b6e08c (patch)
tree83c9a0b90e81335e834943d9d0d64573140fd124
parentec96c0b3c252244066bea264e88867983969d6ee (diff)
[REF] account, sale: some minor refactoring
that would allow to easily overwrite the printed report name and invoice/sale reports
-rw-r--r--addons/account/models/account_invoice.py12
-rw-r--r--addons/account/views/account_report.xml20
-rw-r--r--addons/account/views/report_invoice.xml2
-rw-r--r--addons/sale/report/invoice_report_templates.xml2
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())"
/>
<report
@@ -29,15 +21,7 @@
name="account.report_invoice"
file="account.report_invoice"
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())"
/>
<report
diff --git a/addons/account/views/report_invoice.xml b/addons/account/views/report_invoice.xml
index cca8934e060..eec794ddd01 100644
--- a/addons/account/views/report_invoice.xml
+++ b/addons/account/views/report_invoice.xml
@@ -53,7 +53,7 @@
<!-- Is there a discount on at least one line? -->
<t t-set="display_discount" t-value="any([l.discount for l in o.invoice_line_ids])"/>
- <table class="table table-condensed">
+ <table class="table table-condensed" name="invoice_line_table">
<thead>
<tr>
<th>Description</th>
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 @@
<attribute name="groups">!sale.group_sale_layout</attribute>
</xpath>
<xpath expr="//table" position="after">
- <t groups="sale.group_sale_layout" t-foreach="o.order_lines_layouted()" t-as="page">
+ <t groups="sale.group_sale_layout" t-foreach="o.order_lines_layouted()" t-as="page" name="lines_layouted">
<table class="table table-condensed">
<thead>
<tr>