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

Proposed by Luc De Meyer (Noviat)
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 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>

fix inconsistency in partner accounting parameters

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'partner_accounting_fix'
=== added file 'partner_accounting_fix/__init__.py'
--- partner_accounting_fix/__init__.py 1970-01-01 00:00:00 +0000
+++ partner_accounting_fix/__init__.py 2013-02-18 21:59:22 +0000
@@ -0,0 +1,23 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5#
6# Copyright (c) 2013 Noviat nv/sa (www.noviat.be). All rights reserved.
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import account_invoice
0\ No newline at end of file24\ No newline at end of file
125
=== added file 'partner_accounting_fix/__openerp__.py'
--- partner_accounting_fix/__openerp__.py 1970-01-01 00:00:00 +0000
+++ partner_accounting_fix/__openerp__.py 2013-02-18 21:59:22 +0000
@@ -0,0 +1,42 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5#
6# Copyright (c) 2013 Noviat nv/sa (www.noviat.be). All rights reserved.
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23{
24 'name': 'Partner Account Properties fixes',
25 'version': '0.1',
26 'license': 'AGPL-3',
27 'author': 'Noviat',
28 'category' : 'Generic Modules',
29 'description': """
30
31 Hide accounting fields on partner 'contact' records.
32 This equires also a change of legal reports (e.g. invoice to retrieve the VAT number from the parent record).
33
34 """,
35 'depends': ['account'],
36 'demo_xml': [],
37 'init_xml': [],
38 'update_xml' : [
39 'res_partner_view.xml',
40 ],
41 'auto_install': True,
42 }
043
=== added file 'partner_accounting_fix/account_invoice.py'
--- partner_accounting_fix/account_invoice.py 1970-01-01 00:00:00 +0000
+++ partner_accounting_fix/account_invoice.py 2013-02-18 21:59:22 +0000
@@ -0,0 +1,35 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5#
6# Copyright (c) 2013 Noviat nv/sa (www.noviat.be). All rights reserved.
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23from openerp.osv import osv, fields
24from openerp.addons.partner_accounting_fix.accounting_partner import accounting_partner
25
26class account_invoice(osv.osv):
27 _inherit = 'account.invoice'
28
29 def onchange_partner_id(self, cr, uid, ids, type, partner_id,\
30 date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):
31 partner = self.pool.get('res.partner').browse(cr, uid, partner_id)
32 partner = accounting_partner(partner) # replace by partner for which the accounting entries will be created
33 return super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner.id, \
34 date_invoice, payment_term, partner_bank_id, company_id)
35
036
=== added file 'partner_accounting_fix/accounting_partner.py'
--- partner_accounting_fix/accounting_partner.py 1970-01-01 00:00:00 +0000
+++ partner_accounting_fix/accounting_partner.py 2013-02-18 21:59:22 +0000
@@ -0,0 +1,29 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5#
6# Copyright (c) 2013 Noviat nv/sa (www.noviat.be). All rights reserved.
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23def accounting_partner(partner):
24 """
25 Returns the partner for which the accounting entries will be created.
26 """
27 if partner.parent_id and not partner.is_company:
28 partner = partner.parent_id
29 return partner
030
=== added file 'partner_accounting_fix/res_partner_view.xml'
--- partner_accounting_fix/res_partner_view.xml 1970-01-01 00:00:00 +0000
+++ partner_accounting_fix/res_partner_view.xml 2013-02-18 21:59:22 +0000
@@ -0,0 +1,19 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <!-- hide accounting fields for 'contact' partners records -->
6 <record id="view_partner_form_fix" model="ir.ui.view">
7 <field name="name">res.partner.vat.fix</field>
8 <field name="model">res.partner</field>
9 <field name="inherit_id" ref="account.view_partner_property_form"/>
10 <field name="arch" type="xml">
11 <xpath expr="//page[@string='Accounting']" position="attributes">
12 <attribute name="attrs">{'invisible':[('is_company','=',False),('parent_id','!=',False)]}</attribute>
13 </xpath>
14 </field>
15 </record>
16
17 </data>
18</openerp>
19