new functional printout of invoice with short-text description

develop
Andreas Osim 2021-01-20 17:50:35 +01:00
parent 51e7fcf0c0
commit ba52bcb5eb
6 changed files with 176 additions and 1 deletions

View File

@ -150,6 +150,11 @@ class AccountInvoice(models.Model):
res = '%s %s' % (currency_obj.symbol, res)
return res
@api.multi
def print_invoice_short(self):
self.ensure_one()
return self.env.ref('dp_reports_account.account_invoices_short').report_action(self)
@api.multi
def print_intrastat_invoice(self):
self.ensure_one()
@ -170,3 +175,24 @@ class AccountInvoice(models.Model):
action['context'] = str({"default_info": info, "invoice_ids": self.env.context.get("active_ids")})
return action
return self.env.ref('dp_reports_account.account_invoices_with_intrastat').report_action(self)
@api.multi
def print_intrastat_invoice_short(self):
self.ensure_one()
info = "Bei folgenden Produkten fehlt die Zolltarifnummer:\n"
intrastrat_not_set = False
position = 1
for invoice_line in self.invoice_line_ids:
if invoice_line.product_id and invoice_line.product_id.type != 'service':
if not invoice_line.intrastat_id and not invoice_line.hide_intrastat_code:
info += "Zeile: "+str(position)
if invoice_line.product_id.default_code:
info += "\tProduktcode: " + invoice_line.product_id.default_code
info += "\n"
intrastrat_not_set = True
position += 1
if intrastrat_not_set:
action = self.env.ref('dp_custom.action_wizard_confirm_print_invoice_short').read()[0]
action['context'] = str({"default_info": info, "invoice_ids": self.env.context.get("active_ids")})
return action
return self.env.ref('dp_reports_account.account_invoices_with_intrastat_short').report_action(self)

View File

@ -1,6 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="action_print_invoice_short" model="ir.actions.server">
<field name="name">Rechnung Kurztext</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="account.model_account_invoice"/>
<field name="binding_model_id" ref="account.model_account_invoice"/>
<field name="state">code</field>
<field name="code">action = record.print_invoice_short()</field>
<field name="binding_type">report</field>
</record>
<record id="action_print_intrastat_invoice" model="ir.actions.server">
<field name="name">Rechnung mit Zolltarifnummer</field>
<field name="type">ir.actions.server</field>
@ -11,4 +21,14 @@
<field name="binding_type">report</field>
</record>
<record id="action_print_intrastat_invoice_short" model="ir.actions.server">
<field name="name">Rechnung mit Zolltarifnummer Kurztext</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="account.model_account_invoice"/>
<field name="binding_model_id" ref="account.model_account_invoice"/>
<field name="state">code</field>
<field name="code">action = record.print_intrastat_invoice_short()</field>
<field name="binding_type">report</field>
</record>
</odoo>

View File

@ -18,3 +18,18 @@ class ConfirmPrintInvoice(models.TransientModel):
return {'type': 'ir.actions.act_window_close'}
return self.env.ref('dp_reports_account.account_invoices_with_intrastat').report_action(invoice)
class ConfirmPrintInvoiceShort(models.TransientModel):
_name = 'wizard.confirm_print_invoice_short'
_description = 'Bestätige Rechnungsdruck'
_order = 'name'
info = fields.Text('Info', readonly=True)
def print_invoice(self):
self.ensure_one()
invoice = self.env['account.invoice'].browse(self.env.context.get('invoice_ids', []))
if not invoice:
return {'type': 'ir.actions.act_window_close'}
return self.env.ref('dp_reports_account.account_invoices_with_intrastat_short').report_action(invoice)

View File

@ -29,4 +29,29 @@
<field name="view_mode">form</field>
</record>
<record id="wizard_confirm_print_invoice_form_view_short" model="ir.ui.view">
<field name="name">wizard_confirm_print_invoice_form_view_short</field>
<field name="model">wizard.confirm_print_invoice_short</field>
<field name="arch" type="xml">
<form string="Bestätige Rechnungsdruck">
<group>
<field name="info"/>
</group>
<footer>
<button name="print_invoice" string="Rechnung trotzdem drucken" class="btn-primary" type="object"/>
<button string="Abbrechen" class="btn-default" special="cancel"/>
</footer>
</form>
</field>
</record>
<record id="action_wizard_confirm_print_invoice_short" model="ir.actions.act_window">
<field name="name">Bestätige Rechnungsdruck</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">wizard.confirm_print_invoice_short</field>
<field name="target">new</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
</record>
</odoo>

View File

@ -49,6 +49,24 @@ class AccountInvoice(models.AbstractModel):
}
class AccountInvoiceShort(models.AbstractModel):
_name = 'report.dp_reports_account.report_invoice_short'
_inherit = 'report.account_abstract_report'
_template = 'dp_reports_account.report_invoice_short'
@api.model
def get_report_values(self, docids, data=None):
model = 'account.invoice'
docs = self.env[model].browse(docids)
return {
'doc_ids': docids,
'doc_model': model,
'docs': docs,
'data': data,
'field_set_in_lines': self._field_set_in_lines,
'formatLang': self._formatLang,
}
class AccountInvoiceWithIntrastat(models.AbstractModel):
_name = 'report.dp_reports_account.report_invoice_with_intrastat'
_inherit = 'report.account_abstract_report'
@ -66,3 +84,21 @@ class AccountInvoiceWithIntrastat(models.AbstractModel):
'field_set_in_lines': self._field_set_in_lines,
'formatLang': self._formatLang,
}
class AccountInvoiceWithIntrastatShort(models.AbstractModel):
_name = 'report.dp_reports_account.report_invoice_with_intrastat_short'
_inherit = 'report.account_abstract_report'
_template = 'dp_reports_account.report_invoice_with_intrastat_short'
@api.model
def get_report_values(self, docids, data=None):
model = 'account.invoice'
docs = self.env[model].browse(docids)
return {
'doc_ids': docids,
'doc_model': model,
'docs': docs,
'data': data,
'field_set_in_lines': self._field_set_in_lines,
'formatLang': self._formatLang,
}

View File

@ -200,7 +200,14 @@
<span t-field="invoice_line.intrastat_id"/>
<br/>
</span>
<span t-field="invoice_line.name"/>
<span t-if="shorttext">
<strong>Kurztext:</strong>
<span t-if="invoice_line.lot_id.short_text" t-field="invoice_line.lot_id.short_text"/>
<span t-if="not invoice_line.lot_id.short_text" t-field="invoice_line.name"/>
</span>
<span t-if="not shorttext">
<span t-field="invoice_line.name"/>
</span>
<span t-if="invoice_line.product_id.tracking=='serial'">
<br/>
<strong>Serien Nr.:</strong>
@ -325,6 +332,26 @@
</t>
</template>
<template id="report_invoice_with_intrastat_short">
<t t-call="web.html_container">
<t t-set="with_intrastat" t-value="True"/>
<t t-set="shorttext" t-value="True"/>
<t t-foreach="docs" t-as="o">
<t t-call="dp_reports_account.report_invoice_document" t-lang="o.partner_id.lang"/>
</t>
</t>
</template>
<template id="report_invoice_short">
<t t-call="web.html_container">
<t t-set="with_intrastat" t-value="False"/>
<t t-set="shorttext" t-value="True"/>
<t t-foreach="docs" t-as="o">
<t t-call="dp_reports_account.report_invoice_document" t-lang="o.partner_id.lang"/>
</t>
</t>
</template>
<record id="account.account_invoices" model="ir.actions.report">
<field name="paperformat_id" ref="dp_reports.paperformat_a4_european"/>
<field name="binding_model_id" eval="False"/>
@ -335,6 +362,19 @@
<field name="binding_model_id" eval="False"/>
</record>
<report
id="account_invoices_short"
model="account.invoice"
string="Rechnung Kurztext"
report_type="qweb-pdf"
name="dp_reports_account.report_invoice_short"
file="dp_reports_account.report_invoice_short"
attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
print_report_name="(object._get_printed_report_name())"
paperformat="dp_reports.paperformat_a4_european"
menu="False"
/>
<report
id="account_invoices_with_intrastat"
model="account.invoice"
@ -348,6 +388,19 @@
menu="False"
/>
<report
id="account_invoices_with_intrastat_short"
model="account.invoice"
string="Rechnung mit Zolltarifnummer Kurztext"
report_type="qweb-pdf"
name="dp_reports_account.report_invoice_with_intrastat_short"
file="dp_reports_account.report_invoice_with_intrastat_short"
attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
print_report_name="(object._get_printed_report_name())"
paperformat="dp_reports.paperformat_a4_european"
menu="False"
/>
<record id="account.account_invoices_without_payment" model="ir.actions.report">
<field name="name">Rechnung ohne Zolltarifnummer</field>
<field name="paperformat_id" ref="dp_reports.paperformat_a4_european"/>