[REF] account, sale: some minor refactoring
that would allow to easily overwrite the printed report name and invoice/sale reports
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user