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
=== added directory 'res_partner_fiscal_position'
=== added file 'res_partner_fiscal_position/__init__.py'
--- res_partner_fiscal_position/__init__.py 1970-01-01 00:00:00 +0000
+++ res_partner_fiscal_position/__init__.py 2014-09-18 15:30:20 +0000
@@ -0,0 +1,1 @@
1import model
02
=== added file 'res_partner_fiscal_position/__openerp__.py'
--- res_partner_fiscal_position/__openerp__.py 1970-01-01 00:00:00 +0000
+++ res_partner_fiscal_position/__openerp__.py 2014-09-18 15:30:20 +0000
@@ -0,0 +1,40 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2013 Therp BV (<http://therp.nl>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21{
22 'name': 'Country fiscal position',
23 'version': '7.0',
24 'category': 'Accounting',
25 'description': '''
26 This module automatically select the fiscal position from the country table.
27 based on the module account_fiscal_position_country of agilebg.
28 ''',
29 'author': 'Therp BV',
30 'website': 'http://www.therp.nl',
31 'depends': [
32 'base',
33 'account',
34 ],
35 'data': [
36 'view/res_country.xml',
37 'view/res_partner.xml',
38 ],
39 "installable": True,
40}
041
=== added directory 'res_partner_fiscal_position/model'
=== added file 'res_partner_fiscal_position/model/__init__.py'
--- res_partner_fiscal_position/model/__init__.py 1970-01-01 00:00:00 +0000
+++ res_partner_fiscal_position/model/__init__.py 2014-09-18 15:30:20 +0000
@@ -0,0 +1,3 @@
1from . import res_partner
2from . import res_country
3from . import account_fiscal_position
04
=== added file 'res_partner_fiscal_position/model/account_fiscal_position.py'
--- res_partner_fiscal_position/model/account_fiscal_position.py 1970-01-01 00:00:00 +0000
+++ res_partner_fiscal_position/model/account_fiscal_position.py 2014-09-18 15:30:20 +0000
@@ -0,0 +1,40 @@
1#-*- coding: utf-8 -*-
2'''Enhance account.fiscla.position to show company'''
3##############################################################################
4#
5# OpenERP, Open Source Management Solution
6# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
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##############################################################################
22from openerp.osv import orm, fields
23
24
25class AccountFiscalPosition(orm.Model):
26 '''Add company if possible to name of fiscal position.'''
27 _inherit = 'account.fiscal.position'
28
29 def name_get(self, cr, uid, ids, context=None):
30 '''Return name, including company.'''
31 reads = self.read(
32 cr, uid, ids, ['name', 'company_id'], context=context)
33 res = []
34 for record in reads:
35 if record['company_id']:
36 name = record['company_id'][1] + ' ' + record['name']
37 else:
38 name = record['name']
39 res.append((record['id'], name))
40 return res
041
=== added file 'res_partner_fiscal_position/model/res_country.py'
--- res_partner_fiscal_position/model/res_country.py 1970-01-01 00:00:00 +0000
+++ res_partner_fiscal_position/model/res_country.py 2014-09-18 15:30:20 +0000
@@ -0,0 +1,40 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
5# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published
9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21from osv import fields, osv
22
23
24class Country(osv.osv):
25 _inherit = 'res.country'
26 _columns = {
27 # 'fiscal_position_id': fields.many2one(
28 # 'account.fiscal.position','Default fiscal position'),
29 'property_account_position': fields.property
30 ('account.fiscal.position',
31 type='many2one',
32 relation='account.fiscal.position',
33 string="Default Fiscal Position",
34 method=True,
35 view_load=True,
36 help="""The fiscal position will determine
37 taxes and the accounts used for the country,
38 if not set specifically elsewere.""",),
39 }
40Country()
041
=== added file 'res_partner_fiscal_position/model/res_partner.py'
--- res_partner_fiscal_position/model/res_partner.py 1970-01-01 00:00:00 +0000
+++ res_partner_fiscal_position/model/res_partner.py 2014-09-18 15:30:20 +0000
@@ -0,0 +1,36 @@
1#-*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21from openerp.osv import orm
22
23
24class ResPartner(orm.Model):
25 _inherit = 'res.partner'
26
27 def on_change_country_id(
28 self, cr, uid, ids, country_id, context=None):
29
30 if not country_id:
31 return {}
32 country = self.pool['res.country'].browse(cr, uid,
33 country_id, context=context)
34 fis_pos_id = country.property_account_position.id
35
36 return {'value': {'property_account_position': fis_pos_id}}
037
=== added directory 'res_partner_fiscal_position/view'
=== added file 'res_partner_fiscal_position/view/res_country.xml'
--- res_partner_fiscal_position/view/res_country.xml 1970-01-01 00:00:00 +0000
+++ res_partner_fiscal_position/view/res_country.xml 2014-09-18 15:30:20 +0000
@@ -0,0 +1,18 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4
5 <record model="ir.ui.view" id="res_partner_fiscal_position_form">
6 <field name="name">res.partner.fiscal.position.form</field>
7 <field name="model">res.country</field>
8 <field name="inherit_id" ref="base.view_country_form"/>
9 <field name="arch" type="xml">
10 <field name="code" position="after">
11 <field name="property_account_position" widget="selection"/>
12 </field>
13 </field>
14 </record>
15
16 </data>
17</openerp>
18
019
=== added file 'res_partner_fiscal_position/view/res_partner.xml'
--- res_partner_fiscal_position/view/res_partner.xml 1970-01-01 00:00:00 +0000
+++ res_partner_fiscal_position/view/res_partner.xml 2014-09-18 15:30:20 +0000
@@ -0,0 +1,18 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4
5 <record model="ir.ui.view" id="view_base_form_fiscal_position">
6 <field name="name">res.partner.fiscal.position.form</field>
7 <field name="model">res.partner</field>
8 <field name="inherit_id" ref="base.view_partner_form"/>
9 <field name="arch" type="xml">
10
11 <field name="country_id" position="replace">
12 <field name="country_id" on_change="on_change_country_id(country_id)" placeholder="Country"/>
13 </field>
14 </field>
15 </record>
16
17 </data>
18</openerp>

Subscribers

People subscribed via source and target branches

to all changes: