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>

[ADD] EU countries + fiscal position check

975. By ferdinand <email address hidden>

[FIX] typo in create partner

Unmerged revisions

975. By ferdinand <email address hidden>

[FIX] typo in create partner

974. By ferdinand <email address hidden>

[ADD] EU countries + fiscal position check

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'country_eu'
=== added file 'country_eu/__init__.py'
--- country_eu/__init__.py 1970-01-01 00:00:00 +0000
+++ country_eu/__init__.py 2014-08-20 00:06:31 +0000
@@ -0,0 +1,8 @@
1##############################################
2#
3# ChriCar Beteiligungs- und Beratungs- GmbH
4
5##############################################
6import country
7import partner
8
09
=== added file 'country_eu/__openerp__.py'
--- country_eu/__openerp__.py 1970-01-01 00:00:00 +0000
+++ country_eu/__openerp__.py 2014-08-20 00:06:31 +0000
@@ -0,0 +1,13 @@
1{ "name" : "Country EU Members"
2, "version" : "1.0"
3, "author" : "ChriCar Beteiligungs- und Beratungs- GmbH"
4, "website" : "http://www.chricar.at/ChriCar"
5, "description" : """defines the EU countries"""
6, "category" : "Base"
7, "depends" : ["base"]
8, "init_xml" : []
9, "demo_xml" : []
10, "update_xml" : ["country_view.xml"]
11, "auto_install" : False
12, "installable" : True
13}
014
=== added file 'country_eu/country.py'
--- country_eu/country.py 1970-01-01 00:00:00 +0000
+++ country_eu/country.py 2014-08-20 00:06:31 +0000
@@ -0,0 +1,100 @@
1# -*- coding: utf-8 -*-
2
3#!/usr/bin/python
4# -*- coding: utf-8 -*-
5##############################################
6#
7# ChriCar Beteiligungs- und Beratungs- GmbH
8# Copyright (C) ChriCar Beteiligungs- und Beratungs- GmbH
9# all rights reserved
10
11#
12# WARNING: This program as such is intended to be used by professional
13# programmers who take the whole responsability of assessing all potential
14# consequences resulting from its eventual inadequacies and bugs.
15# End users who are looking for a ready-to-use solution with commercial
16# garantees and support are strongly adviced to contract a Free Software
17# Service Company.
18#
19# This program is Free Software; you can redistribute it and/or
20# modify it under the terms of the GNU Affero General Public License
21# as published by the Free Software Foundation; either version 3
22# of the License, or (at your option) any later version.
23#
24# This program is distributed in the hope that it will be useful,
25# but WITHOUT ANY WARRANTY; without even the implied warranty of
26# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27# GNU Affero General Public License for more details.
28#
29# You should have received a copy of the GNU Affero General Public License
30# along with this program; if not, see <http://www.gnu.org/licenses/> or
31# write to the Free Software Foundation, Inc.,
32# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33#
34###############################################
35from datetime import datetime
36import time
37from osv import fields,osv
38from tools.translate import _
39from openerp import SUPERUSER_ID
40
41class res_country(osv.osv):
42 _inherit = "res.country"
43
44 _columns = {
45 'eu_member' : fields.boolean ('EU-Member'),
46 'date_start' : fields.date ('Member Begin'),
47 'date_end' : fields.date ('Member End'),
48
49 }
50
51 def check_eu_member(self, cr, uid, country_id, date):
52 res = False
53 #d = date.strftime('%Y-%m-%d')
54 d = date
55 for country in self.browse(cr, uid, [country_id]):
56 if country.date_start and country.date_start <= d and (not country.date_end or (country.date_end and country.date_end >= d)):
57 res = True
58
59 return res
60
61 def init(self, cr):
62
63 eu_member = [
64 ('Austria','1995-01-01'),
65 ('Belgium','1958-01-01'),
66 ('Bulgaria','2007-01-01'),
67 ('Croatia','2013-07-01'),
68 ('Cyprus','2004-05-01'),
69 ('Czech Republic','2004-05-01'),
70 ('Denmark','1973-01-01'),
71 ('Estonia','2004-05-01'),
72 ('Finland','1995-01-01'),
73 ('France','1958-01-01'),
74 ('Germany','1958-01-01'),
75 ('Greece','1981-01-01'),
76 ('Hungary','2004-05-01'),
77 ('Ireland','1973-01-01'),
78 ('Italy','1958-01-01'),
79 ('Latvia','2004-05-01'),
80 ('Lithuania','2004-05-01'),
81 ('Luxembourg','1958-01-01'),
82 ('Malta','2004-05-01'),
83 ('Netherlands','1958-01-01'),
84 ('Poland','2004-05-01'),
85 ('Portugal','1986-01-01'),
86 ('Romania','2007-01-01'),
87 ('Slovakia','2004-05-01'),
88 ('Slovak Republic','2004-05-01'),
89 ('Slovenia','2004-05-01'),
90 ('Spain','1986-01-01'),
91 ('Sweden','1995-01-01'),
92 ('United Kingdom','1973-01-01')
93 ]
94 for c in eu_member:
95 country_id = self.search(cr, SUPERUSER_ID, [ ('name','=',c[0]) ] )
96 if country_id:
97 self.write(cr, SUPERUSER_ID, country_id, { 'eu_member': True, 'date_start' : c[1] })
98
99
100res_country()
0101
=== added file 'country_eu/country_view.xml'
--- country_eu/country_view.xml 1970-01-01 00:00:00 +0000
+++ country_eu/country_view.xml 2014-08-20 00:06:31 +0000
@@ -0,0 +1,35 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4
5 <!-- Country -->
6 <record id="view_country_eu_tree" model="ir.ui.view">
7 <field name="name">res.country.eu.tree</field>
8 <field name="model">res.country</field>
9 <field name="inherit_id" ref="base.view_country_tree"/>
10 <field name="arch" type="xml">
11 <field name="code" position="after">
12 <field name="eu_member"/>
13 <field name="date_start"/>
14 <field name="date_end"/>
15 </field>
16 </field>
17 </record>
18
19 <record id="view_country_eu_form" model="ir.ui.view">
20 <field name="name">res.country.eu.form</field>
21 <field name="model">res.country</field>
22 <field name="inherit_id" ref="base.view_country_form"/>
23 <field name="arch" type="xml">
24 <field name="code" position="after">
25 <field name="eu_member"/>
26 <field name="date_start"/>
27 <field name="date_end"/>
28 </field>
29 </field>
30 </record>
31
32
33
34 </data>
35</openerp>
036
=== added directory 'country_eu/i18n'
=== added file 'country_eu/partner.py'
--- country_eu/partner.py 1970-01-01 00:00:00 +0000
+++ country_eu/partner.py 2014-08-20 00:06:31 +0000
@@ -0,0 +1,88 @@
1#!/usr/bin/python
2# -*- coding: utf-8 -*-
3##############################################
4#
5# ChriCar Beteiligungs- und Beratungs- GmbH
6# Copyright (C) ChriCar Beteiligungs- und Beratungs- GmbH
7# all rights reserved
8
9#
10# WARNING: This program as such is intended to be used by professional
11# programmers who take the whole responsability of assessing all potential
12# consequences resulting from its eventual inadequacies and bugs.
13# End users who are looking for a ready-to-use solution with commercial
14# garantees and support are strongly adviced to contract a Free Software
15# Service Company.
16#
17# This program is Free Software; you can redistribute it and/or
18# modify it under the terms of the GNU Affero General Public License
19# as published by the Free Software Foundation; either version 3
20# of the License, or (at your option) any later version.
21#
22# This program is distributed in the hope that it will be useful,
23# but WITHOUT ANY WARRANTY; without even the implied warranty of
24# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25# GNU Affero General Public License for more details.
26#
27# You should have received a copy of the GNU Affero General Public License
28# along with this program; if not, see <http://www.gnu.org/licenses/> or
29# write to the Free Software Foundation, Inc.,
30# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31#
32###############################################
33from osv import fields,osv
34import time
35from tools.translate import _
36import logging
37
38class res_partner(osv.osv):
39 _inherit = "res.partner"
40
41 def check_fiscal_position(self, cr, uid, ids, context):
42 _logger = logging.getLogger(__name__)
43 country_obj = self.pool.get('res.country')
44 company_obj = self.pool.get('res.company')
45 partner_obj = self.pool.get('res.partner')
46 #address_obj = self.pool.get('res.partner.address')
47 fiscal_pos_obj = self.pool.get('account.fiscal.position')
48
49 fiscal_pos_ids = fiscal_pos_obj.search(cr, uid, [])
50 if not fiscal_pos_ids:
51 return True
52
53 current_user = self.pool.get('res.users').browse(cr, uid, [uid], context=context)[0]
54 company_id = current_user.company_id.id
55
56 home_country_id = ''
57 if company_id and current_user.company_id.partner_id.country_id:
58 home_country_id = current_user.company_id.partner_id.country_id.id
59
60 for partner in self.browse(cr, uid, ids, context):
61 if home_country_id and not partner.property_account_position:
62 d = time.strftime('%Y-%m-%d')
63 #for address in partner.address:
64 if partner.country_id and partner.country_id.id != home_country_id:
65 for country in country_obj.browse(cr, uid, [partner.country_id.id], context):
66 if country.date_start and country.date_start <= d and (not country.date_end or (country.date_end and country.date_end >= d)):
67 raise osv.except_osv(_('Error'), _('You must assign a fiscal postition (partner accounting tab) for EU-Partners in %s %s !') % \
68 (country.name, partner.name ))
69 else:
70 raise osv.except_osv(_('Error'), _('You must assign a fiscal postition (partner accounting tab) for Non-EU-Partners in %s %s !') % \
71 (country.name, partner.name))
72
73 return ''
74
75 def write(self, cr, uid, ids, vals, context=None):
76 res = super(res_partner, self).write(cr, uid, ids, vals, context=context)
77 self.check_fiscal_position(cr, uid, ids, context)
78 return res
79
80 def create(self, cr, uid, vals, context=None):
81 res = super(res_partner, self).create(cr, uid, vals, context=context)
82 self.check_fiscal_position(cr, uid, [res], context)
83 return res
84
85
86
87
88res_partner()

Subscribers

People subscribed via source and target branches