From 8532166c1e525893bf76ad0145494d142b9c5c00 Mon Sep 17 00:00:00 2001 From: Ahmed Aly Date: Wed, 11 Apr 2018 15:17:12 +0200 Subject: [PATCH] =?UTF-8?q?Fall=205430:=20=C3=84nderungsw=C3=BCnsche=20-?= =?UTF-8?q?=20Andruck=20Zolltarifnummer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ext/custom-addons/dp_custom/__manifest__.py | 1 + ext/custom-addons/dp_custom/models/account.py | 18 +++++++++++ .../dp_custom/views/dp_custom_views.xml | 10 ++++++ .../dp_custom/wizards/__init__.py | 1 + .../wizards/wizard_confirm_print_invoice.py | 18 +++++++++++ .../wizards/wizard_confirm_print_invoice.xml | 32 +++++++++++++++++++ .../models/report_helper.py | 4 --- .../dp_reports_account/reports/invoice.xml | 8 +++-- 8 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 ext/custom-addons/dp_custom/wizards/wizard_confirm_print_invoice.py create mode 100644 ext/custom-addons/dp_custom/wizards/wizard_confirm_print_invoice.xml diff --git a/ext/custom-addons/dp_custom/__manifest__.py b/ext/custom-addons/dp_custom/__manifest__.py index 6ed9cc3f..5043ebc1 100644 --- a/ext/custom-addons/dp_custom/__manifest__.py +++ b/ext/custom-addons/dp_custom/__manifest__.py @@ -43,6 +43,7 @@ 'views/commission_account.xml', 'wizards/wizard_confirm_production.xml', 'wizards/portal_assign_company.xml', + 'wizards/wizard_confirm_print_invoice.xml', 'security/security.xml', 'data/dp_custom_data.xml', 'data/glaser_company_data.xml', diff --git a/ext/custom-addons/dp_custom/models/account.py b/ext/custom-addons/dp_custom/models/account.py index 51b43852..7348998a 100644 --- a/ext/custom-addons/dp_custom/models/account.py +++ b/ext/custom-addons/dp_custom/models/account.py @@ -121,3 +121,21 @@ class AccountInvoice(models.Model): elif currency_obj and currency_obj.position == 'before': res = '%s %s' % (currency_obj.symbol, res) return res + + @api.multi + def print_intrastat_invoice(self): + self.ensure_one() + info = "Bei folgenden Produkten fehlt die Zolltarifnummer:\n" + intrastrat_not_set = False + 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: + info += invoice_line.name + "\n" + intrastrat_not_set = True + if intrastrat_not_set: + action = self.env.ref('dp_custom.action_wizard_confirm_print_invoice').read()[0] + action['context'] = '{"default_info": "'+info+'"}' + return action + return self.env.ref('dp_reports_account.account_invoices_with_intrastat').report_action(self) + + diff --git a/ext/custom-addons/dp_custom/views/dp_custom_views.xml b/ext/custom-addons/dp_custom/views/dp_custom_views.xml index 1d77a6b3..29262140 100644 --- a/ext/custom-addons/dp_custom/views/dp_custom_views.xml +++ b/ext/custom-addons/dp_custom/views/dp_custom_views.xml @@ -1,4 +1,14 @@ + + Rechnung mit Zolltarifnummer + ir.actions.server + + + code + action = record.print_intrastat_invoice() + report + + diff --git a/ext/custom-addons/dp_custom/wizards/__init__.py b/ext/custom-addons/dp_custom/wizards/__init__.py index 25fb3622..9d83ef0f 100644 --- a/ext/custom-addons/dp_custom/wizards/__init__.py +++ b/ext/custom-addons/dp_custom/wizards/__init__.py @@ -1,2 +1,3 @@ from . import wizard_confirm_production +from . import wizard_confirm_print_invoice from . import portal_assign_company diff --git a/ext/custom-addons/dp_custom/wizards/wizard_confirm_print_invoice.py b/ext/custom-addons/dp_custom/wizards/wizard_confirm_print_invoice.py new file mode 100644 index 00000000..e2122016 --- /dev/null +++ b/ext/custom-addons/dp_custom/wizards/wizard_confirm_print_invoice.py @@ -0,0 +1,18 @@ +# Copyright 2018-Today datenpol gmbh () +# License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). + +from odoo import fields, models + + +class ConfirmPrintInvoice(models.TransientModel): + _name = 'wizard.confirm_print_invoice' + _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('active_ids', [])) + + return self.env.ref('dp_reports_account.account_invoices_with_intrastat').report_action(invoice) diff --git a/ext/custom-addons/dp_custom/wizards/wizard_confirm_print_invoice.xml b/ext/custom-addons/dp_custom/wizards/wizard_confirm_print_invoice.xml new file mode 100644 index 00000000..e577860c --- /dev/null +++ b/ext/custom-addons/dp_custom/wizards/wizard_confirm_print_invoice.xml @@ -0,0 +1,32 @@ + + + + + + + wizard_confirm_print_invoice_form_view + wizard.confirm_print_invoice + +
+ + + +
+
+
+
+
+ + + Bestätige Rechnungsdruck + ir.actions.act_window + wizard.confirm_print_invoice + new + form + form + + +
diff --git a/ext/custom-addons/dp_reports_account/models/report_helper.py b/ext/custom-addons/dp_reports_account/models/report_helper.py index 6f18af7c..a64d5e32 100644 --- a/ext/custom-addons/dp_reports_account/models/report_helper.py +++ b/ext/custom-addons/dp_reports_account/models/report_helper.py @@ -32,10 +32,6 @@ class AccountInvoiceWithIntrastat(models.AbstractModel): def get_report_values(self, docids, data=None): model = 'account.invoice' docs = self.env[model].browse(docids) - for doc in docs: - for line in doc.invoice_line_ids: - if not line.intrastat_id: - raise ValidationError(_('Es muss bei allen Produkten/Lots eine Zolltarifnummer hinterlegt sein!')) return { 'doc_ids': docids, 'doc_model': model, diff --git a/ext/custom-addons/dp_reports_account/reports/invoice.xml b/ext/custom-addons/dp_reports_account/reports/invoice.xml index 38ff7729..3debc25e 100644 --- a/ext/custom-addons/dp_reports_account/reports/invoice.xml +++ b/ext/custom-addons/dp_reports_account/reports/invoice.xml @@ -107,7 +107,7 @@ - - + - @@ -152,7 +152,7 @@
- + Zolltarif Nr.:
@@ -163,7 +163,8 @@ - + @@ -273,6 +274,7 @@ 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" />