diff --git a/ext/custom-addons/dp_custom/views/res_partner_views.xml b/ext/custom-addons/dp_custom/views/res_partner_views.xml index da040b72..0282dc15 100644 --- a/ext/custom-addons/dp_custom/views/res_partner_views.xml +++ b/ext/custom-addons/dp_custom/views/res_partner_views.xml @@ -73,6 +73,7 @@ + diff --git a/ext/custom-addons/dp_intercompany_invoicing/__init__.py b/ext/custom-addons/dp_intercompany_invoicing/__init__.py index 15bca215..a4a92031 100644 --- a/ext/custom-addons/dp_intercompany_invoicing/__init__.py +++ b/ext/custom-addons/dp_intercompany_invoicing/__init__.py @@ -20,3 +20,4 @@ ############################################################################## from . import models +from . import wizards diff --git a/ext/custom-addons/dp_intercompany_invoicing/__manifest__.py b/ext/custom-addons/dp_intercompany_invoicing/__manifest__.py index d333a251..952bf8ea 100644 --- a/ext/custom-addons/dp_intercompany_invoicing/__manifest__.py +++ b/ext/custom-addons/dp_intercompany_invoicing/__manifest__.py @@ -35,6 +35,7 @@ 'data': [ 'views/account_views.xml', 'views/res_company_views.xml', + 'wizards/wizard_tz_ic.xml', 'security/ir.model.access.csv', ], 'installable': True, diff --git a/ext/custom-addons/dp_intercompany_invoicing/models/account.py b/ext/custom-addons/dp_intercompany_invoicing/models/account.py index 3a475b9e..bee85fbc 100644 --- a/ext/custom-addons/dp_intercompany_invoicing/models/account.py +++ b/ext/custom-addons/dp_intercompany_invoicing/models/account.py @@ -36,6 +36,9 @@ class AccountInvoice(models.Model): charge_further = fields.Boolean(string='Weiterverrechnen', compute='_compute_charge_further', store=True, help='Ist gesetzt, wenn das WV-Flag von mindestens einer Zeile gesetzt ist') + pg_ic_num = fields.Char('PG_IC_Nummer') + pg_ic_flag = fields.Boolean(string='IC', help='Rechnung nach PG exportiert') + @api.multi def _compute_inter_company_supplier_isset(self): for record in self: diff --git a/ext/custom-addons/dp_intercompany_invoicing/views/account_views.xml b/ext/custom-addons/dp_intercompany_invoicing/views/account_views.xml index 873e9fee..39e98c9f 100644 --- a/ext/custom-addons/dp_intercompany_invoicing/views/account_views.xml +++ b/ext/custom-addons/dp_intercompany_invoicing/views/account_views.xml @@ -6,11 +6,12 @@ account.invoice - + @@ -18,7 +19,12 @@ - + + + + @@ -42,6 +48,30 @@ + + account.invoice.select + account.invoice + + + + + + + + + + account_invoice_tree_view_tz + account.invoice + + + + + + + + + + diff --git a/ext/custom-addons/dp_intercompany_invoicing/wizards/__init__.py b/ext/custom-addons/dp_intercompany_invoicing/wizards/__init__.py new file mode 100644 index 00000000..4b78c74d --- /dev/null +++ b/ext/custom-addons/dp_intercompany_invoicing/wizards/__init__.py @@ -0,0 +1 @@ +from . import wizard_tz_ic diff --git a/ext/custom-addons/dp_intercompany_invoicing/wizards/wizard_tz_ic.py b/ext/custom-addons/dp_intercompany_invoicing/wizards/wizard_tz_ic.py new file mode 100644 index 00000000..43f42169 --- /dev/null +++ b/ext/custom-addons/dp_intercompany_invoicing/wizards/wizard_tz_ic.py @@ -0,0 +1,42 @@ +# 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 api, fields, models, _ +from odoo.exceptions import ValidationError + + +class WizardTzIc(models.TransientModel): + _name = 'wizard.tz.ic' + _description = 'Generiere IC-Rechnung' + + new_pg_ic_num = fields.Char() + + @api.multi + def button_tz_ic(self): + if not self.new_pg_ic_num: + raise ValidationError(_("Keine IC-Nummer angegeben")) + inv = self.env['account.invoice'] + ck_ivc = inv.search([('pg_ic_num', '=', self.new_pg_ic_num), ('pg_ic_flag', '=', True)], order='id ASC', + limit=1) + if ck_ivc: + info = 'IC-Nummer bereits bei folgenden Rechnungen vergegeben!' + for ivc in ck_ivc: + info += '\n %s' % ivc.number + raise ValidationError(_(info)) + for wizard in self: + error_at_ivc = False + info = 'Bitte prüfen Sie den Status folgender Rechnungen:' + active_ids = self.env.context.get('active_ids', []) + ivcs = self.env['account.invoice'].browse(active_ids) + if ivcs.exists(): + for ivc in ivcs: + if not ivc.charge_further or ivc.pg_ic_flag or (ivc.state in ['draft','cancel']): + info += '\n %s, WV=%s / IC_Flag=%s / Status=%s' % (ivc.number,ivc.charge_further,ivc.pg_ic_flag,ivc.state) + error_at_ivc = True + else: + ivc.pg_ic_num = self.new_pg_ic_num + if error_at_ivc: + raise ValidationError(_(info)) + action = self.env.ref('account.action_invoice_tree').read()[0] + action['domain'] = [('id', 'in', active_ids)] + return action diff --git a/ext/custom-addons/dp_intercompany_invoicing/wizards/wizard_tz_ic.xml b/ext/custom-addons/dp_intercompany_invoicing/wizards/wizard_tz_ic.xml new file mode 100644 index 00000000..30551b85 --- /dev/null +++ b/ext/custom-addons/dp_intercompany_invoicing/wizards/wizard_tz_ic.xml @@ -0,0 +1,40 @@ + + + + + + + view_wizard_tz_ic_form + wizard.tz.ic + + + + Wollen Sie für diese Rechnungen eine IC-Rechnung erstellen? + + + + + + + + + + + +
Wollen Sie für diese Rechnungen eine IC-Rechnung erstellen?