Lorenzo Battistini - Agile BG has proposed merging lp:~elbati/openobject-italia/l10n_it_withholding_tax_7 into lp:openobject-italia/7.0.
Requested reviews: OpenERP Italia core devs (openobject-italia-core-devs) For more details, see: https://code.launchpad.net/~elbati/openobject-italia/l10n_it_withholding_tax_7/+merge/159380 Dipende da https://code.launchpad.net/~elbati/account-payment/adding_account_voucher_cash_basis_7/+merge/159379 -- https://code.launchpad.net/~elbati/openobject-italia/l10n_it_withholding_tax_7/+merge/159380 Your team OpenERP Italia core devs is requested to review the proposed merge of lp:~elbati/openobject-italia/l10n_it_withholding_tax_7 into lp:openobject-italia/7.0.
=== added directory 'l10n_it_withholding_tax' === added file 'l10n_it_withholding_tax/AUTHORS.txt' --- l10n_it_withholding_tax/AUTHORS.txt 1970-01-01 00:00:00 +0000 +++ l10n_it_withholding_tax/AUTHORS.txt 2013-04-17 12:54:35 +0000 @@ -0,0 +1,2 @@ +Lorenzo Battistini <lorenzo.battist...@agilebg.com> +Paolo Chiara <p.chi...@isa.it> === added file 'l10n_it_withholding_tax/__init__.py' --- l10n_it_withholding_tax/__init__.py 1970-01-01 00:00:00 +0000 +++ l10n_it_withholding_tax/__init__.py 2013-04-17 12:54:35 +0000 @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>) +# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>) +# Copyright (C) 2012-2013 Associazione OpenERP Italia +# (<http://www.openerp-italia.org>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +import account === added file 'l10n_it_withholding_tax/__openerp__.py' --- l10n_it_withholding_tax/__openerp__.py 1970-01-01 00:00:00 +0000 +++ l10n_it_withholding_tax/__openerp__.py 2013-04-17 12:54:35 +0000 @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>) +# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>) +# Copyright (C) 2012-2013 Associazione OpenERP Italia +# (<http://www.openerp-italia.org>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## +{ + 'name': "Italian Localisation - Withholding tax", + 'version': '0.2', + 'category': 'Localisation/Italy', + 'description': """ +Ritenute d'acconto sulle fatture fornitore +========================================== + +Per utilizzare il modulo bisogna configurare i campi associati alla company: + - Termine di pagamento della ritenuta + - Conto di debito per le ritenute da versare + - Sezionale che conterrà le registrazioni legate alla ritenuta + +Durante la compilazione di una fattura fornitore con ritenuta d'acconto, l'utente dovrà specificare l'importo della ritenuta. + +Requisiti +--------- +http://wiki.openerp-italia.org/doku.php/area_utente/requisiti/ritenuta_d_acconto + +Howto +----- +http://planet.domsense.com/2012/06/come-registrare-in-openerp-le-fatture-fornitore-con-ritenuta-dacconto/ +""", + 'author': 'OpenERP Italian Community', + 'website': 'http://www.openerp-italia.org', + 'license': 'AGPL-3', + "depends" : ['account_voucher_cash_basis'], + "data" : [ + 'account_view.xml',], + "demo" : [], + "active": False, + "installable": True +} === added file 'l10n_it_withholding_tax/account.py' --- l10n_it_withholding_tax/account.py 1970-01-01 00:00:00 +0000 +++ l10n_it_withholding_tax/account.py 2013-04-17 12:54:35 +0000 @@ -0,0 +1,195 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>) +# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>) +# Copyright (C) 2012-2013 Associazione OpenERP Italia +# (<http://www.openerp-italia.org>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from openerp.osv import fields, orm +from openerp.tools.translate import _ +import decimal_precision as dp + +class res_company(orm.Model): + _inherit = 'res.company' + _columns = { + 'withholding_payment_term_id': fields.many2one('account.payment.term', 'Withholding tax Payment Term'), + 'withholding_account_id': fields.many2one('account.account','Withholding account', help='Payable account used for amount due to tax authority', domain=[('type', '=', 'payable')]), + 'withholding_journal_id': fields.many2one('account.journal','Withholding journal', help="Journal used for registration of witholding amounts to be paid"), + 'authority_partner_id': fields.many2one('res.partner', 'Tax Authority Partner'), + } + +class account_config_settings(orm.TransientModel): + _inherit = 'account.config.settings' + _columns = { + 'withholding_payment_term_id': fields.related( + 'company_id', 'withholding_payment_term_id', + type='many2one', + relation="account.payment.term", + string="Withholding tax Payment Term"), + 'withholding_account_id': fields.related( + 'company_id', 'withholding_account_id', + type='many2one', + relation="account.account", + string="Withholding account", + help='Payable account used for amount due to tax authority', + domain=[('type', '=', 'payable')]), + 'withholding_journal_id': fields.related( + 'company_id', 'withholding_journal_id', + type='many2one', + relation="account.journal", + string="Withholding journal", + help='Journal used for registration of witholding amounts to be paid'), + 'authority_partner_id': fields.related( + 'company_id', 'authority_partner_id', + type='many2one', + relation="res.partner", + string="Tax Authority Partner"), + } + + def onchange_company_id(self, cr, uid, ids, company_id, context=None): + res = super(account_config_settings, self).onchange_company_id(cr, uid, ids, company_id, context=context) + if company_id: + company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) + res['value'].update({ + 'withholding_payment_term_id': (company.withholding_payment_term_id + and company.withholding_payment_term_id.id or False), + 'withholding_account_id': (company.withholding_account_id + and company.withholding_account_id.id or False), + 'withholding_journal_id': (company.withholding_journal_id + and company.withholding_journal_id.id or False), + 'authority_partner_id': (company.authority_partner_id + and company.authority_partner_id.id or False), + }) + else: + res['value'].update({ + 'withholding_payment_term_id': False, + 'withholding_account_id': False, + 'withholding_journal_id': False, + 'authority_partner_id': False, + }) + return res + +class account_invoice(orm.Model): + + def _net_pay(self, cr, uid, ids, field_name, arg, context=None): + res = {} + for invoice in self.browse(cr, uid, ids, context): + res[invoice.id] = invoice.amount_total - invoice.withholding_amount + return res + + _inherit = "account.invoice" + + _columns = { + 'withholding_amount': fields.float('Withholding amount', digits_compute=dp.get_precision('Account'), readonly=True, states={'draft':[('readonly',False)]}), + 'has_withholding': fields.boolean('With withholding tax', readonly=True, states={'draft':[('readonly',False)]}), + 'net_pay': fields.function(_net_pay, string="Net Pay"), + } + +class account_voucher(orm.Model): + _inherit = "account.voucher" + + _columns = { + 'withholding_move_ids': fields.many2many('account.move', 'voucher_withholding_move_rel', 'voucher_id', 'move_id', 'Withholding Tax Entries', readonly=True), + } + + def reconcile_withholding_move(self, cr, uid, invoice, wh_move, context=None): + line_pool=self.pool.get('account.move.line') + rec_ids = [] + for inv_move_line in invoice.move_id.line_id: + if inv_move_line.account_id.type == 'payable' and not inv_move_line.reconcile_id: + rec_ids.append(inv_move_line.id) + for wh_line in wh_move.line_id: + if wh_line.account_id.type == 'payable' and invoice.company_id.withholding_account_id and invoice.company_id.withholding_account_id.id != wh_line.account_id.id and not wh_line.reconcile_id: + rec_ids.append(wh_line.id) + return line_pool.reconcile_partial(cr, uid, rec_ids, type='auto', context=context) + + def action_move_line_create(self, cr, uid, ids, context=None): + res = super(account_voucher,self).action_move_line_create(cr, uid, ids, context) + inv_pool = self.pool.get('account.invoice') + move_pool = self.pool.get('account.move') + tax_pool = self.pool.get('account.tax') + curr_pool = self.pool.get('res.currency') + term_pool = self.pool.get('account.payment.term') + for voucher in self.browse(cr, uid, ids, context): + amounts_by_invoice = super(account_voucher,self).allocated_amounts_grouped_by_invoice(cr, uid,voucher, context) + for inv_id in amounts_by_invoice: + invoice = inv_pool.browse(cr, uid, inv_id, context) + if invoice.withholding_amount: + # only for supplier payments + if voucher.type != 'payment': + raise orm.except_orm(_('Error'), _('Can\'t handle withholding tax with voucher of type other than payment')) + if not invoice.company_id.withholding_account_id: + raise orm.except_orm(_('Error'), _('The company does not have an associated Withholding account') ) + if not invoice.company_id.withholding_payment_term_id: + raise orm.except_orm(_('Error'), _('The company does not have an associated Withholding Payment Term') ) + if not invoice.company_id.withholding_journal_id: + raise orm.except_orm(_('Error'), _('The company does not have an associated Withholding journal') ) + if not invoice.company_id.authority_partner_id: + raise orm.except_orm(_('Error'), _('The company does not have an associated Tax Authority partner') ) + # compute the new amount proportionally to paid amount + new_line_amount = curr_pool.round(cr, uid, voucher.company_id.currency_id, ((amounts_by_invoice[invoice.id]['allocated'] + amounts_by_invoice[invoice.id]['write-off']) / invoice.net_pay) * invoice.withholding_amount) + + # compute the due date + due_list = term_pool.compute( + cr, uid, invoice.company_id.withholding_payment_term_id.id, new_line_amount, + date_ref=voucher.date or invoice.date_invoice, context=context) + if len(due_list) > 1: + raise orm.except_orm(_('Error'), + _('The payment term %s has too many due dates') + % invoice.company_id.withholding_payment_term_id.name) + if len(due_list) == 0: + raise orm.except_orm(_('Error'), + _('The payment term %s does not have due dates') + % invoice.company_id.withholding_payment_term_id.name) + + new_move = { + 'journal_id': invoice.company_id.withholding_journal_id.id, + 'line_id': [ + (0,0,{ + 'name': invoice.number, + 'account_id': invoice.account_id.id, + 'partner_id': invoice.partner_id.id, + 'debit': new_line_amount, + 'credit': 0.0, + }), + (0,0,{ + 'name': _('Payable withholding - ') + invoice.number, + 'account_id': invoice.company_id.withholding_account_id.id, + 'partner_id': invoice.company_id.authority_partner_id.id, + 'debit': 0.0, + 'credit': new_line_amount, + 'date_maturity': due_list[0][0], + }), + ] + } + move_id = self.pool.get('account.move').create(cr, uid, new_move, context=context) + self.reconcile_withholding_move(cr, uid, invoice, move_pool.browse(cr, uid, move_id, context), context) + voucher.write({'withholding_move_ids': [(4, move_id)]}) + return res + + def cancel_voucher(self, cr, uid, ids, context=None): + res = super(account_voucher,self).cancel_voucher(cr, uid, ids, context) + reconcile_pool = self.pool.get('account.move.reconcile') + move_pool = self.pool.get('account.move') + for voucher in self.browse(cr, uid, ids, context=context): + recs = [] + for move in voucher.withholding_move_ids: + move_pool.button_cancel(cr, uid, [move.id]) + move_pool.unlink(cr, uid, [move.id]) + return res === added file 'l10n_it_withholding_tax/account_view.xml' --- l10n_it_withholding_tax/account_view.xml 1970-01-01 00:00:00 +0000 +++ l10n_it_withholding_tax/account_view.xml 2013-04-17 12:54:35 +0000 @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + +<!-- company --> + + <record id="view_account_config_settings" model="ir.ui.view"> + <field name="name">view_account_config_settings</field> + <field name="model">account.config.settings</field> + <field name="inherit_id" ref="account.view_account_config_settings"/> + <field name="arch" type="xml"> + <xpath expr="/form/group[6]" position="after"> + <separator string="Witholding Tax"/> + <group name="withholding_tax"> + <label for="id" string="Configuration"/> + <div> + <div> + <label for="withholding_payment_term_id"/> + <field name="withholding_payment_term_id" class="oe_inline"/> + </div> + <div> + <label for="withholding_account_id"/> + <field name="withholding_account_id" class="oe_inline"/> + </div> + <div> + <label for="withholding_journal_id"/> + <field name="withholding_journal_id" class="oe_inline"/> + </div> + <div> + <label for="authority_partner_id"/> + <field name="authority_partner_id" class="oe_inline"/> + </div> + </div> + </group> + </xpath> + </field> + </record> + + <!-- invoice --> + + <record id="invoice_supplier_form" model="ir.ui.view"> + <field name="name">account.invoice.supplier.form</field> + <field name="model">account.invoice</field> + <field name="inherit_id" ref="account.invoice_supplier_form"/> + <field name="arch" type="xml"> + <field name="date_due" position="after"> + <field name="has_withholding"/> + </field> + <field name="amount_total" position="after"> + <field name="withholding_amount" attrs="{'invisible': [('has_withholding', '=', False)]}"/> + <field name="net_pay" attrs="{'invisible': [('has_withholding', '=', False)]}"/> + </field> + </field> + </record> + + <!-- voucher --> + + <record id="view_vendor_payment_form_wh_move" model="ir.ui.view"> + <field name="name">account.voucher.payment.form.wh.move</field> + <field name="model">account.voucher</field> + <field name="inherit_id" ref="account_voucher.view_vendor_payment_form"/> + <field name="arch" type="xml"> + <field name="move_ids" position="after"> + <separator string="Withholding tax entries" colspan="4"></separator> + <field name="withholding_move_ids" colspan="4" nolabel="1"/> + </field> + </field> + </record> + + </data> +</openerp> === added directory 'l10n_it_withholding_tax/i18n' === added file 'l10n_it_withholding_tax/i18n/it.mo' Binary files l10n_it_withholding_tax/i18n/it.mo 1970-01-01 00:00:00 +0000 and l10n_it_withholding_tax/i18n/it.mo 2013-04-17 12:54:35 +0000 differ === added file 'l10n_it_withholding_tax/i18n/it.po' --- l10n_it_withholding_tax/i18n/it.po 1970-01-01 00:00:00 +0000 +++ l10n_it_withholding_tax/i18n/it.po 2013-04-17 12:54:35 +0000 @@ -0,0 +1,150 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * l10n_it_withholding_tax +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-10-12 15:54+0000\n" +"PO-Revision-Date: 2012-10-12 18:02+0100\n" +"Last-Translator: Franco Tampieri <i...@francotampieri.com>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" + +#. module: l10n_it_withholding_tax +#: code:addons/l10n_it_withholding_tax/account.py:90 +#, python-format +msgid "The company does not have an associated Withholding Payment Term" +msgstr "L'Azienda non ha associato nessun Termine di pagamento per le Ritenute" + +#. module: l10n_it_withholding_tax +#: constraint:res.company:0 +msgid "Error! You can not create recursive companies." +msgstr "Errore! Non è possibile creare aziende ricorsive." + +#. module: l10n_it_withholding_tax +#: code:addons/l10n_it_withholding_tax/account.py:106 +#, python-format +msgid "The payment term %s does not have due dates" +msgstr "The payment term %s does not have due dates" + +#. module: l10n_it_withholding_tax +#: code:addons/l10n_it_withholding_tax/account.py:102 +#, python-format +msgid "The payment term %s has too many due dates" +msgstr "The payment term %s has too many due dates" + +#. module: l10n_it_withholding_tax +#: view:account.voucher:0 +msgid "Withholding tax entries" +msgstr "Voci Tasse Ritenute" + +#. module: l10n_it_withholding_tax +#: field:account.invoice,has_withholding:0 +msgid "With withholding tax" +msgstr "Con tasse ritenute" + +#. module: l10n_it_withholding_tax +#: field:res.company,withholding_payment_term_id:0 +msgid "Withholding tax Payment Term" +msgstr "Termini Pagamento Ritenute" + +#. module: l10n_it_withholding_tax +#: field:res.company,withholding_account_id:0 +msgid "Withholding account" +msgstr "Conto Ritenute" + +#. module: l10n_it_withholding_tax +#: sql_constraint:res.company:0 +msgid "The company name must be unique !" +msgstr "Il nome azienda deve essere unico!" + +#. module: l10n_it_withholding_tax +#: field:account.invoice,net_pay:0 +msgid "Net Pay" +msgstr "Netto da Pagare" + +#. module: l10n_it_withholding_tax +#: model:ir.model,name:l10n_it_withholding_tax.model_res_company +msgid "Companies" +msgstr "Aziende" + +#. module: l10n_it_withholding_tax +#: code:addons/l10n_it_withholding_tax/account.py:92 +#, python-format +msgid "The company does not have an associated Withholding journal" +msgstr "L'Azienda non ha un Sezionale associato per le Ritenute" + +#. module: l10n_it_withholding_tax +#: code:addons/l10n_it_withholding_tax/account.py:86 +#: code:addons/l10n_it_withholding_tax/account.py:88 +#: code:addons/l10n_it_withholding_tax/account.py:90 +#: code:addons/l10n_it_withholding_tax/account.py:92 +#: code:addons/l10n_it_withholding_tax/account.py:101 +#: code:addons/l10n_it_withholding_tax/account.py:105 +#, python-format +msgid "Error" +msgstr "Errore" + +#. module: l10n_it_withholding_tax +#: code:addons/l10n_it_withholding_tax/account.py:86 +#, python-format +msgid "Can't handle withholding tax with voucher of type other than payment" +msgstr "Can't handle withholding tax with voucher of type other than payment" + +#. module: l10n_it_withholding_tax +#: help:res.company,withholding_account_id:0 +msgid "Payable account used for amount due to tax authority" +msgstr "Payable account used for amount due to tax authority" + +#. module: l10n_it_withholding_tax +#: sql_constraint:account.invoice:0 +msgid "Invoice Number must be unique per Company!" +msgstr "Nell'azienda il numero fattura dev'essere univoco!" + +#. module: l10n_it_withholding_tax +#: help:res.company,withholding_journal_id:0 +msgid "Journal used for registration of witholding amounts to be paid" +msgstr "Journal used for registration of witholding amounts to be paid" + +#. module: l10n_it_withholding_tax +#: code:addons/l10n_it_withholding_tax/account.py:119 +#, python-format +msgid "Payable withholding - " +msgstr "Ritenute Pagabili - " + +#. module: l10n_it_withholding_tax +#: model:ir.model,name:l10n_it_withholding_tax.model_account_voucher +msgid "Accounting Voucher" +msgstr "Voucher contabile" + +#. module: l10n_it_withholding_tax +#: field:account.invoice,withholding_amount:0 +msgid "Withholding amount" +msgstr "Totale Ritenute" + +#. module: l10n_it_withholding_tax +#: model:ir.model,name:l10n_it_withholding_tax.model_account_invoice +msgid "Invoice" +msgstr "Fattura" + +#. module: l10n_it_withholding_tax +#: field:res.company,withholding_journal_id:0 +msgid "Withholding journal" +msgstr "Sezionale Ritenute" + +#. module: l10n_it_withholding_tax +#: code:addons/l10n_it_withholding_tax/account.py:88 +#, python-format +msgid "The company does not have an associated Withholding account" +msgstr "L'Azienda non ha un conto associato per le Ritenute" + +#. module: l10n_it_withholding_tax +#: field:account.voucher,withholding_move_ids:0 +msgid "Withholding Tax Entries" +msgstr "Voci Tasse Ritenute" +
_______________________________________________ Mailing list: https://launchpad.net/~openobject-italia-core-devs Post to : openobject-italia-core-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~openobject-italia-core-devs More help : https://help.launchpad.net/ListHelp