IC-Invoicing (Odoo-2-PG)
							parent
							
								
									a8cf531728
								
							
						
					
					
						commit
						4ac2f0ad4b
					
				|  | @ -73,6 +73,7 @@ | ||||||
|                 <field name="zip"/> |                 <field name="zip"/> | ||||||
|                 <field name="city"/> |                 <field name="city"/> | ||||||
|                 <field name="ref"/> |                 <field name="ref"/> | ||||||
|  |                 <field name="portal_id" string="PID"/> | ||||||
|             </field> |             </field> | ||||||
|             <field name="email" position="replace"> |             <field name="email" position="replace"> | ||||||
|                 <field name="email" invisible="1"/> |                 <field name="email" invisible="1"/> | ||||||
|  |  | ||||||
|  | @ -20,3 +20,4 @@ | ||||||
| ############################################################################## | ############################################################################## | ||||||
| 
 | 
 | ||||||
| from . import models | from . import models | ||||||
|  | from . import wizards | ||||||
|  |  | ||||||
|  | @ -35,6 +35,7 @@ | ||||||
|     'data': [ |     'data': [ | ||||||
|         'views/account_views.xml', |         'views/account_views.xml', | ||||||
|         'views/res_company_views.xml', |         'views/res_company_views.xml', | ||||||
|  |         'wizards/wizard_tz_ic.xml', | ||||||
|         'security/ir.model.access.csv', |         'security/ir.model.access.csv', | ||||||
|     ], |     ], | ||||||
|     'installable': True, |     'installable': True, | ||||||
|  |  | ||||||
|  | @ -36,6 +36,9 @@ class AccountInvoice(models.Model): | ||||||
|     charge_further = fields.Boolean(string='Weiterverrechnen', compute='_compute_charge_further', store=True, |     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') |                                     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 |     @api.multi | ||||||
|     def _compute_inter_company_supplier_isset(self): |     def _compute_inter_company_supplier_isset(self): | ||||||
|         for record in self: |         for record in self: | ||||||
|  |  | ||||||
|  | @ -6,11 +6,12 @@ | ||||||
|         <field name="model">account.invoice</field> |         <field name="model">account.invoice</field> | ||||||
|         <field name="inherit_id" ref="account.invoice_form"/> |         <field name="inherit_id" ref="account.invoice_form"/> | ||||||
|         <field name="arch" type="xml"> |         <field name="arch" type="xml"> | ||||||
|             <xpath expr="//button[@name='action_invoice_cancel']" position="after"> | <!--            <xpath expr="//button[@name='action_invoice_cancel']" position="after"> | ||||||
|                 <button name="reimburse_invoice" type="object" |                 <button name="reimburse_invoice" type="object" | ||||||
|                         attrs="{'invisible': ['|', ('state', '=', 'draft'), '|', ('reimburse_invoice_id', '!=', False), '|', ('type', '!=', 'out_invoice'), ('charge_further', '=', False)]}" |                         attrs="{'invisible': ['|', ('state', '=', 'draft'), '|', ('reimburse_invoice_id', '!=', False), '|', ('type', '!=', 'out_invoice'), ('charge_further', '=', False)]}" | ||||||
|                         string="Weiterverrechnen" groups="account.group_account_invoice"/> |                         string="Weiterverrechnen" groups="account.group_account_invoice"/> | ||||||
|             </xpath> |             </xpath> | ||||||
|  | --> | ||||||
|             <field name="payment_term_id" position="after"> |             <field name="payment_term_id" position="after"> | ||||||
|                 <label for="charge_further"/> |                 <label for="charge_further"/> | ||||||
|                 <div class="o_row" name="charge_further"> |                 <div class="o_row" name="charge_further"> | ||||||
|  | @ -18,7 +19,12 @@ | ||||||
|                     <button class="btn btn-primary" type="object" name="action_set_all_wv_flag" string="Setzen"/> |                     <button class="btn btn-primary" type="object" name="action_set_all_wv_flag" string="Setzen"/> | ||||||
|                     <button class="btn btn-primary" type="object" name="action_unset_all_wv_flag" string="Löschen"/> |                     <button class="btn btn-primary" type="object" name="action_unset_all_wv_flag" string="Löschen"/> | ||||||
|                 </div> |                 </div> | ||||||
|                 <field name="reimburse_invoice_id"/> |                 <field name="reimburse_invoice_id" attrs="{'invisible':True}"/> | ||||||
|  |                 <field name="pg_ic_num"/> | ||||||
|  |                 <field name="pg_ic_flag"/> | ||||||
|  | <!-- | ||||||
|  |                 <field name="pg_ic_flag" attrs="{'readonly':[('state','not in',('draft','sent'))]}"/> | ||||||
|  | --> | ||||||
|             </field> |             </field> | ||||||
| 
 | 
 | ||||||
|             <xpath expr="//field[@name='invoice_line_ids']/tree//field[@name='account_id']" position="before"> |             <xpath expr="//field[@name='invoice_line_ids']/tree//field[@name='account_id']" position="before"> | ||||||
|  | @ -42,6 +48,30 @@ | ||||||
|         </field> |         </field> | ||||||
|     </record> |     </record> | ||||||
| 
 | 
 | ||||||
|  |     <record id="view_account_invoice_filter_tz" model="ir.ui.view"> | ||||||
|  |         <field name="name">account.invoice.select</field> | ||||||
|  |         <field name="model">account.invoice</field> | ||||||
|  |         <field name="inherit_id" ref="account.view_account_invoice_filter"/> | ||||||
|  |         <field name="arch" type="xml"> | ||||||
|  |             <field name="journal_id" position="after"> | ||||||
|  |                 <field name="pg_ic_num" string="IC-Nummer"/> | ||||||
|  |             </field> | ||||||
|  |         </field> | ||||||
|  |     </record> | ||||||
|  | 
 | ||||||
|  |     <record id="account_invoice_tree_view_tz" model="ir.ui.view"> | ||||||
|  |         <field name="name">account_invoice_tree_view_tz</field> | ||||||
|  |         <field name="model">account.invoice</field> | ||||||
|  |         <field name="inherit_id" ref="account.invoice_tree"/> | ||||||
|  |         <field name="arch" type="xml"> | ||||||
|  |             <field name="number" position="after"> | ||||||
|  |                 <field name="pg_ic_num" string="IC-Num"/> | ||||||
|  |                 <field name="pg_ic_flag" string="IC"/> | ||||||
|  |             </field> | ||||||
|  |         </field> | ||||||
|  |     </record> | ||||||
|  | 
 | ||||||
|  | <!-- | ||||||
|     <record id="action_reimburse_invoice" model="ir.actions.server"> |     <record id="action_reimburse_invoice" model="ir.actions.server"> | ||||||
|         <field name="name">Intern Weiterverrechnen</field> |         <field name="name">Intern Weiterverrechnen</field> | ||||||
|         <field name="model_id" ref="account.model_account_invoice"/> |         <field name="model_id" ref="account.model_account_invoice"/> | ||||||
|  | @ -50,5 +80,6 @@ | ||||||
|         <field name="state">code</field> |         <field name="state">code</field> | ||||||
|         <field name="code">records.reimburse_invoice()</field> |         <field name="code">records.reimburse_invoice()</field> | ||||||
|     </record> |     </record> | ||||||
|  | --> | ||||||
| 
 | 
 | ||||||
| </odoo> | </odoo> | ||||||
|  |  | ||||||
|  | @ -0,0 +1 @@ | ||||||
|  | from . import wizard_tz_ic | ||||||
|  | @ -0,0 +1,42 @@ | ||||||
|  | # Copyright 2018-Today datenpol gmbh (<http://www.datenpol.at>) | ||||||
|  | # 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 | ||||||
|  | @ -0,0 +1,40 @@ | ||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <!-- Copyright 2018-Today datenpol gmbh(<http://www.datenpol.at>) | ||||||
|  |      License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). --> | ||||||
|  | 
 | ||||||
|  | <odoo> | ||||||
|  | 
 | ||||||
|  |     <record id="view_wizard_tz_ic_form" model="ir.ui.view"> | ||||||
|  |         <field name="name">view_wizard_tz_ic_form</field> | ||||||
|  |         <field name="model">wizard.tz.ic</field> | ||||||
|  |         <field name="arch" type="xml"> | ||||||
|  |             <form string="Wizard Import TZBox"> | ||||||
|  |                 <group> | ||||||
|  |                     <p>Wollen Sie für diese Rechnungen eine IC-Rechnung erstellen?</p> | ||||||
|  |                 </group> | ||||||
|  |                 <group> | ||||||
|  |                     <field name="new_pg_ic_num" string="IC-Nummer"/> | ||||||
|  |                 </group> | ||||||
|  |                 <footer> | ||||||
|  |                     <button name="button_tz_ic" | ||||||
|  |                             string="IC-Rechnung vorbereiten" | ||||||
|  |                             class="btn-primary" | ||||||
|  |                             type="object"/> | ||||||
|  |                     <button string="Abbrechen" | ||||||
|  |                             class="btn-default" | ||||||
|  |                             special="cancel"/> | ||||||
|  |                 </footer> | ||||||
|  |             </form> | ||||||
|  |         </field> | ||||||
|  |     </record> | ||||||
|  | 
 | ||||||
|  |     <act_window id="action_wizard_tz_ic" | ||||||
|  |         name="IC-Rechnung vorbereiten" | ||||||
|  |         src_model="account.invoice" | ||||||
|  |         res_model="wizard.tz.ic" | ||||||
|  |         view_type="form" | ||||||
|  |         view_mode="form" | ||||||
|  |         key2="client_action_multi" | ||||||
|  |         target="new"/> | ||||||
|  | 
 | ||||||
|  | </odoo> | ||||||
		Loading…
	
		Reference in New Issue