Merge lp:~agilebg/account-invoicing/adding_account_fiscal_position_country_7 into lp:~account-core-editors/account-invoicing/7.0

Proposed by Alex Comba - Agile BG
Status: Rejected
Rejected by: Pedro Manuel Baeza
Proposed branch: lp:~agilebg/account-invoicing/adding_account_fiscal_position_country_7
Merge into: lp:~account-core-editors/account-invoicing/7.0
Diff against target: 203 lines (+178/-0)
5 files modified
account_fiscal_position_country/__init__.py (+25/-0)
account_fiscal_position_country/__openerp__.py (+47/-0)
account_fiscal_position_country/country.py (+39/-0)
account_fiscal_position_country/country_view.xml (+17/-0)
account_fiscal_position_country/invoice.py (+50/-0)
To merge this branch: bzr merge lp:~agilebg/account-invoicing/adding_account_fiscal_position_country_7
Reviewer Review Type Date Requested Status
Lorenzo Battistini (community) Disapprove
Guewen Baconnier @ Camptocamp Needs Information
Review via email: mp+182636@code.launchpad.net

Description of the change

This branch adds the account_fiscal_position_country porting to 7.0

Module description:

A rule to select automatically the fiscal position based on the country.
In the configuration of the country, choose a default fiscal position for it.
When selecting a partner in an invoice, if the fiscal position for the partner is not set, the one from the country will be used.

To post a comment you must log in.
Revision history for this message
Lorenzo Battistini (elbati) wrote :

line 189: too long

review: Needs Fixing
23. By Alex Comba - Agile BG

[FIX] PEP8 style

Revision history for this message
Alex Comba - Agile BG (tafaru) wrote :

Lorenzo, now it should be ok.

Revision history for this message
Lorenzo Battistini (elbati) :
review: Approve
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Seems redundant with account_fiscal_position_rule in the https://code.launchpad.net/openerp-fiscal-rules project.
Do you have a reason for not reusing it?

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

Guewen, you are right. The functionality seems to be already covered by account_fiscal_position_rule*
I'm closing this MP

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

"I'm closing this MP"

I can't :-)

You can reject this MP.

Thanks

Unmerged revisions

23. By Alex Comba - Agile BG

[FIX] PEP8 style

22. By Alex Comba - Agile BG

[FIX] avoid country_ids and adjust onchange_partner_id

21. By Alex Comba - Agile BG

[IMP] class name

20. By Alex Comba - Agile BG

[REF] ported module account_fiscal_position_country to ver. 7.0

19. By Alex Comba - Agile BG

[ADD] module account_fiscal_position_country ver. 6.1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_fiscal_position_country'
2=== added file 'account_fiscal_position_country/__init__.py'
3--- account_fiscal_position_country/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_fiscal_position_country/__init__.py 2013-08-28 16:12:06 +0000
5@@ -0,0 +1,25 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
10+# Copyright (C) 2011-2013 Agile Business Group sagl
11+# (<http://www.agilebg.com>)
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 published
15+# by the Free Software Foundation, either version 3 of the License, or
16+# (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 country
29+import account
30+import invoice
31
32=== added file 'account_fiscal_position_country/__openerp__.py'
33--- account_fiscal_position_country/__openerp__.py 1970-01-01 00:00:00 +0000
34+++ account_fiscal_position_country/__openerp__.py 2013-08-28 16:12:06 +0000
35@@ -0,0 +1,47 @@
36+# -*- coding: utf-8 -*-
37+##############################################################################
38+#
39+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
40+# Copyright (C) 2011-2013 Agile Business Group sagl
41+# (<http://www.agilebg.com>)
42+# @author Leonardo Pistone <leonardo.pistone@agilebg.com>
43+# Ported to OpenERP 7.0 by Alex Comba <alex.comba@agilebg.com>
44+#
45+# This program is free software: you can redistribute it and/or modify
46+# it under the terms of the GNU Affero General Public License as published
47+# by the Free Software Foundation, either version 3 of the License, or
48+# (at your option) any later version.
49+#
50+# This program is distributed in the hope that it will be useful,
51+# but WITHOUT ANY WARRANTY; without even the implied warranty of
52+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53+# GNU Affero General Public License for more details.
54+#
55+# You should have received a copy of the GNU Affero General Public License
56+# along with this program. If not, see <http://www.gnu.org/licenses/>.
57+#
58+##############################################################################
59+
60+{
61+ 'name': 'Fiscal Position by country',
62+ 'version': '0.3',
63+ 'category': 'Generic Modules/Accounting',
64+ 'description': """
65+A rule to select automatically the fiscal position based on the country
66+In the configuration of the country, choose a default fiscal position for it.
67+When selecting a partner in an invoice, if the fiscal position for the partner
68+is not set, the one from the country will be used.
69+ """,
70+ 'author': 'Agile Business Group',
71+ 'website': 'http://www.agilebg.com',
72+ 'license': 'AGPL-3',
73+ 'depends': [
74+ 'base',
75+ 'account',
76+ ],
77+ 'data': [
78+ 'country_view.xml',
79+ ],
80+ "active": False,
81+ 'installable': True,
82+}
83
84=== added file 'account_fiscal_position_country/country.py'
85--- account_fiscal_position_country/country.py 1970-01-01 00:00:00 +0000
86+++ account_fiscal_position_country/country.py 2013-08-28 16:12:06 +0000
87@@ -0,0 +1,39 @@
88+# -*- coding: utf-8 -*-
89+##############################################################################
90+#
91+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
92+# Copyright (C) 2011-2013 Agile Business Group sagl
93+# (<http://www.agilebg.com>)
94+#
95+# This program is free software: you can redistribute it and/or modify
96+# it under the terms of the GNU Affero General Public License as published
97+# by the Free Software Foundation, either version 3 of the License, or
98+# (at your option) any later version.
99+#
100+# This program is distributed in the hope that it will be useful,
101+# but WITHOUT ANY WARRANTY; without even the implied warranty of
102+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
103+# GNU Affero General Public License for more details.
104+#
105+# You should have received a copy of the GNU Affero General Public License
106+# along with this program. If not, see <http://www.gnu.org/licenses/>.
107+#
108+##############################################################################
109+
110+from openerp.osv import fields, orm
111+
112+
113+class res_country(orm.Model):
114+ _inherit = 'res.country'
115+ _columns = {
116+ 'property_account_position': fields.property(
117+ 'account.fiscal.position',
118+ type='many2one',
119+ relation='account.fiscal.position',
120+ string="Default Fiscal Position",
121+ method=True,
122+ view_load=True,
123+ help="""The fiscal position will determine taxes and the accounts
124+ used for the country, if not set specifically elsewere.""",
125+ ),
126+ }
127
128=== added file 'account_fiscal_position_country/country_view.xml'
129--- account_fiscal_position_country/country_view.xml 1970-01-01 00:00:00 +0000
130+++ account_fiscal_position_country/country_view.xml 2013-08-28 16:12:06 +0000
131@@ -0,0 +1,17 @@
132+<?xml version="1.0" encoding="UTF-8"?>
133+<openerp>
134+ <data>
135+
136+ <record model="ir.ui.view" id="view_country_fiscal_position_form">
137+ <field name="name">country.fiscal.position.form</field>
138+ <field name="model">res.country</field>
139+ <field name="inherit_id" ref="base.view_country_form"/>
140+ <field name="arch" type="xml">
141+ <field name="code" position="after">
142+ <field name="property_account_position" widget="selection"/>
143+ </field>
144+ </field>
145+ </record>
146+
147+ </data>
148+</openerp>
149
150=== added file 'account_fiscal_position_country/invoice.py'
151--- account_fiscal_position_country/invoice.py 1970-01-01 00:00:00 +0000
152+++ account_fiscal_position_country/invoice.py 2013-08-28 16:12:06 +0000
153@@ -0,0 +1,50 @@
154+# -*- coding: utf-8 -*-
155+##############################################################################
156+#
157+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
158+# Copyright (C) 2011-2013 Agile Business Group sagl
159+# (<http://www.agilebg.com>)
160+#
161+# This program is free software: you can redistribute it and/or modify
162+# it under the terms of the GNU Affero General Public License as published
163+# by the Free Software Foundation, either version 3 of the License, or
164+# (at your option) any later version.
165+#
166+# This program is distributed in the hope that it will be useful,
167+# but WITHOUT ANY WARRANTY; without even the implied warranty of
168+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
169+# GNU Affero General Public License for more details.
170+#
171+# You should have received a copy of the GNU Affero General Public License
172+# along with this program. If not, see <http://www.gnu.org/licenses/>.
173+#
174+##############################################################################
175+
176+from openerp.osv import fields, orm
177+
178+
179+class account_invoice(orm.Model):
180+ _inherit = "account.invoice"
181+
182+ def onchange_partner_id(
183+ self, cr, uid, ids, type, partner_id,
184+ date_invoice=False, payment_term=False,
185+ partner_bank_id=False, company_id=False
186+ ):
187+
188+ result = super(account_invoice, self).onchange_partner_id(
189+ cr, uid, ids, type, partner_id,
190+ date_invoice, payment_term, partner_bank_id, company_id)
191+
192+ if not result['value']['fiscal_position']:
193+ if partner_id:
194+ partner = self.pool.get('res.partner').browse(
195+ cr, uid, partner_id)
196+ result['value']['fiscal_position'] = (
197+ partner.country_id
198+ and partner.country_id.property_account_position
199+ and partner.country_id.property_account_position.id
200+ or False
201+ )
202+
203+ return result

Subscribers

People subscribed via source and target branches