Merge lp:c2c-rd-addons/7.0 into lp:~taktik/c2c-rd-addons/7.0-fix-timed-job

Proposed by David Lefever @ Taktik
Status: Needs review
Proposed branch: lp:c2c-rd-addons/7.0
Merge into: lp:~taktik/c2c-rd-addons/7.0-fix-timed-job
Diff against target: 270 lines (+244/-0)
5 files modified
country_eu/__init__.py (+8/-0)
country_eu/__openerp__.py (+13/-0)
country_eu/country.py (+100/-0)
country_eu/country_view.xml (+35/-0)
country_eu/partner.py (+88/-0)
To merge this branch: bzr merge lp:c2c-rd-addons/7.0
Reviewer Review Type Date Requested Status
Taktik Pending
Review via email: mp+225548@code.launchpad.net

Description of the change

Fixed timed_job module by replacing base.group_extended by base.group_no_one in timed_job_view.xml.

To post a comment you must log in.
lp:c2c-rd-addons/7.0 updated
974. By ferdinand <email address hidden> on 2014-08-18

[ADD] EU countries + fiscal position check

975. By ferdinand <email address hidden> on 2014-08-20

[FIX] typo in create partner

Unmerged revisions

975. By ferdinand <email address hidden> on 2014-08-20

[FIX] typo in create partner

974. By ferdinand <email address hidden> on 2014-08-18

[ADD] EU countries + fiscal position check

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'country_eu'
2=== added file 'country_eu/__init__.py'
3--- country_eu/__init__.py 1970-01-01 00:00:00 +0000
4+++ country_eu/__init__.py 2014-08-20 00:06:31 +0000
5@@ -0,0 +1,8 @@
6+##############################################
7+#
8+# ChriCar Beteiligungs- und Beratungs- GmbH
9+
10+##############################################
11+import country
12+import partner
13+
14
15=== added file 'country_eu/__openerp__.py'
16--- country_eu/__openerp__.py 1970-01-01 00:00:00 +0000
17+++ country_eu/__openerp__.py 2014-08-20 00:06:31 +0000
18@@ -0,0 +1,13 @@
19+{ "name" : "Country EU Members"
20+, "version" : "1.0"
21+, "author" : "ChriCar Beteiligungs- und Beratungs- GmbH"
22+, "website" : "http://www.chricar.at/ChriCar"
23+, "description" : """defines the EU countries"""
24+, "category" : "Base"
25+, "depends" : ["base"]
26+, "init_xml" : []
27+, "demo_xml" : []
28+, "update_xml" : ["country_view.xml"]
29+, "auto_install" : False
30+, "installable" : True
31+}
32
33=== added file 'country_eu/country.py'
34--- country_eu/country.py 1970-01-01 00:00:00 +0000
35+++ country_eu/country.py 2014-08-20 00:06:31 +0000
36@@ -0,0 +1,100 @@
37+# -*- coding: utf-8 -*-
38+
39+#!/usr/bin/python
40+# -*- coding: utf-8 -*-
41+##############################################
42+#
43+# ChriCar Beteiligungs- und Beratungs- GmbH
44+# Copyright (C) ChriCar Beteiligungs- und Beratungs- GmbH
45+# all rights reserved
46+
47+#
48+# WARNING: This program as such is intended to be used by professional
49+# programmers who take the whole responsability of assessing all potential
50+# consequences resulting from its eventual inadequacies and bugs.
51+# End users who are looking for a ready-to-use solution with commercial
52+# garantees and support are strongly adviced to contract a Free Software
53+# Service Company.
54+#
55+# This program is Free Software; you can redistribute it and/or
56+# modify it under the terms of the GNU Affero General Public License
57+# as published by the Free Software Foundation; either version 3
58+# of the License, or (at your option) any later version.
59+#
60+# This program is distributed in the hope that it will be useful,
61+# but WITHOUT ANY WARRANTY; without even the implied warranty of
62+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63+# GNU Affero General Public License for more details.
64+#
65+# You should have received a copy of the GNU Affero General Public License
66+# along with this program; if not, see <http://www.gnu.org/licenses/> or
67+# write to the Free Software Foundation, Inc.,
68+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
69+#
70+###############################################
71+from datetime import datetime
72+import time
73+from osv import fields,osv
74+from tools.translate import _
75+from openerp import SUPERUSER_ID
76+
77+class res_country(osv.osv):
78+ _inherit = "res.country"
79+
80+ _columns = {
81+ 'eu_member' : fields.boolean ('EU-Member'),
82+ 'date_start' : fields.date ('Member Begin'),
83+ 'date_end' : fields.date ('Member End'),
84+
85+ }
86+
87+ def check_eu_member(self, cr, uid, country_id, date):
88+ res = False
89+ #d = date.strftime('%Y-%m-%d')
90+ d = date
91+ for country in self.browse(cr, uid, [country_id]):
92+ if country.date_start and country.date_start <= d and (not country.date_end or (country.date_end and country.date_end >= d)):
93+ res = True
94+
95+ return res
96+
97+ def init(self, cr):
98+
99+ eu_member = [
100+ ('Austria','1995-01-01'),
101+ ('Belgium','1958-01-01'),
102+ ('Bulgaria','2007-01-01'),
103+ ('Croatia','2013-07-01'),
104+ ('Cyprus','2004-05-01'),
105+ ('Czech Republic','2004-05-01'),
106+ ('Denmark','1973-01-01'),
107+ ('Estonia','2004-05-01'),
108+ ('Finland','1995-01-01'),
109+ ('France','1958-01-01'),
110+ ('Germany','1958-01-01'),
111+ ('Greece','1981-01-01'),
112+ ('Hungary','2004-05-01'),
113+ ('Ireland','1973-01-01'),
114+ ('Italy','1958-01-01'),
115+ ('Latvia','2004-05-01'),
116+ ('Lithuania','2004-05-01'),
117+ ('Luxembourg','1958-01-01'),
118+ ('Malta','2004-05-01'),
119+ ('Netherlands','1958-01-01'),
120+ ('Poland','2004-05-01'),
121+ ('Portugal','1986-01-01'),
122+ ('Romania','2007-01-01'),
123+ ('Slovakia','2004-05-01'),
124+ ('Slovak Republic','2004-05-01'),
125+ ('Slovenia','2004-05-01'),
126+ ('Spain','1986-01-01'),
127+ ('Sweden','1995-01-01'),
128+ ('United Kingdom','1973-01-01')
129+ ]
130+ for c in eu_member:
131+ country_id = self.search(cr, SUPERUSER_ID, [ ('name','=',c[0]) ] )
132+ if country_id:
133+ self.write(cr, SUPERUSER_ID, country_id, { 'eu_member': True, 'date_start' : c[1] })
134+
135+
136+res_country()
137
138=== added file 'country_eu/country_view.xml'
139--- country_eu/country_view.xml 1970-01-01 00:00:00 +0000
140+++ country_eu/country_view.xml 2014-08-20 00:06:31 +0000
141@@ -0,0 +1,35 @@
142+<?xml version="1.0" encoding="UTF-8"?>
143+<openerp>
144+ <data>
145+
146+ <!-- Country -->
147+ <record id="view_country_eu_tree" model="ir.ui.view">
148+ <field name="name">res.country.eu.tree</field>
149+ <field name="model">res.country</field>
150+ <field name="inherit_id" ref="base.view_country_tree"/>
151+ <field name="arch" type="xml">
152+ <field name="code" position="after">
153+ <field name="eu_member"/>
154+ <field name="date_start"/>
155+ <field name="date_end"/>
156+ </field>
157+ </field>
158+ </record>
159+
160+ <record id="view_country_eu_form" model="ir.ui.view">
161+ <field name="name">res.country.eu.form</field>
162+ <field name="model">res.country</field>
163+ <field name="inherit_id" ref="base.view_country_form"/>
164+ <field name="arch" type="xml">
165+ <field name="code" position="after">
166+ <field name="eu_member"/>
167+ <field name="date_start"/>
168+ <field name="date_end"/>
169+ </field>
170+ </field>
171+ </record>
172+
173+
174+
175+ </data>
176+</openerp>
177
178=== added directory 'country_eu/i18n'
179=== added file 'country_eu/partner.py'
180--- country_eu/partner.py 1970-01-01 00:00:00 +0000
181+++ country_eu/partner.py 2014-08-20 00:06:31 +0000
182@@ -0,0 +1,88 @@
183+#!/usr/bin/python
184+# -*- coding: utf-8 -*-
185+##############################################
186+#
187+# ChriCar Beteiligungs- und Beratungs- GmbH
188+# Copyright (C) ChriCar Beteiligungs- und Beratungs- GmbH
189+# all rights reserved
190+
191+#
192+# WARNING: This program as such is intended to be used by professional
193+# programmers who take the whole responsability of assessing all potential
194+# consequences resulting from its eventual inadequacies and bugs.
195+# End users who are looking for a ready-to-use solution with commercial
196+# garantees and support are strongly adviced to contract a Free Software
197+# Service Company.
198+#
199+# This program is Free Software; you can redistribute it and/or
200+# modify it under the terms of the GNU Affero General Public License
201+# as published by the Free Software Foundation; either version 3
202+# of the License, or (at your option) any later version.
203+#
204+# This program is distributed in the hope that it will be useful,
205+# but WITHOUT ANY WARRANTY; without even the implied warranty of
206+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
207+# GNU Affero General Public License for more details.
208+#
209+# You should have received a copy of the GNU Affero General Public License
210+# along with this program; if not, see <http://www.gnu.org/licenses/> or
211+# write to the Free Software Foundation, Inc.,
212+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
213+#
214+###############################################
215+from osv import fields,osv
216+import time
217+from tools.translate import _
218+import logging
219+
220+class res_partner(osv.osv):
221+ _inherit = "res.partner"
222+
223+ def check_fiscal_position(self, cr, uid, ids, context):
224+ _logger = logging.getLogger(__name__)
225+ country_obj = self.pool.get('res.country')
226+ company_obj = self.pool.get('res.company')
227+ partner_obj = self.pool.get('res.partner')
228+ #address_obj = self.pool.get('res.partner.address')
229+ fiscal_pos_obj = self.pool.get('account.fiscal.position')
230+
231+ fiscal_pos_ids = fiscal_pos_obj.search(cr, uid, [])
232+ if not fiscal_pos_ids:
233+ return True
234+
235+ current_user = self.pool.get('res.users').browse(cr, uid, [uid], context=context)[0]
236+ company_id = current_user.company_id.id
237+
238+ home_country_id = ''
239+ if company_id and current_user.company_id.partner_id.country_id:
240+ home_country_id = current_user.company_id.partner_id.country_id.id
241+
242+ for partner in self.browse(cr, uid, ids, context):
243+ if home_country_id and not partner.property_account_position:
244+ d = time.strftime('%Y-%m-%d')
245+ #for address in partner.address:
246+ if partner.country_id and partner.country_id.id != home_country_id:
247+ for country in country_obj.browse(cr, uid, [partner.country_id.id], context):
248+ if country.date_start and country.date_start <= d and (not country.date_end or (country.date_end and country.date_end >= d)):
249+ raise osv.except_osv(_('Error'), _('You must assign a fiscal postition (partner accounting tab) for EU-Partners in %s %s !') % \
250+ (country.name, partner.name ))
251+ else:
252+ raise osv.except_osv(_('Error'), _('You must assign a fiscal postition (partner accounting tab) for Non-EU-Partners in %s %s !') % \
253+ (country.name, partner.name))
254+
255+ return ''
256+
257+ def write(self, cr, uid, ids, vals, context=None):
258+ res = super(res_partner, self).write(cr, uid, ids, vals, context=context)
259+ self.check_fiscal_position(cr, uid, ids, context)
260+ return res
261+
262+ def create(self, cr, uid, vals, context=None):
263+ res = super(res_partner, self).create(cr, uid, vals, context=context)
264+ self.check_fiscal_position(cr, uid, [res], context)
265+ return res
266+
267+
268+
269+
270+res_partner()

Subscribers

People subscribed via source and target branches