← Back to team overview

openobject-italia-core-devs team mailing list archive

[Merge] lp:~icsergio/openobject-italia/61_imp_withholding_tax into lp:openobject-italia/6.1

 

Sergio Corato has proposed merging lp:~icsergio/openobject-italia/61_imp_withholding_tax into lp:openobject-italia/6.1.

Requested reviews:
  Lorenzo Battistini - Agile BG (elbati)

For more details, see:
https://code.launchpad.net/~icsergio/openobject-italia/61_imp_withholding_tax/+merge/189442

A simpler and so more efficient implementation of withholding tax, with the same features of original one.
-- 
https://code.launchpad.net/~icsergio/openobject-italia/61_imp_withholding_tax/+merge/189442
Your team OpenERP Italia core devs is subscribed to branch lp:openobject-italia/6.1.
=== modified file 'l10n_it_account/__openerp__.py'
--- l10n_it_account/__openerp__.py	2013-09-05 22:04:55 +0000
+++ l10n_it_account/__openerp__.py	2013-10-04 23:13:20 +0000
@@ -33,11 +33,12 @@
     'author': 'OpenERP Italian Community',
     'website': 'http://www.openerp-italia.org',
     'license': 'AGPL-3',
-    "depends" : ['account','base_vat','account_chart','base_iban', 'l10n_it_base','account_invoice_entry_date'],
+    "depends" : ['account','base_vat','account_chart','account_voucher','base_iban', 'l10n_it_base','account_invoice_entry_date'],
     "init_xml": [
         'account/partner_view.xml',
         'account/invoice_view.xml',
         'wizard/fiscalcode_to_data_view.xml',
+        'account/tax_view.xml',
     ],
     "update_xml" : [],
     "demo_xml" : [],

=== modified file 'l10n_it_account/account/__init__.py'
--- l10n_it_account/account/__init__.py	2013-01-04 14:02:10 +0000
+++ l10n_it_account/account/__init__.py	2013-10-04 23:13:20 +0000
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 ##############################################################################
-#    
-#    Copyright (C) 2010 Associazione OpenERP Italia
-#    (<http://www.openerp-italia.org>). 
+#
+#    Copyright (C) 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
@@ -21,3 +21,4 @@
 
 import account
 import invoice
+import withholding_tax_payment

=== added file 'l10n_it_account/account/tax_view.xml'
--- l10n_it_account/account/tax_view.xml	1970-01-01 00:00:00 +0000
+++ l10n_it_account/account/tax_view.xml	2013-10-04 23:13:20 +0000
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<openerp>
+    <data>
+
+        <record id="view_tax_code_form_whtax" model="ir.ui.view">
+            <field name="name">account.tax.code.form</field>
+            <field name="model">account.tax.code</field>
+            <field name="inherit_id" ref="account.view_tax_code_form"/>
+            <field name="arch" type="xml">
+                    <field name="parent_id" position="after">
+                        <field name="withholding_type"/>
+                        <field name="withholding_payment_term"/>
+                    </field>
+            </field>
+        </record>
+
+    </data>
+</openerp>

=== added file 'l10n_it_account/account/withholding_tax_payment.py'
--- l10n_it_account/account/withholding_tax_payment.py	1970-01-01 00:00:00 +0000
+++ l10n_it_account/account/withholding_tax_payment.py	2013-10-04 23:13:20 +0000
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+
+#    Copyright (C) 2013 Sergio Corato (<http://www.icstools.it>)
+#
+#    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.code'
+    """quando si fa il pagamento della fattura fornitore, verificare se c'è una tassa collegata alla fattura di tipo ritenuta d'acconto, e nel caso impostarne la scadenza. Limitare la funzione ai pagamenti con una sola scadenza, nel caso ce ne siano di più lasciare che si arrangi l'utente."""
+    _columns = {
+        'withholding_type': fields.boolean("Ritenuta d'acconto"),
+        'withholding_payment_term': fields.many2one('account.payment.term', "Termine di pagamento ritenuta d'acconto"),
+    }
+
+
+class account_voucher(osv.osv):
+    _inherit = "account.voucher"
+
+    def action_move_line_create(self, cr, uid, ids, context=None):
+        res = super(account_voucher, self).action_move_line_create(cr, uid, ids, context)
+        move_line_obj = self.pool.get('account.move.line')
+        term_pool = self.pool.get('account.payment.term')
+        date_maturity = {}
+        for voucher in self.browse(cr, uid, ids, context):
+            for line in voucher.line_ids:
+                if line.amount and line.move_line_id and line.move_line_id.invoice:
+                    invoice = line.move_line_id.invoice
+                    for inv_tax_line in line.move_line_id.invoice.tax_line:
+                        if inv_tax_line.tax_code_id.withholding_type:
+                            due_list = term_pool.compute(
+                                cr, uid, inv_tax_line.tax_code_id.withholding_payment_term.id, line.amount,
+                                date_ref=voucher.date or invoice.date_invoice, context=context)
+                            if len(due_list) > 1:
+                                raise osv.except_osv(
+                                    _('Error'),
+                                    _('The payment term %s has too many due dates')
+                                    % inv_tax_line.tax_code_id.withholding_payment_term.name)
+                            if len(due_list) == 0:
+                                raise osv.except_osv(
+                                    _('Error'),
+                                    _('The payment term %s does not have due dates')
+                                    % inv_tax_line.tax_code_id.withholding_payment_term.name)
+                            date_maturity['date_maturity'] = due_list[0][0]
+                            move_line_id = move_line_obj.search(cr, uid, [('invoice', '=', line.move_line_id.invoice.id), ('tax_code_id.withholding_type', '=', True)], context)
+                            move_line_obj.write(cr, uid, move_line_id, date_maturity, context)
+        return res


Follow ups