Merge lp:~luc-demeyer/openobject-addons/7.0-partner-accounting-fix into lp:openobject-addons/7.0

Proposed by Luc De Meyer (Noviat) on 2013-02-18
Status: Needs review
Proposed branch: lp:~luc-demeyer/openobject-addons/7.0-partner-accounting-fix
Merge into: lp:openobject-addons/7.0
Diff against target: 174 lines (+148/-0)
5 files modified
partner_accounting_fix/__init__.py (+23/-0)
partner_accounting_fix/__openerp__.py (+42/-0)
partner_accounting_fix/account_invoice.py (+35/-0)
partner_accounting_fix/accounting_partner.py (+29/-0)
partner_accounting_fix/res_partner_view.xml (+19/-0)
To merge this branch: bzr merge lp:~luc-demeyer/openobject-addons/7.0-partner-accounting-fix
Reviewer Review Type Date Requested Status
OpenERP Core Team 2013-02-18 Pending
Review via email: mp+149167@code.launchpad.net

Description of the change

This module fixes an inconsistency between the way OpenERP 7.0 treats the partner accounting parameters :
• For invoices, the accounts payable/receivable of the partner ‘company’ record (if any) is used (which is the right way)
• For other accounting parameters (e.g. VAT number, payment terms, ... ) the partner ‘contact’ record is used (hence : 10 contacts within the same partner company may have 10 different VAT numbers … ).

How to use functionality offered by this fix e.g. have a look to the account_invoice.py

Line 23 : from openerp.addons.partner_accounting_fix.accounting_partner import accounting_partner
Line 31: partner = accounting_partner(partner) # replace by the partner for which the accounting entries will be created

So basically : 2 lines of code, 5 minutes of work and the whole thing becomes consistent (but these 5 minutes are required in all modules which retrieve partner accounting parameters).

Please merge the 'partner_accounting_fix’ functionality into the OpenERP standard V7.0 distribution.

To post a comment you must log in.

Unmerged revisions

8724. By openerp <openerp@oerp70> on 2013-02-18

fix inconsistency in partner accounting parameters

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'partner_accounting_fix'
2=== added file 'partner_accounting_fix/__init__.py'
3--- partner_accounting_fix/__init__.py 1970-01-01 00:00:00 +0000
4+++ partner_accounting_fix/__init__.py 2013-02-18 21:59:22 +0000
5@@ -0,0 +1,23 @@
6+# -*- encoding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+#
11+# Copyright (c) 2013 Noviat nv/sa (www.noviat.be). All rights reserved.
12+#
13+# This program is free software: you can redistribute it and/or modify
14+# it under the terms of the GNU Affero General Public License as
15+# published by the Free Software Foundation, either version 3 of the
16+# License, or (at your option) any later version.
17+#
18+# This program is distributed in the hope that it will be useful,
19+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+# GNU Affero General Public License for more details.
22+#
23+# You should have received a copy of the GNU Affero General Public License
24+# along with this program. If not, see <http://www.gnu.org/licenses/>.
25+#
26+##############################################################################
27+
28+import account_invoice
29\ No newline at end of file
30
31=== added file 'partner_accounting_fix/__openerp__.py'
32--- partner_accounting_fix/__openerp__.py 1970-01-01 00:00:00 +0000
33+++ partner_accounting_fix/__openerp__.py 2013-02-18 21:59:22 +0000
34@@ -0,0 +1,42 @@
35+# -*- encoding: utf-8 -*-
36+##############################################################################
37+#
38+# OpenERP, Open Source Management Solution
39+#
40+# Copyright (c) 2013 Noviat nv/sa (www.noviat.be). All rights reserved.
41+#
42+# This program is free software: you can redistribute it and/or modify
43+# it under the terms of the GNU Affero General Public License as
44+# published by the Free Software Foundation, either version 3 of the
45+# License, or (at your option) any later version.
46+#
47+# This program is distributed in the hope that it will be useful,
48+# but WITHOUT ANY WARRANTY; without even the implied warranty of
49+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50+# GNU Affero General Public License for more details.
51+#
52+# You should have received a copy of the GNU Affero General Public License
53+# along with this program. If not, see <http://www.gnu.org/licenses/>.
54+#
55+##############################################################################
56+
57+{
58+ 'name': 'Partner Account Properties fixes',
59+ 'version': '0.1',
60+ 'license': 'AGPL-3',
61+ 'author': 'Noviat',
62+ 'category' : 'Generic Modules',
63+ 'description': """
64+
65+ Hide accounting fields on partner 'contact' records.
66+ This equires also a change of legal reports (e.g. invoice to retrieve the VAT number from the parent record).
67+
68+ """,
69+ 'depends': ['account'],
70+ 'demo_xml': [],
71+ 'init_xml': [],
72+ 'update_xml' : [
73+ 'res_partner_view.xml',
74+ ],
75+ 'auto_install': True,
76+ }
77
78=== added file 'partner_accounting_fix/account_invoice.py'
79--- partner_accounting_fix/account_invoice.py 1970-01-01 00:00:00 +0000
80+++ partner_accounting_fix/account_invoice.py 2013-02-18 21:59:22 +0000
81@@ -0,0 +1,35 @@
82+# -*- encoding: utf-8 -*-
83+##############################################################################
84+#
85+# OpenERP, Open Source Management Solution
86+#
87+# Copyright (c) 2013 Noviat nv/sa (www.noviat.be). All rights reserved.
88+#
89+# This program is free software: you can redistribute it and/or modify
90+# it under the terms of the GNU Affero General Public License as
91+# published by the Free Software Foundation, either version 3 of the
92+# License, or (at your option) any later version.
93+#
94+# This program is distributed in the hope that it will be useful,
95+# but WITHOUT ANY WARRANTY; without even the implied warranty of
96+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
97+# GNU Affero General Public License for more details.
98+#
99+# You should have received a copy of the GNU Affero General Public License
100+# along with this program. If not, see <http://www.gnu.org/licenses/>.
101+#
102+##############################################################################
103+
104+from openerp.osv import osv, fields
105+from openerp.addons.partner_accounting_fix.accounting_partner import accounting_partner
106+
107+class account_invoice(osv.osv):
108+ _inherit = 'account.invoice'
109+
110+ def onchange_partner_id(self, cr, uid, ids, type, partner_id,\
111+ date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):
112+ partner = self.pool.get('res.partner').browse(cr, uid, partner_id)
113+ partner = accounting_partner(partner) # replace by partner for which the accounting entries will be created
114+ return super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner.id, \
115+ date_invoice, payment_term, partner_bank_id, company_id)
116+
117
118=== added file 'partner_accounting_fix/accounting_partner.py'
119--- partner_accounting_fix/accounting_partner.py 1970-01-01 00:00:00 +0000
120+++ partner_accounting_fix/accounting_partner.py 2013-02-18 21:59:22 +0000
121@@ -0,0 +1,29 @@
122+# -*- encoding: utf-8 -*-
123+##############################################################################
124+#
125+# OpenERP, Open Source Management Solution
126+#
127+# Copyright (c) 2013 Noviat nv/sa (www.noviat.be). All rights reserved.
128+#
129+# This program is free software: you can redistribute it and/or modify
130+# it under the terms of the GNU Affero General Public License as
131+# published by the Free Software Foundation, either version 3 of the
132+# License, or (at your option) any later version.
133+#
134+# This program is distributed in the hope that it will be useful,
135+# but WITHOUT ANY WARRANTY; without even the implied warranty of
136+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
137+# GNU Affero General Public License for more details.
138+#
139+# You should have received a copy of the GNU Affero General Public License
140+# along with this program. If not, see <http://www.gnu.org/licenses/>.
141+#
142+##############################################################################
143+
144+def accounting_partner(partner):
145+ """
146+ Returns the partner for which the accounting entries will be created.
147+ """
148+ if partner.parent_id and not partner.is_company:
149+ partner = partner.parent_id
150+ return partner
151
152=== added file 'partner_accounting_fix/res_partner_view.xml'
153--- partner_accounting_fix/res_partner_view.xml 1970-01-01 00:00:00 +0000
154+++ partner_accounting_fix/res_partner_view.xml 2013-02-18 21:59:22 +0000
155@@ -0,0 +1,19 @@
156+<?xml version="1.0" encoding="utf-8"?>
157+<openerp>
158+ <data>
159+
160+ <!-- hide accounting fields for 'contact' partners records -->
161+ <record id="view_partner_form_fix" model="ir.ui.view">
162+ <field name="name">res.partner.vat.fix</field>
163+ <field name="model">res.partner</field>
164+ <field name="inherit_id" ref="account.view_partner_property_form"/>
165+ <field name="arch" type="xml">
166+ <xpath expr="//page[@string='Accounting']" position="attributes">
167+ <attribute name="attrs">{'invisible':[('is_company','=',False),('parent_id','!=',False)]}</attribute>
168+ </xpath>
169+ </field>
170+ </record>
171+
172+ </data>
173+</openerp>
174+