Merge lp:~roberto-v/openobject-italia/7.0 into lp:~openobject-italia-core-devs/openobject-italia/italian-addons-7.0

Proposed by Roberto Gianassi
Status: Needs review
Proposed branch: lp:~roberto-v/openobject-italia/7.0
Merge into: lp:~openobject-italia-core-devs/openobject-italia/italian-addons-7.0
Diff against target: 166 lines (+114/-4)
5 files modified
l10n_it_withholding_tax/__init__.py (+1/-0)
l10n_it_withholding_tax/__openerp__.py (+3/-1)
l10n_it_withholding_tax/account.py (+27/-3)
l10n_it_withholding_tax/partner.py (+36/-0)
l10n_it_withholding_tax/partner_view.xml (+47/-0)
To merge this branch: bzr merge lp:~roberto-v/openobject-italia/7.0
Reviewer Review Type Date Requested Status
Lorenzo Battistini code review Approve
Review via email: mp+205739@code.launchpad.net
To post a comment you must log in.
lp:~roberto-v/openobject-italia/7.0 updated
235. By Roberto Gianassi

[IMP] Copyright fix.

236. By Roberto Gianassi

[IMP] PEP8 fixings.

237. By Roberto Gianassi

[FIX] Fixed a bug on XML record creation.

If a module (like fetchmail_invoice) containing a partner record to be
preinstalled through a data.xml file was installed after this one, a
bug occurred.
The bug shows because the record is created with the
default_has_withholding flag to empty and then validation fails.
To solve this, the create function for partners is changed to check for
the presence of that flag in the vals dictionary. If the flag is found,
we assume the creation happens through the UI and so normal checking goes
on. If the flag is not found, we assume the creation happens for an XML
record and so we add an arbitrary, but valid value for the flag.

238. By Roberto Gianassi

[FIX] Typo.

239. By Roberto Gianassi

[IMP] Changed default_has_withholding type to Boolean.

240. By Roberto Gianassi

[FIX] Bug fix to save record.

For unknown reasons, if a boolean value has the required field to True,
it is not possible to save the corresponding supplier record.
Removed the field to fix that.

241. By Roberto Gianassi

[FIX] When partner field is empty value is False.

The value passed to the onchange_partner_id for the partner is False
when the field is empty. In this case, it is not possible to use such a
value with the browse function or an error arises. Fixed that.

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Following this MP
https://code.launchpad.net/~roberto-v/account-payment/adding_account_vat_on_payment_7/+merge/205723
maybe better if we use fiscal positions for withholding taxes too?

Thanks

review: Needs Information
Revision history for this message
Roberto Gianassi (roberto-v) wrote :

> Following this MP
> https://code.launchpad.net/~roberto-v/account-
> payment/adding_account_vat_on_payment_7/+merge/205723
> maybe better if we use fiscal positions for withholding taxes too?

Depends... :)

After discussing this in my shop, the reasoning is as follows:

- VAT on Payment gives a financial advantage, so it is always used where applicable by law; linking it to fiscal position seems the best bet, because it depends on law. After I set it to True, I have the best possible advantage. Only in rare cases, I will manually set it to False.

- Withholding Taxes is something you have to do with some parties, but it doesn't give any financial advantage; normally companies prefer to avoid it because it implies more accounting work; linking it to a supplier seems the best choice because you want to use it as little as possible. I don't see any advantages on linking it to fiscal position: it will quite always be False and you still have to set it manually to True on every supplier you need to.

However, if you have valid reasons to do it differently let me know and we may discuss a solution.

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Ok, let's set it on partner.

line 87, _defaults is unnecessary

please apply PEP8 to the new code

review: Needs Fixing
lp:~roberto-v/openobject-italia/7.0 updated
242. By Roberto Gianassi

[FIX] Fixed pep8 warnings on new code.

243. By Roberto Gianassi

[MERGE]

Revision history for this message
Roberto Gianassi (roberto-v) wrote :

Ok, fixed.

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Please apply PEP8 to onchange_partner_id too

We would like to avoid introducing other not PEP8 code (there's enough ;-) )

lp:~roberto-v/openobject-italia/7.0 updated
244. By Roberto Gianassi

[FIX] Missing pep8 fixes.

Revision history for this message
Roberto Gianassi (roberto-v) wrote :

Ok, fixed that, too.

Thank you!

Revision history for this message
Lorenzo Battistini (elbati) :
review: Approve (code review)
Revision history for this message
Lorenzo Battistini (elbati) wrote :

This project is now hosted on https://github.com/OCA/l10n-italy. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

Unmerged revisions

244. By Roberto Gianassi

[FIX] Missing pep8 fixes.

243. By Roberto Gianassi

[MERGE]

242. By Roberto Gianassi

[FIX] Fixed pep8 warnings on new code.

241. By Roberto Gianassi

[FIX] When partner field is empty value is False.

The value passed to the onchange_partner_id for the partner is False
when the field is empty. In this case, it is not possible to use such a
value with the browse function or an error arises. Fixed that.

240. By Roberto Gianassi

[FIX] Bug fix to save record.

For unknown reasons, if a boolean value has the required field to True,
it is not possible to save the corresponding supplier record.
Removed the field to fix that.

239. By Roberto Gianassi

[IMP] Changed default_has_withholding type to Boolean.

238. By Roberto Gianassi

[FIX] Typo.

237. By Roberto Gianassi

[FIX] Fixed a bug on XML record creation.

If a module (like fetchmail_invoice) containing a partner record to be
preinstalled through a data.xml file was installed after this one, a
bug occurred.
The bug shows because the record is created with the
default_has_withholding flag to empty and then validation fails.
To solve this, the create function for partners is changed to check for
the presence of that flag in the vals dictionary. If the flag is found,
we assume the creation happens through the UI and so normal checking goes
on. If the flag is not found, we assume the creation happens for an XML
record and so we add an arbitrary, but valid value for the flag.

236. By Roberto Gianassi

[IMP] PEP8 fixings.

235. By Roberto Gianassi

[IMP] Copyright fix.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_it_withholding_tax/__init__.py'
2--- l10n_it_withholding_tax/__init__.py 2013-04-17 10:18:29 +0000
3+++ l10n_it_withholding_tax/__init__.py 2014-02-28 08:04:32 +0000
4@@ -22,3 +22,4 @@
5 ##############################################################################
6
7 import account
8+import partner
9
10=== modified file 'l10n_it_withholding_tax/__openerp__.py'
11--- l10n_it_withholding_tax/__openerp__.py 2013-04-17 14:19:03 +0000
12+++ l10n_it_withholding_tax/__openerp__.py 2014-02-28 08:04:32 +0000
13@@ -48,7 +48,9 @@
14 'license': 'AGPL-3',
15 "depends" : ['account_voucher_cash_basis'],
16 "data" : [
17- 'account_view.xml',],
18+ 'account_view.xml',
19+ 'partner_view.xml',
20+ ],
21 "demo" : [
22 'account_demo.xml',
23 ],
24
25=== modified file 'l10n_it_withholding_tax/account.py'
26--- l10n_it_withholding_tax/account.py 2013-05-09 14:30:36 +0000
27+++ l10n_it_withholding_tax/account.py 2014-02-28 08:04:32 +0000
28@@ -91,18 +91,42 @@
29 return res
30
31 class account_invoice(orm.Model):
32-
33+
34 def _net_pay(self, cr, uid, ids, field_name, arg, context=None):
35 res = {}
36 for invoice in self.browse(cr, uid, ids, context):
37 res[invoice.id] = invoice.amount_total - invoice.withholding_amount
38 return res
39
40+ def onchange_partner_id(
41+ self, cr, uid, ids, type, partner_id,
42+ date_invoice=False, payment_term=False, partner_bank_id=False,
43+ company_id=False):
44+ res = super(account_invoice, self).onchange_partner_id(
45+ cr, uid, ids, type, partner_id, date_invoice, payment_term,
46+ partner_bank_id, company_id)
47+ # default value for VAT on Payment is changed
48+ # every time the supplier is changed
49+ partner_obj = self.pool.get("res.partner")
50+ if partner_id:
51+ for partner in partner_obj.browse(cr, uid, [partner_id]):
52+ if partner.supplier:
53+ res['value']['has_withholding'] = \
54+ partner.default_has_withholding
55+ return res
56+
57 _inherit = "account.invoice"
58
59 _columns = {
60- 'withholding_amount': fields.float('Withholding amount', digits_compute=dp.get_precision('Account'), readonly=True, states={'draft':[('readonly',False)]}),
61- 'has_withholding': fields.boolean('With withholding tax', readonly=True, states={'draft':[('readonly',False)]}),
62+ 'withholding_amount': fields.float(
63+ 'Withholding amount',
64+ digits_compute=dp.get_precision('Account'),
65+ readonly=True,
66+ states={'draft': [('readonly', False)]}),
67+ 'has_withholding': fields.boolean(
68+ 'With withholding tax',
69+ readonly=True,
70+ states={'draft': [('readonly', False)]}),
71 'net_pay': fields.function(_net_pay, string="Net Pay"),
72 }
73
74
75=== added file 'l10n_it_withholding_tax/partner.py'
76--- l10n_it_withholding_tax/partner.py 1970-01-01 00:00:00 +0000
77+++ l10n_it_withholding_tax/partner.py 2014-02-28 08:04:32 +0000
78@@ -0,0 +1,36 @@
79+# -*- coding: utf-8 -*-
80+##############################################################################
81+#
82+# OpenERP, Open Source Management Solution
83+# Copyright (C) 2011-2012 Domsense s.r.l. (<http://www.domsense.com>).
84+# Copyright (C) 2012-2013 Agile Business Group sagl
85+# (<http://www.agilebg.com>)
86+# Copyright (C) 2014 Develer srl (<http://www.develer.com>)
87+#
88+# This program is free software: you can redistribute it and/or modify
89+# it under the terms of the GNU Affero General Public License as
90+# published by the Free Software Foundation, either version 3 of the
91+# License, or (at your option) any later version.
92+#
93+# This program is distributed in the hope that it will be useful,
94+# but WITHOUT ANY WARRANTY; without even the implied warranty of
95+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96+# GNU Affero General Public License for more details.
97+#
98+# You should have received a copy of the GNU Affero General Public License
99+# along with this program. If not, see <http://www.gnu.org/licenses/>.
100+#
101+##############################################################################
102+
103+
104+from openerp.osv import fields, orm
105+from openerp.tools.translate import _
106+
107+
108+class res_partner(orm.Model):
109+ _inherit = 'res.partner'
110+
111+ _columns = {
112+ 'default_has_withholding': fields.boolean(
113+ 'WithHolding Tax Default Flag'),
114+ }
115
116=== added file 'l10n_it_withholding_tax/partner_view.xml'
117--- l10n_it_withholding_tax/partner_view.xml 1970-01-01 00:00:00 +0000
118+++ l10n_it_withholding_tax/partner_view.xml 2014-02-28 08:04:32 +0000
119@@ -0,0 +1,47 @@
120+<?xml version="1.0"?>
121+
122+<!--
123+# -*- coding: utf-8 -*-
124+##############################################################################
125+#
126+# OpenERP, Open Source Management Solution
127+# Copyright (C) 2011-2012 Domsense s.r.l. (<http://www.domsense.com>).
128+# Copyright (C) 2012-2013 Agile Business Group sagl
129+# (<http://www.agilebg.com>)
130+# Copyright (C) 2014 Develer srl (<http://www.develer.com>)
131+#
132+# This program is free software: you can redistribute it and/or modify
133+# it under the terms of the GNU Affero General Public License as
134+# published by the Free Software Foundation, either version 3 of the
135+# License, or (at your option) any later version.
136+#
137+# This program is distributed in the hope that it will be useful,
138+# but WITHOUT ANY WARRANTY; without even the implied warranty of
139+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
140+# GNU Affero General Public License for more details.
141+#
142+# You should have received a copy of the GNU Affero General Public License
143+# along with this program. If not, see <http://www.gnu.org/licenses/>.
144+#
145+##############################################################################
146+-->
147+
148+
149+<openerp>
150+ <data>
151+
152+ <!-- res.partner customizations -->
153+
154+ <record id="view_partner_form" model="ir.ui.view">
155+ <field name="name">res.partner.vat.default.view</field>
156+ <field name="model">res.partner</field>
157+ <field name="inherit_id" ref="account.view_partner_property_form"/>
158+ <field name="arch" type="xml">
159+ <field name="property_account_position" position="after" version="7.0">
160+ <field name="default_has_withholding" class="oe_inline" attrs="{'invisible': [('supplier','!=',True)]}"/>
161+ </field>
162+ </field>
163+ </record>
164+
165+ </data>
166+</openerp>

Subscribers

People subscribed via source and target branches