Lorenzo Battistini - Agile BG - Domsense has proposed merging lp:~openobject-italia-core-devs/openobject-italia/adding_l10n_it_withholding_tax into lp:openobject-italia.
Requested reviews: OpenERP Italia core devs (openobject-italia-core-devs) For more details, see: https://code.launchpad.net/~openobject-italia-core-devs/openobject-italia/adding_l10n_it_withholding_tax/+merge/93585 -- https://code.launchpad.net/~openobject-italia-core-devs/openobject-italia/adding_l10n_it_withholding_tax/+merge/93585 Your team OpenERP Italia core devs is requested to review the proposed merge of lp:~openobject-italia-core-devs/openobject-italia/adding_l10n_it_withholding_tax into lp:openobject-italia.
=== 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 2012-02-17 14:58:24 +0000 @@ -0,0 +1,1 @@ +Lorenzo Battistini <[email protected]> === 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 2012-02-17 14:58:24 +0000 @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2012 Associazione OpenERP Italia +# (<http://www.openerp-italia.org>). +# All Rights Reserved +# +# 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 2012-02-17 14:58:24 +0000 @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2012 Associazione OpenERP Italia +# (<http://www.openerp-italia.org>). +# All Rights Reserved +# +# 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 - Ritenute d'acconto", + 'version': '0.1', + 'category': 'Localisation/Italy', + 'description': """ + http://wiki.openerp-italia.org/doku.php/area_utente/requisiti/ritenuta_d_acconto#openerp +""", + 'author': 'OpenERP Italian Community', + 'website': 'http://www.openerp-italia.org', + 'license': 'AGPL-3', + "depends" : ['account_invoice_template'], + "init_xml" : [ + 'account_view.xml', + ], + "update_xml" : [], + "demo_xml" : [], + "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 2012-02-17 14:58:24 +0000 @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2012 Associazione OpenERP Italia +# (<http://www.openerp-italia.org>). +# All Rights Reserved +# +# 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 osv import fields, osv +from tools.translate import _ + +class account_tax(osv.osv): + _inherit = 'account.tax' + _columns = { + 'withholding_tax': fields.boolean('Withholding Tax'), + 'withholding_payment_term_id': fields.many2one('account.payment.term', 'Withholding Payment Term'), + } +account_tax() + +class account_invoice(osv.osv): + _inherit = "account.invoice" + + def action_move_create(self, cr, uid, ids, context=None): + res = super(account_invoice, self).action_move_create(cr, uid, ids, context=context) + tax_pool = self.pool.get('account.tax') + term_pool = self.pool.get('account.payment.term') + for inv in self.browse(cr, uid, ids, context=context): + for move_line in inv.move_id.line_id: + if move_line.tax_code_id: + tax_ids = tax_pool.search(cr, uid, [('tax_code_id', '=', move_line.tax_code_id.id)]) + is_withholding = False + for tax in tax_pool.browse(cr, uid, tax_ids): + if tax.withholding_tax: + is_withholding = True + if is_withholding: + if len(tax_ids) > 1: + raise osv.except_osv(_('Error'), + _('Too many taxes associated to tax.code %s') % move_line.tax_code_id.name) + if not tax_ids: + raise osv.except_osv(_('Error'), + _('No taxes associated to tax.code %s') % move_line.tax_code_id.name) + tax = tax_pool.browse(cr, uid, tax_ids[0]) + if tax.withholding_tax and tax.withholding_payment_term_id: + due_list = term_pool.compute( + cr, uid, tax.withholding_payment_term_id.id, move_line.tax_amount, + date_ref=inv.date_invoice, context=context) + if len(due_list) > 1: + raise osv.except_osv(_('Error'), + _('The payment term %s has too many due dates') + % tax.withholding_payment_term_id.name) + if len(due_list) == 0: + raise osv.except_osv(_('Error'), + _('The payment term %s does not have due dates') + % tax.withholding_payment_term_id.name) + move_line.write({'date_maturity': due_list[0][0]}) + return res + +account_invoice() === 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 2012-02-17 14:58:24 +0000 @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_tax_form" model="ir.ui.view"> + <field name="name">account.tax.form</field> + <field name="model">account.tax</field> + <field name="type">form</field> + <field name="inherit_id" ref="account.view_tax_form"></field> + <field name="arch" type="xml"> + <field name="active" position="after"> + <field name="withholding_tax"/> + <field name="withholding_payment_term_id" attrs="{'readonly':[('withholding_tax','=',False)]}"/> + </field> + </field> + </record> + </data> +</openerp> === added directory 'l10n_it_withholding_tax/i18n'
_______________________________________________ Mailing list: https://launchpad.net/~openobject-italia-core-devs Post to : [email protected] Unsubscribe : https://launchpad.net/~openobject-italia-core-devs More help : https://help.launchpad.net/ListHelp

