From 3d3e0b28dc5f6a0ae24e6f27069217e1ccf336ed Mon Sep 17 00:00:00 2001 From: alessandrocamilli Date: Wed, 14 Dec 2016 19:39:00 +0100 Subject: [PATCH 01/16] WT move and account move creation from reconcile [FIX] 10.0 api compat First beta Travis check Ref name [FIX] Compute WT only if the invoice has wt lines Added feature to unreconcile the wt move created by payment, and after it possible to re-reconcile --- l10n_it_withholding_tax_payment/__init__.py | 5 + .../__manifest__.py | 23 ++ .../data/sequence.xml | 14 + l10n_it_withholding_tax_payment/i18n/it.po | 249 ++++++++++++++++++ .../models/__init__.py | 6 + .../models/withholding_tax.py | 159 +++++++++++ .../security/ir.model.access.csv | 4 + .../views/withholding_tax.xml | 102 +++++++ .../wizard/__init__.py | 6 + .../wizard/create_move_payment.py | 30 +++ .../wizard/create_move_payment_view.xml | 40 +++ l10n_it_withholding_tax_payment/workflow.xml | 48 ++++ 12 files changed, 686 insertions(+) create mode 100644 l10n_it_withholding_tax_payment/__init__.py create mode 100644 l10n_it_withholding_tax_payment/__manifest__.py create mode 100644 l10n_it_withholding_tax_payment/data/sequence.xml create mode 100644 l10n_it_withholding_tax_payment/i18n/it.po create mode 100644 l10n_it_withholding_tax_payment/models/__init__.py create mode 100644 l10n_it_withholding_tax_payment/models/withholding_tax.py create mode 100644 l10n_it_withholding_tax_payment/security/ir.model.access.csv create mode 100644 l10n_it_withholding_tax_payment/views/withholding_tax.xml create mode 100644 l10n_it_withholding_tax_payment/wizard/__init__.py create mode 100644 l10n_it_withholding_tax_payment/wizard/create_move_payment.py create mode 100644 l10n_it_withholding_tax_payment/wizard/create_move_payment_view.xml create mode 100644 l10n_it_withholding_tax_payment/workflow.xml diff --git a/l10n_it_withholding_tax_payment/__init__.py b/l10n_it_withholding_tax_payment/__init__.py new file mode 100644 index 000000000000..eea7f1a56c73 --- /dev/null +++ b/l10n_it_withholding_tax_payment/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright © 2015 Alessandro Camilli () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models, wizard diff --git a/l10n_it_withholding_tax_payment/__manifest__.py b/l10n_it_withholding_tax_payment/__manifest__.py new file mode 100644 index 000000000000..49c57e65ffaa --- /dev/null +++ b/l10n_it_withholding_tax_payment/__manifest__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright © 2015 Alessandro Camilli () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + 'name': 'Italian Withholding Tax Payment', + 'version': '10.0.1.0.0', + 'category': 'Account', + 'author': 'Openforce, Odoo Italia Network, ' + 'Odoo Community Association (OCA)', + 'website': 'https://odoo-community.org/', + 'license': 'AGPL-3', + "depends": ['account'], + "data": [ + 'views/withholding_tax.xml', + 'workflow.xml', + 'security/ir.model.access.csv', + 'data/sequence.xml', + 'wizard/create_move_payment_view.xml', + ], + "active": False, + "installable": True +} diff --git a/l10n_it_withholding_tax_payment/data/sequence.xml b/l10n_it_withholding_tax_payment/data/sequence.xml new file mode 100644 index 000000000000..2f0c8c10c8c0 --- /dev/null +++ b/l10n_it_withholding_tax_payment/data/sequence.xml @@ -0,0 +1,14 @@ + + + + + + Withholding Tax Move Payment Number + withholding.tax.move.payment + + WTMP/ + + + + + \ No newline at end of file diff --git a/l10n_it_withholding_tax_payment/i18n/it.po b/l10n_it_withholding_tax_payment/i18n/it.po new file mode 100644 index 000000000000..a5fe7ca267fa --- /dev/null +++ b/l10n_it_withholding_tax_payment/i18n/it.po @@ -0,0 +1,249 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_withholding_tax_payment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-15 10:35+0000\n" +"PO-Revision-Date: 2016-12-15 10:35+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_account_id +#. module: l10n_it_withholding_tax_payment +msgid "Account" +msgstr "Conto" + +#: model:ir.ui.view,arch_db:l10n_it_withholding_tax_payment.view_withholding_move_payment_form +#. module: l10n_it_withholding_tax_payment +msgid "Account Setting" +msgstr "Impostazioni Contabili" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_move_id +#. module: l10n_it_withholding_tax_payment +msgid "Account move" +msgstr "Registrazione Contabile" + +#: model:ir.ui.view,arch_db:l10n_it_withholding_tax_payment.wizard_wt_move_payment_create_view +#. module: l10n_it_withholding_tax_payment +msgid "Cancel" +msgstr "Annulla" + +#: model:ir.ui.view,arch_db:l10n_it_withholding_tax_payment.view_withholding_move_payment_form +#. module: l10n_it_withholding_tax_payment +msgid "Confirm" +msgstr "Conferma" + +#: selection:withholding.tax.move.payment,state:0 +#. module: l10n_it_withholding_tax_payment +msgid "Confirmed" +msgstr "Confermata" + +#: model:ir.ui.view,arch_db:l10n_it_withholding_tax_payment.view_withholding_move_payment_form +#. module: l10n_it_withholding_tax_payment +msgid "Create Account Move" +msgstr "Crea Registrazione" + +#: model:ir.actions.act_window,name:l10n_it_withholding_tax_payment.wizard_wt_move_payment_create_action +#: model:ir.ui.view,arch_db:l10n_it_withholding_tax_payment.wizard_wt_move_payment_create_view +#. module: l10n_it_withholding_tax_payment +msgid "Create Move Payment" +msgstr "Crea Versamento" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_create_uid +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_wizard_wt_move_payment_create_create_uid +#. module: l10n_it_withholding_tax_payment +msgid "Created by" +msgstr "Creato da" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_create_date +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_wizard_wt_move_payment_create_create_date +#. module: l10n_it_withholding_tax_payment +msgid "Created on" +msgstr "Creato il" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_date +#. module: l10n_it_withholding_tax_payment +msgid "Date" +msgstr "Data" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_date_payment +#. module: l10n_it_withholding_tax_payment +msgid "Date Payment" +msgstr "Data Versamento" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_date_start +#. module: l10n_it_withholding_tax_payment +msgid "Date Start" +msgstr "Data inizio" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_date_stop +#. module: l10n_it_withholding_tax_payment +msgid "Date Stop" +msgstr "Data fine" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_display_name +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_wizard_wt_move_payment_create_display_name +#. module: l10n_it_withholding_tax_payment +msgid "Display Name" +msgstr "Nome Visualizzato" + +#: selection:withholding.tax.move.payment,state:0 +#. module: l10n_it_withholding_tax_payment +msgid "Draft" +msgstr "Bozza" + +#: model:ir.ui.view,arch_db:l10n_it_withholding_tax_payment.wizard_wt_move_payment_create_view +#. module: l10n_it_withholding_tax_payment +msgid "Generate" +msgstr "Genera" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_id +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_wizard_wt_move_payment_create_id +#. module: l10n_it_withholding_tax_payment +msgid "ID" +msgstr "ID" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_journal_id +#. module: l10n_it_withholding_tax_payment +msgid "Journal" +msgstr "Sezionale" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment___last_update +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_wizard_wt_move_payment_create___last_update +#. module: l10n_it_withholding_tax_payment +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_write_uid +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_wizard_wt_move_payment_create_write_uid +#. module: l10n_it_withholding_tax_payment +msgid "Last Updated by" +msgstr "Ultima modifica di" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_write_date +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_wizard_wt_move_payment_create_write_date +#. module: l10n_it_withholding_tax_payment +msgid "Last Updated on" +msgstr "Ultima modifica il" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_line_ids +#. module: l10n_it_withholding_tax_payment +msgid "Lines" +msgstr "Righe" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_wt_move_payment_id +#. module: l10n_it_withholding_tax_payment +msgid "Move Payment" +msgstr "Versamento Ritenuta" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_name +#. module: l10n_it_withholding_tax_payment +msgid "Name" +msgstr "Nome" + +#: model:ir.ui.view,arch_db:l10n_it_withholding_tax_payment.view_withholding_move_payment_form +#. module: l10n_it_withholding_tax_payment +msgid "Period" +msgstr "Periodo" + +#: model:ir.ui.view,arch_db:l10n_it_withholding_tax_payment.view_withholding_move_payment_form +#. module: l10n_it_withholding_tax_payment +msgid "Set to Draft" +msgstr "Imposta a Bozza" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_state +#. module: l10n_it_withholding_tax_payment +msgid "Status" +msgstr "Stato" + +#: model:ir.ui.view,arch_db:l10n_it_withholding_tax_payment.view_withholding_move_payment_form +#. module: l10n_it_withholding_tax_payment +msgid "Tot" +msgstr "Tot" + +#: model:ir.ui.menu,name:l10n_it_withholding_tax_payment.menu_withholding_tax_move_payment +#. module: l10n_it_withholding_tax_payment +msgid "WT Move Payments" +msgstr "Versamenti Ritenuta" + +#: model:ir.ui.view,arch_db:l10n_it_withholding_tax_payment.wizard_wt_move_payment_create_view +#. module: l10n_it_withholding_tax_payment +msgid "WT Moves" +msgstr "Voci Ritenuta" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_withholding_tax_move_payment_amount +#. module: l10n_it_withholding_tax_payment +msgid "WT amount" +msgstr "Importo Ritenuta" + +#: model:ir.model,name:l10n_it_withholding_tax_payment.model_wizard_wt_move_payment_create +#. module: l10n_it_withholding_tax_payment +msgid "WT wizard create move payment" +msgstr "WT wizard create move payment" + +#: code:addons/l10n_it_withholding_tax_payment/models/withholding_tax.py:55 +#. module: l10n_it_withholding_tax_payment +#, python-format +msgid "Warning! Datas required for account move creation: Date payment, journal, account" +msgstr "Attenzione! Per la creazione della registrazione sono richiesti:" +"Data pagamento, sezionale, conto" + +#: model:ir.ui.view,arch_db:l10n_it_withholding_tax_payment.view_withholding_move_payment_form +#: model:ir.ui.view,arch_db:l10n_it_withholding_tax_payment.view_withholding_move_payment_tree +#. module: l10n_it_withholding_tax_payment +msgid "Withholding Move Payment" +msgstr "Versamento Ritenuta" + +#: model:ir.model,name:l10n_it_withholding_tax_payment.model_withholding_tax_move +#. module: l10n_it_withholding_tax_payment +msgid "Withholding Tax Move" +msgstr "Voci ritenuta" + +#: model:ir.model,name:l10n_it_withholding_tax_payment.model_withholding_tax_move_payment +#: model:ir.ui.view,arch_db:l10n_it_withholding_tax_payment.view_withholding_move_payment_form +#. module: l10n_it_withholding_tax_payment +msgid "Withholding Tax Move Payment" +msgstr "Versamenti Ritenuta" + +#: code:addons/l10n_it_withholding_tax_payment/models/withholding_tax.py:87 +#: code:addons/l10n_it_withholding_tax_payment/models/withholding_tax.py:95 +#. module: l10n_it_withholding_tax_payment +#, python-format +msgid "Withholding Tax Payment" +msgstr "Versamenti Ritenuta" + +#: code:addons/l10n_it_withholding_tax_payment/models/withholding_tax.py:68 +#. module: l10n_it_withholding_tax_payment +#, python-format +msgid "Withholding Tax Payment %s" +msgstr "Versamento Ritenuta %s" + +#: model:ir.actions.act_window,name:l10n_it_withholding_tax_payment.action_withholding_tax_move_payment +#. module: l10n_it_withholding_tax_payment +msgid "Withhoulding Tax Move Payment" +msgstr "Withhoulding Tax Move Payment" + +#: model:ir.model.fields,field_description:l10n_it_withholding_tax_payment.field_wizard_wt_move_payment_create_wt_move_ids +#. module: l10n_it_withholding_tax_payment +msgid "Wt Moves" +msgstr "Wt Moves" + +#: code:addons/l10n_it_withholding_tax_payment/models/withholding_tax.py:115 +#. module: l10n_it_withholding_tax_payment +#, python-format +msgid "Wt move already in a move payment! Move paym. %s -Ref WT: %s - %s - %s" +msgstr "Wt move already in a move payment! Move paym. %s -Ref WT: %s - %s - %s" + +#: code:addons/l10n_it_withholding_tax_payment/models/withholding_tax.py:109 +#. module: l10n_it_withholding_tax_payment +#, python-format +msgid "Wt move already paid! - %s - %s - %s" +msgstr "Wt move already paid! - %s - %s - %s" + diff --git a/l10n_it_withholding_tax_payment/models/__init__.py b/l10n_it_withholding_tax_payment/models/__init__.py new file mode 100644 index 000000000000..f1eb1a813a88 --- /dev/null +++ b/l10n_it_withholding_tax_payment/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Copyright © 2015 Alessandro Camilli () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from . import withholding_tax diff --git a/l10n_it_withholding_tax_payment/models/withholding_tax.py b/l10n_it_withholding_tax_payment/models/withholding_tax.py new file mode 100644 index 000000000000..ee16a15365da --- /dev/null +++ b/l10n_it_withholding_tax_payment/models/withholding_tax.py @@ -0,0 +1,159 @@ +# -*- coding: utf-8 -*- +# Copyright © 2015 Alessandro Camilli () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from openerp import models, fields, api, _ +from openerp.exceptions import ValidationError +from openerp import netsvc + + +class WithholdingTaxMove(models.Model): + _inherit = 'withholding.tax.move' + + wt_move_payment_id = fields.Many2one( + 'withholding.tax.move.payment', 'Move Payment', readonly=True) + + +class WithholdingTaxMovePayment(models.Model): + _name = 'withholding.tax.move.payment' + _description = 'Withholding Tax Move Payment' + + @api.depends('line_ids.amount', 'line_ids.wt_move_payment_id') + def _compute_total(self): + for mp in self: + tot_wt_amount = 0 + for wt_move in mp.line_ids: + tot_wt_amount += wt_move.amount + mp.amount = tot_wt_amount + + state = fields.Selection([ + ('draft', 'Draft'), + ('confirmed', 'Confirmed'), + ], 'Status', readonly=True, copy=False, select=True, default='draft') + name = fields.Char('Name') + date = fields.Char('Date') + date_payment = fields.Date('Date Payment') + date_start = fields.Date('Date Start', readonly=True) + date_stop = fields.Date('Date Stop', readonly=True) + move_id = fields.Many2one('account.move', string='Account move') + account_id = fields.Many2one('account.account', string='Account') + journal_id = fields.Many2one('account.journal', string='Journal') + line_ids = fields.One2many( + 'withholding.tax.move', 'wt_move_payment_id', string='Lines') + amount = fields.Float('WT amount', compute='_compute_total') + + def create_account_move(self): + account_move_obj = self.env['account.move'] + for mp in self: + if not mp.date_payment \ + or not mp.journal_id\ + or not mp.account_id: + raise ValidationError( + _('Warning! Datas required for account move creation: \ + Date payment, journal, account')) + # WT Moves + wt_move_balance = 0 + move_lines = [] + for wt_move in mp.line_ids: + debit = 0 + credit = 0 + if wt_move.amount > 0: + debit = wt_move.amount + else: + credit = wt_move.amount + vals = { + 'name': _('Withholding Tax Payment %s') + % wt_move.partner_id.name, + 'account_id': + wt_move.withholding_tax_id.account_payable_id.id, + 'credit': credit, + 'debit': debit, + } + move_lines.append((0, 0, vals)) + # Balance + wt_move_balance += wt_move.amount + # WT payment + if wt_move_balance: + debit = 0 + credit = 0 + if wt_move_balance > 0: + credit = wt_move_balance + else: + debit = wt_move_balance * -1 + vals = { + 'name': _('Withholding Tax Payment'), + 'account_id': mp.account_id.id, + 'credit': credit, + 'debit': debit, + } + move_lines.append((0, 0, vals)) + # Move create + move = account_move_obj.create({ + 'ref': _('Withholding Tax Payment'), + 'journal_id': mp.journal_id.id, + 'date': mp.date_payment, + 'line_ids': move_lines, + }) + move.post() + # Ref on payement + mp.move_id = move.id + + def generate_from_moves(self, wt_moves): + sequence_obj = self.env['ir.sequence'] + for wt_move in wt_moves: + if wt_move.state == 'paid': + raise ValidationError( + _("Wt move already paid! - %s - %s - %s") + % (wt_move.partner_id.name, + wt_move.date, + str(wt_move.amount))) + if wt_move.wt_move_payment_id: + raise ValidationError( + _("Wt move already in a move payment! \ + Move paym. %s -Ref WT: %s - %s - %s") + % (str(wt_move.wt_move_payment_id.id), + wt_move.partner_id.name, + wt_move.date, + str(wt_move.amount))) + # Create Move payment + wt_payment = False + if wt_moves: + val = { + 'name': sequence_obj.get('withholding.tax.move.payment'), + 'date': fields.Date.today(), + 'line_ids': [(6, 0, wt_moves.ids)] + } + wt_payment = self.create(val) + # Update ref on moves + for wt_move in wt_moves: + wt_move.wt_move_payment_id = wt_payment.id + return wt_payment + + def action_confirmed(self): + for pt in self: + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate( + self.env.uid, self._name, pt.id, 'confirmed', self.env.cr) + + def action_set_to_draft(self): + for pt in self: + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate( + self.env.uid, self._name, pt.id, 'cancel', self.env.cr) + + def move_payment_to_draft(self): + for move in self: + if move.state in ['confirmed']: + move.state = 'draft' + # Wt move set to due + for wt_move in move.line_ids: + wt_move.action_set_to_draft() + + def move_payment_confirmed(self): + for move in self: + if move.state in ['draft']: + move.state = 'confirmed' + # Wt move set to due + for wt_move in move.line_ids: + wt_move.action_paid() diff --git a/l10n_it_withholding_tax_payment/security/ir.model.access.csv b/l10n_it_withholding_tax_payment/security/ir.model.access.csv new file mode 100644 index 000000000000..334cc4889e0c --- /dev/null +++ b/l10n_it_withholding_tax_payment/security/ir.model.access.csv @@ -0,0 +1,4 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" + +withholding_tax_move_payment_user,withholding_tax_move_payment user,model_withholding_tax_move_payment,account.group_account_user,1,0,0,0 +withholding_tax_move_payment_manager,withholding_tax_move_payment manager,model_withholding_tax_move_payment,account.group_account_manager,1,1,1,1 diff --git a/l10n_it_withholding_tax_payment/views/withholding_tax.xml b/l10n_it_withholding_tax_payment/views/withholding_tax.xml new file mode 100644 index 000000000000..3a634c1ef833 --- /dev/null +++ b/l10n_it_withholding_tax_payment/views/withholding_tax.xml @@ -0,0 +1,102 @@ + + + + + withholding.move.payment.move.view.tree + withholding.tax.move + + + + + + + + + + withholding.move.payment.move.view.form + withholding.tax.move + + + + + + + + + + + withholding.tax.move.payment.view.tree + withholding.tax.move.payment + + + + + + + + + + + + + + withholding.tax.move.payment.view.form + withholding.tax.move.payment + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + Withhoulding Tax Move Payment + withholding.tax.move.payment + + + + + +
+
diff --git a/l10n_it_withholding_tax_payment/wizard/__init__.py b/l10n_it_withholding_tax_payment/wizard/__init__.py new file mode 100644 index 000000000000..742aa3ce5989 --- /dev/null +++ b/l10n_it_withholding_tax_payment/wizard/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Copyright © 2015 Alessandro Camilli () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from . import create_move_payment diff --git a/l10n_it_withholding_tax_payment/wizard/create_move_payment.py b/l10n_it_withholding_tax_payment/wizard/create_move_payment.py new file mode 100644 index 000000000000..650c489b386c --- /dev/null +++ b/l10n_it_withholding_tax_payment/wizard/create_move_payment.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Copyright © 2015 Alessandro Camilli () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from openerp import models, fields, api + + +class WizardWtMovePaymentCreate(models.TransientModel): + _name = 'wizard.wt.move.payment.create' + _description = 'WT wizard create move payment' + + @api.model + def default_get(self, fields): + res = super(WizardWtMovePaymentCreate, self).default_get(fields) + active_ids = self._context.get('active_ids', []) + res = { + 'wt_move_ids': active_ids + } + return res + + wt_move_ids = fields.Many2many( + 'withholding.tax.move', 'wiz_wt_move_payment_create_rel', + 'wizard_id', 'wt_move_id', 'Wt Moves', readonly=True) + + def generate(self): + wt_move_payment_obj = self.env['withholding.tax.move.payment'] + wt_move_payment_obj.generate_from_moves(self.wt_move_ids) + + return {'type': 'ir.actions.act_window_close'} diff --git a/l10n_it_withholding_tax_payment/wizard/create_move_payment_view.xml b/l10n_it_withholding_tax_payment/wizard/create_move_payment_view.xml new file mode 100644 index 000000000000..d426f831c733 --- /dev/null +++ b/l10n_it_withholding_tax_payment/wizard/create_move_payment_view.xml @@ -0,0 +1,40 @@ + + + + + + + wizard.wt.move.payment.create.view + wizard.wt.move.payment.create + +
+ + + + +
+
+
+
+
+ + + + +
+
diff --git a/l10n_it_withholding_tax_payment/workflow.xml b/l10n_it_withholding_tax_payment/workflow.xml new file mode 100644 index 000000000000..bb3a78dc51e0 --- /dev/null +++ b/l10n_it_withholding_tax_payment/workflow.xml @@ -0,0 +1,48 @@ + + + + + + + + withholding.tax.move.payment.wkf + withholding.tax.move.payment + True + + + + + draft + function + + move_payment_to_draft() + + True + + + + + confirmed + function + + move_payment_confirmed() + + + + + + + + + confirmed + + + + + + + cancel + + + + From 933d4301f8a8256d4eeca3839d607d8ac156b01a Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 10 May 2017 10:24:21 +0200 Subject: [PATCH 02/16] [FIX] add depends to l10n_it_withholding_tax [FIX] add display_name on class withholding.tax.move withholding.tax.statement [FIX] add display_name on class withholding.tax.move withholding.tax.statement [FIX] removed select on class l10n_it_withholding_tax l10n_it_withholding_tax_payment [FIX] add README --- l10n_it_withholding_tax_payment/README.rst | 67 +++++++++++++++++++ .../__manifest__.py | 3 +- .../models/withholding_tax.py | 2 +- 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 l10n_it_withholding_tax_payment/README.rst diff --git a/l10n_it_withholding_tax_payment/README.rst b/l10n_it_withholding_tax_payment/README.rst new file mode 100644 index 000000000000..5363bcf89caf --- /dev/null +++ b/l10n_it_withholding_tax_payment/README.rst @@ -0,0 +1,67 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +======================= +Italian Withholding Tax +======================= + +Module for Italian Withholding Tax: Ritenute d'acconto + +Gestisce le ritenute sulle fatture e sui pagamenti + +Installation +============ + +To install this module, you need to have l10n_it_withholding_tax + +Usage +===== + +* Go to ... + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/122/8.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed `feedback +`_. + +Credits +======= + +Contributors +------------ + +* Alessandro Camilli +* Lorenzo Battistini + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. + +Sponsor +------- + +'Odoo Italia Network '_ + diff --git a/l10n_it_withholding_tax_payment/__manifest__.py b/l10n_it_withholding_tax_payment/__manifest__.py index 49c57e65ffaa..ec696ed133d7 100644 --- a/l10n_it_withholding_tax_payment/__manifest__.py +++ b/l10n_it_withholding_tax_payment/__manifest__.py @@ -10,7 +10,8 @@ 'Odoo Community Association (OCA)', 'website': 'https://odoo-community.org/', 'license': 'AGPL-3', - "depends": ['account'], + "depends": ['account', + 'l10n_it_withholding_tax'], "data": [ 'views/withholding_tax.xml', 'workflow.xml', diff --git a/l10n_it_withholding_tax_payment/models/withholding_tax.py b/l10n_it_withholding_tax_payment/models/withholding_tax.py index ee16a15365da..0c678afbf7f2 100644 --- a/l10n_it_withholding_tax_payment/models/withholding_tax.py +++ b/l10n_it_withholding_tax_payment/models/withholding_tax.py @@ -30,7 +30,7 @@ def _compute_total(self): state = fields.Selection([ ('draft', 'Draft'), ('confirmed', 'Confirmed'), - ], 'Status', readonly=True, copy=False, select=True, default='draft') + ], 'Status', readonly=True, copy=False, default='draft') name = fields.Char('Name') date = fields.Char('Date') date_payment = fields.Date('Date Payment') From f4d285e7b9ae854e31d8e56ed2a9cf33ca579ed5 Mon Sep 17 00:00:00 2001 From: Alessandro Camilli Date: Mon, 24 Jul 2017 18:29:29 +0200 Subject: [PATCH 03/16] Rates required Disabled delete from tree view of wt statements and wt moves Rates required Disabled delete from tree view of wt statements and wt moves Fix conflicts and changed code with new standards --- l10n_it_withholding_tax_payment/data/sequence.xml | 4 ++-- .../models/withholding_tax.py | 6 +++--- .../views/withholding_tax.xml | 10 ++++------ .../wizard/create_move_payment.py | 2 +- .../wizard/create_move_payment_view.xml | 8 +++----- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/l10n_it_withholding_tax_payment/data/sequence.xml b/l10n_it_withholding_tax_payment/data/sequence.xml index 2f0c8c10c8c0..d24fed743a4a 100644 --- a/l10n_it_withholding_tax_payment/data/sequence.xml +++ b/l10n_it_withholding_tax_payment/data/sequence.xml @@ -1,5 +1,5 @@ - + @@ -11,4 +11,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/l10n_it_withholding_tax_payment/models/withholding_tax.py b/l10n_it_withholding_tax_payment/models/withholding_tax.py index 0c678afbf7f2..6ce7186d1e43 100644 --- a/l10n_it_withholding_tax_payment/models/withholding_tax.py +++ b/l10n_it_withholding_tax_payment/models/withholding_tax.py @@ -3,9 +3,9 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import models, fields, api, _ -from openerp.exceptions import ValidationError -from openerp import netsvc +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError +from odoo import netsvc class WithholdingTaxMove(models.Model): diff --git a/l10n_it_withholding_tax_payment/views/withholding_tax.xml b/l10n_it_withholding_tax_payment/views/withholding_tax.xml index 3a634c1ef833..8d3b3271038a 100644 --- a/l10n_it_withholding_tax_payment/views/withholding_tax.xml +++ b/l10n_it_withholding_tax_payment/views/withholding_tax.xml @@ -1,5 +1,4 @@ - - + @@ -32,7 +31,7 @@ withholding.tax.move.payment.view.tree withholding.tax.move.payment - + @@ -47,7 +46,7 @@ withholding.tax.move.payment.view.form withholding.tax.move.payment -
+
- + @@ -91,12 +91,12 @@ - Withhoulding Tax Move Payment + Withholding Tax Payment Move withholding.tax.move.payment - diff --git a/l10n_it_withholding_tax_payment/wizard/__init__.py b/l10n_it_withholding_tax_payment/wizard/__init__.py index 45591af4c9dc..752c33a8ab30 100644 --- a/l10n_it_withholding_tax_payment/wizard/__init__.py +++ b/l10n_it_withholding_tax_payment/wizard/__init__.py @@ -1,5 +1,3 @@ -# Copyright 2015 Alessandro Camilli () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - from . import create_move_payment diff --git a/l10n_it_withholding_tax_payment/wizard/create_move_payment.py b/l10n_it_withholding_tax_payment/wizard/create_move_payment.py index c1bf716138a7..497d473cf1dc 100644 --- a/l10n_it_withholding_tax_payment/wizard/create_move_payment.py +++ b/l10n_it_withholding_tax_payment/wizard/create_move_payment.py @@ -1,26 +1,21 @@ # Copyright 2015 Alessandro Camilli () +# Copyright 2019 Matteo Bilotta # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo import models, fields, api, _ +from odoo import _, fields, models class WizardWtMovePaymentCreate(models.TransientModel): _name = 'wizard.wt.move.payment.create' - _description = 'WT wizard create move payment' + _description = "Create WT Payment Move Wizard" - @api.model - def default_get(self, fields): - res = super(WizardWtMovePaymentCreate, self).default_get(fields) - active_ids = self._context.get('active_ids', []) - res = { - 'wt_move_ids': active_ids - } - return res + def _default_wt_moves(self): + return self._context.get('active_ids', []) wt_move_ids = fields.Many2many( 'withholding.tax.move', 'wiz_wt_move_payment_create_rel', - 'wizard_id', 'wt_move_id', 'Wt Moves', readonly=True) + 'wizard_id', 'wt_move_id', 'WT Moves', readonly=True, + default=_default_wt_moves) def generate(self): wt_move_payment_obj = self.env['withholding.tax.move.payment'] @@ -29,6 +24,7 @@ def generate(self): 'l10n_it_withholding_tax_payment', 'view_withholding_move_payment_form') view_id = view[1] or False + return { 'name': _('Withholding Tax Payment'), 'view_type': 'form', @@ -36,5 +32,5 @@ def generate(self): 'res_model': 'withholding.tax.move.payment', 'res_id': wt_payment.id, 'type': 'ir.actions.act_window', - 'view_id': [view_id], + 'view_id': [view_id] } diff --git a/l10n_it_withholding_tax_payment/wizard/create_move_payment_view.xml b/l10n_it_withholding_tax_payment/wizard/create_move_payment_view.xml index 1d843fca9f9c..a381a45c9aa3 100644 --- a/l10n_it_withholding_tax_payment/wizard/create_move_payment_view.xml +++ b/l10n_it_withholding_tax_payment/wizard/create_move_payment_view.xml @@ -1,38 +1,41 @@ + - + Copyright 2010-2013 Akretion (http://www.akretion.com) + @author: Alexis de Lattre + The licence is in the file __manifest__.py - - wizard.wt.move.payment.create.view - wizard.wt.move.payment.create - - - - - - -
-
- -
-
+ Copyright 2010-2013 Alessandro Camilli (http://www.openforce.it) + Copyright 2019 Matteo Bilotta + --> + + - + + wizard.wt.move.payment.create.view + wizard.wt.move.payment.create + +
+ + + + + +
+
+
+
+
+