Merge lp:~lfreeke/therp-addons/7.0-res_partner_fiscal_position into lp:~therp-nl/therp-addons/7.0

Proposed by Lara (Therp)
Status: Rejected
Rejected by: Holger Brunn (Therp)
Proposed branch: lp:~lfreeke/therp-addons/7.0-res_partner_fiscal_position
Merge into: lp:~therp-nl/therp-addons/7.0
Diff against target: 238 lines (+196/-0)
8 files modified
res_partner_fiscal_position/__init__.py (+1/-0)
res_partner_fiscal_position/__openerp__.py (+40/-0)
res_partner_fiscal_position/model/__init__.py (+3/-0)
res_partner_fiscal_position/model/account_fiscal_position.py (+40/-0)
res_partner_fiscal_position/model/res_country.py (+40/-0)
res_partner_fiscal_position/model/res_partner.py (+36/-0)
res_partner_fiscal_position/view/res_country.xml (+18/-0)
res_partner_fiscal_position/view/res_partner.xml (+18/-0)
To merge this branch: bzr merge lp:~lfreeke/therp-addons/7.0-res_partner_fiscal_position
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) Disapprove
Stefan Rijnhart (Opener) (community) Needs Fixing
Review via email: mp+235155@code.launchpad.net

Description of the change

add a new module. See module description

To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks! Looks really useful. Some comments:

If I understand correctly, name_get() was modified to display the company of the fiscal position, because in a superior company the fiscal positions of the underlying companies are accessible. This could help the user not to pick a fiscal position of any other company than the one it is working for at that moment, but it does not prevent a mixup of company data. I would prefer to filter the fiscal positions on the current user's company. You may have to create a function field on res.country to be able to access this piece of data though.

In the manifest, please explain what is different in this module from the module that it is based on.

The object instantiation in line number 150 is not needed in recent versions of Odoo and should be removed.

Please remove commented code in ll.136,137

review: Needs Fixing
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

Rejected because this lives on https://github.com/Therp/Therp-Addons/pull/2 now

review: Disapprove

Unmerged revisions

110. By Ronald Portier (Therp)

[FIX] Module res_partner_fiscal_position:
    - No multiple inheritance on account.fiscal.position

109. By Ronald Portier (Therp)

[ENH] Module res_partner_fiscal_position:
    - show company on selection of fiscal position.

108. By <email address hidden>

[ADD] res_partner_fiscal position. Adds fiscal position to country and will add fiscal position when selecting country at a partner.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'res_partner_fiscal_position'
2=== added file 'res_partner_fiscal_position/__init__.py'
3--- res_partner_fiscal_position/__init__.py 1970-01-01 00:00:00 +0000
4+++ res_partner_fiscal_position/__init__.py 2014-09-18 15:30:20 +0000
5@@ -0,0 +1,1 @@
6+import model
7
8=== added file 'res_partner_fiscal_position/__openerp__.py'
9--- res_partner_fiscal_position/__openerp__.py 1970-01-01 00:00:00 +0000
10+++ res_partner_fiscal_position/__openerp__.py 2014-09-18 15:30:20 +0000
11@@ -0,0 +1,40 @@
12+# -*- encoding: utf-8 -*-
13+##############################################################################
14+#
15+# OpenERP, Open Source Management Solution
16+# This module copyright (C) 2013 Therp BV (<http://therp.nl>).
17+#
18+# This program is free software: you can redistribute it and/or modify
19+# it under the terms of the GNU Affero General Public License as
20+# published by the Free Software Foundation, either version 3 of the
21+# License, or (at your option) any later version.
22+#
23+# This program is distributed in the hope that it will be useful,
24+# but WITHOUT ANY WARRANTY; without even the implied warranty of
25+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26+# GNU Affero General Public License for more details.
27+#
28+# You should have received a copy of the GNU Affero General Public License
29+# along with this program. If not, see <http://www.gnu.org/licenses/>.
30+#
31+##############################################################################
32+{
33+ 'name': 'Country fiscal position',
34+ 'version': '7.0',
35+ 'category': 'Accounting',
36+ 'description': '''
37+ This module automatically select the fiscal position from the country table.
38+ based on the module account_fiscal_position_country of agilebg.
39+ ''',
40+ 'author': 'Therp BV',
41+ 'website': 'http://www.therp.nl',
42+ 'depends': [
43+ 'base',
44+ 'account',
45+ ],
46+ 'data': [
47+ 'view/res_country.xml',
48+ 'view/res_partner.xml',
49+ ],
50+ "installable": True,
51+}
52
53=== added directory 'res_partner_fiscal_position/model'
54=== added file 'res_partner_fiscal_position/model/__init__.py'
55--- res_partner_fiscal_position/model/__init__.py 1970-01-01 00:00:00 +0000
56+++ res_partner_fiscal_position/model/__init__.py 2014-09-18 15:30:20 +0000
57@@ -0,0 +1,3 @@
58+from . import res_partner
59+from . import res_country
60+from . import account_fiscal_position
61
62=== added file 'res_partner_fiscal_position/model/account_fiscal_position.py'
63--- res_partner_fiscal_position/model/account_fiscal_position.py 1970-01-01 00:00:00 +0000
64+++ res_partner_fiscal_position/model/account_fiscal_position.py 2014-09-18 15:30:20 +0000
65@@ -0,0 +1,40 @@
66+#-*- coding: utf-8 -*-
67+'''Enhance account.fiscla.position to show company'''
68+##############################################################################
69+#
70+# OpenERP, Open Source Management Solution
71+# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
72+#
73+# This program is free software: you can redistribute it and/or modify
74+# it under the terms of the GNU Affero General Public License as
75+# published by the Free Software Foundation, either version 3 of the
76+# License, or (at your option) any later version.
77+#
78+# This program is distributed in the hope that it will be useful,
79+# but WITHOUT ANY WARRANTY; without even the implied warranty of
80+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81+# GNU Affero General Public License for more details.
82+#
83+# You should have received a copy of the GNU Affero General Public License
84+# along with this program. If not, see <http://www.gnu.org/licenses/>.
85+#
86+##############################################################################
87+from openerp.osv import orm, fields
88+
89+
90+class AccountFiscalPosition(orm.Model):
91+ '''Add company if possible to name of fiscal position.'''
92+ _inherit = 'account.fiscal.position'
93+
94+ def name_get(self, cr, uid, ids, context=None):
95+ '''Return name, including company.'''
96+ reads = self.read(
97+ cr, uid, ids, ['name', 'company_id'], context=context)
98+ res = []
99+ for record in reads:
100+ if record['company_id']:
101+ name = record['company_id'][1] + ' ' + record['name']
102+ else:
103+ name = record['name']
104+ res.append((record['id'], name))
105+ return res
106
107=== added file 'res_partner_fiscal_position/model/res_country.py'
108--- res_partner_fiscal_position/model/res_country.py 1970-01-01 00:00:00 +0000
109+++ res_partner_fiscal_position/model/res_country.py 2014-09-18 15:30:20 +0000
110@@ -0,0 +1,40 @@
111+# -*- coding: utf-8 -*-
112+##############################################################################
113+#
114+# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
115+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
116+#
117+# This program is free software: you can redistribute it and/or modify
118+# it under the terms of the GNU Affero General Public License as published
119+# by the Free Software Foundation, either version 3 of the License, or
120+# (at your option) any later version.
121+#
122+# This program is distributed in the hope that it will be useful,
123+# but WITHOUT ANY WARRANTY; without even the implied warranty of
124+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
125+# GNU General Public License for more details.
126+#
127+# You should have received a copy of the GNU Affero General Public License
128+# along with this program. If not, see <http://www.gnu.org/licenses/>.
129+#
130+##############################################################################
131+from osv import fields, osv
132+
133+
134+class Country(osv.osv):
135+ _inherit = 'res.country'
136+ _columns = {
137+ # 'fiscal_position_id': fields.many2one(
138+ # 'account.fiscal.position','Default fiscal position'),
139+ 'property_account_position': fields.property
140+ ('account.fiscal.position',
141+ type='many2one',
142+ relation='account.fiscal.position',
143+ string="Default Fiscal Position",
144+ method=True,
145+ view_load=True,
146+ help="""The fiscal position will determine
147+ taxes and the accounts used for the country,
148+ if not set specifically elsewere.""",),
149+ }
150+Country()
151
152=== added file 'res_partner_fiscal_position/model/res_partner.py'
153--- res_partner_fiscal_position/model/res_partner.py 1970-01-01 00:00:00 +0000
154+++ res_partner_fiscal_position/model/res_partner.py 2014-09-18 15:30:20 +0000
155@@ -0,0 +1,36 @@
156+#-*- coding: utf-8 -*-
157+##############################################################################
158+#
159+# OpenERP, Open Source Management Solution
160+# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
161+#
162+# This program is free software: you can redistribute it and/or modify
163+# it under the terms of the GNU Affero General Public License as
164+# published by the Free Software Foundation, either version 3 of the
165+# License, or (at your option) any later version.
166+#
167+# This program is distributed in the hope that it will be useful,
168+# but WITHOUT ANY WARRANTY; without even the implied warranty of
169+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
170+# GNU Affero General Public License for more details.
171+#
172+# You should have received a copy of the GNU Affero General Public License
173+# along with this program. If not, see <http://www.gnu.org/licenses/>.
174+#
175+##############################################################################
176+from openerp.osv import orm
177+
178+
179+class ResPartner(orm.Model):
180+ _inherit = 'res.partner'
181+
182+ def on_change_country_id(
183+ self, cr, uid, ids, country_id, context=None):
184+
185+ if not country_id:
186+ return {}
187+ country = self.pool['res.country'].browse(cr, uid,
188+ country_id, context=context)
189+ fis_pos_id = country.property_account_position.id
190+
191+ return {'value': {'property_account_position': fis_pos_id}}
192
193=== added directory 'res_partner_fiscal_position/view'
194=== added file 'res_partner_fiscal_position/view/res_country.xml'
195--- res_partner_fiscal_position/view/res_country.xml 1970-01-01 00:00:00 +0000
196+++ res_partner_fiscal_position/view/res_country.xml 2014-09-18 15:30:20 +0000
197@@ -0,0 +1,18 @@
198+<?xml version="1.0" encoding="UTF-8"?>
199+<openerp>
200+ <data>
201+
202+ <record model="ir.ui.view" id="res_partner_fiscal_position_form">
203+ <field name="name">res.partner.fiscal.position.form</field>
204+ <field name="model">res.country</field>
205+ <field name="inherit_id" ref="base.view_country_form"/>
206+ <field name="arch" type="xml">
207+ <field name="code" position="after">
208+ <field name="property_account_position" widget="selection"/>
209+ </field>
210+ </field>
211+ </record>
212+
213+ </data>
214+</openerp>
215+
216
217=== added file 'res_partner_fiscal_position/view/res_partner.xml'
218--- res_partner_fiscal_position/view/res_partner.xml 1970-01-01 00:00:00 +0000
219+++ res_partner_fiscal_position/view/res_partner.xml 2014-09-18 15:30:20 +0000
220@@ -0,0 +1,18 @@
221+<?xml version="1.0" encoding="UTF-8"?>
222+<openerp>
223+ <data>
224+
225+ <record model="ir.ui.view" id="view_base_form_fiscal_position">
226+ <field name="name">res.partner.fiscal.position.form</field>
227+ <field name="model">res.partner</field>
228+ <field name="inherit_id" ref="base.view_partner_form"/>
229+ <field name="arch" type="xml">
230+
231+ <field name="country_id" position="replace">
232+ <field name="country_id" on_change="on_change_country_id(country_id)" placeholder="Country"/>
233+ </field>
234+ </field>
235+ </record>
236+
237+ </data>
238+</openerp>

Subscribers

People subscribed via source and target branches

to all changes: