← Back to team overview

openobject-italia-core-devs team mailing list archive

[Merge] lp:~roberto-v/openobject-italia/7.0 into lp:openobject-italia/7.0

 

Roberto Gianassi has proposed merging lp:~roberto-v/openobject-italia/7.0 into lp:openobject-italia/7.0.

Requested reviews:
  OpenERP Italia core devs (openobject-italia-core-devs)

For more details, see:
https://code.launchpad.net/~roberto-v/openobject-italia/7.0/+merge/205739
-- 
https://code.launchpad.net/~roberto-v/openobject-italia/7.0/+merge/205739
Your team OpenERP Italia core devs is requested to review the proposed merge of lp:~roberto-v/openobject-italia/7.0 into lp:openobject-italia/7.0.
=== modified file 'l10n_it_withholding_tax/__init__.py'
--- l10n_it_withholding_tax/__init__.py	2013-04-17 10:18:29 +0000
+++ l10n_it_withholding_tax/__init__.py	2014-02-11 11:07:44 +0000
@@ -22,3 +22,4 @@
 ##############################################################################
 
 import account
+import partner

=== modified file 'l10n_it_withholding_tax/__openerp__.py'
--- l10n_it_withholding_tax/__openerp__.py	2013-04-17 14:19:03 +0000
+++ l10n_it_withholding_tax/__openerp__.py	2014-02-11 11:07:44 +0000
@@ -48,7 +48,9 @@
     'license': 'AGPL-3',
     "depends" : ['account_voucher_cash_basis'],
     "data" : [
-        'account_view.xml',],
+        'account_view.xml',
+        'partner_view.xml',
+        ],
     "demo" : [
         'account_demo.xml',
         ],

=== modified file 'l10n_it_withholding_tax/account.py'
--- l10n_it_withholding_tax/account.py	2013-05-09 14:30:36 +0000
+++ l10n_it_withholding_tax/account.py	2014-02-11 11:07:44 +0000
@@ -98,6 +98,15 @@
             res[invoice.id] = invoice.amount_total - invoice.withholding_amount
         return res
 
+    def onchange_partner_id(self, cr, uid, ids, type, partner_id,\
+            date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):
+        res = super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner_id, date_invoice, payment_term, partner_bank_id, company_id)
+        partner_obj = self.pool.get("res.partner")
+        for partner_id in partner_obj.browse(cr, uid, [partner_id]):
+            if partner_id.supplier:
+                res['value']['has_withholding'] = True if partner_id.default_has_withholding == 'true' else False
+        return res
+
     _inherit = "account.invoice"
 
     _columns = {

=== added file 'l10n_it_withholding_tax/partner.py'
--- l10n_it_withholding_tax/partner.py	1970-01-01 00:00:00 +0000
+++ l10n_it_withholding_tax/partner.py	2014-02-11 11:07:44 +0000
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2014 Develer srl (<http://www.develer.com>)
+#
+#    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 _
+
+
+class res_partner(orm.Model):
+    _inherit = 'res.partner'
+
+    _columns = {
+        # the following field is a selection to force the user to select a value (a required boolean field may easily lead to errors)
+        'default_has_withholding': fields.selection([('empty', ''), ('true', 'Has WithHolding Tax'), ('false', 'No WithHolding Tax')], 'WithHolding Tax Default Flag', required=True),
+    }
+
+    _defaults = {
+        'default_has_withholding': lambda *x: 'empty',
+    }
+
+    def _check_default_has_withholding(self, cr, uid, ids, context=None):
+        for partner_id in self.browse(cr, uid, ids, context=context):
+            if partner_id.default_has_withholding == 'empty' and partner_id.supplier:
+                return False
+        return True
+
+    _constraints = [
+        (_check_default_has_withholding, 'Default value for WithHolding tax flag must be set on suppliers.', ['default_has_withholding']),
+    ]

=== added file 'l10n_it_withholding_tax/partner_view.xml'
--- l10n_it_withholding_tax/partner_view.xml	1970-01-01 00:00:00 +0000
+++ l10n_it_withholding_tax/partner_view.xml	2014-02-11 11:07:44 +0000
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+
+<!--
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2014 Develer srl (<http://www.develer.com>)
+#
+#    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/>.
+#
+##############################################################################
+-->
+
+
+<openerp>
+    <data>
+
+        <!-- res.partner customizations -->
+
+        <record id="view_partner_form" model="ir.ui.view">
+            <field name="name">res.partner.vat.default.view</field>
+            <field name="model">res.partner</field>
+            <field name="inherit_id" ref="account.view_partner_property_form"/>
+            <field name="arch" type="xml">
+                <field name="property_account_position" position="after" version="7.0">
+                    <field name="default_has_withholding" class="oe_inline" attrs="{'invisible': [('supplier','!=',True)]}"/>
+                </field>
+            </field>
+        </record>
+
+    </data>
+</openerp>


Follow ups