Merge lp:~openerp-dev/openobject-addons/trunk-base_contact-stw into lp:openobject-addons
- trunk-base_contact-stw
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 6009 |
Proposed branch: | lp:~openerp-dev/openobject-addons/trunk-base_contact-stw |
Merge into: | lp:openobject-addons |
Diff against target: |
943 lines (+193/-441) (has conflicts) 12 files modified
base_contact/__init__.py (+0/-1) base_contact/__openerp__.py (+0/-1) base_contact/base_contact.py (+145/-183) base_contact/base_contact_demo.xml (+2/-0) base_contact/base_contact_installer.py (+0/-67) base_contact/base_contact_installer_view.xml (+0/-59) base_contact/base_contact_view.xml (+35/-99) base_contact/process/base_contact_process.xml (+1/-26) base_contact/security/ir.model.access.csv (+7/-0) base_contact/test/base_contact00.yml (+0/-2) event/__openerp__.py (+1/-1) event/event.py (+2/-2) Text conflict in base_contact/security/ir.model.access.csv |
To merge this branch: | bzr merge lp:~openerp-dev/openobject-addons/trunk-base_contact-stw |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Aline (OpenERP) | Needs Fixing | ||
Raphael Collet (OpenERP) (community) | Needs Fixing | ||
Christophe Simonis (OpenERP) | Pending | ||
Review via email: mp+83401@code.launchpad.net |
Commit message
Description of the change
this branch helps to fix some bugs with the base_contact module.
Regards,
- 5789. By Stephane Wirtel (OpenERP)
-
[FIX] event: Remove the dependency to base_contact
- 5790. By Stephane Wirtel (OpenERP)
-
[FIX] base_contact: Add some missing features
Raphael Collet (OpenERP) (rco-openerp) wrote : | # |
Aline (OpenERP) (apr-tinyerp) wrote : | # |
i tested and i confirm that it breaks some addons, i can't confirm SO
it is still in testing, i put other comments in related pad
- 5791. By Stephane Wirtel (OpenERP)
-
[FIX] base_contact: Review the algo
- 5792. By Stephane Wirtel (OpenERP)
-
[REVERT]
- 5793. By Stephane Wirtel (OpenERP)
-
[FIX] base_contact: Modify the migration script
- 5794. By Stephane Wirtel (OpenERP)
-
[REF] base_contact: Remove the old installer
- 5795. By Stephane Wirtel (OpenERP)
-
[IMP] base_contact: Add the migration script for the addresses
[FIX] base_contact: Add a name_get for the location and the address - 5796. By Stephane Wirtel (OpenERP)
-
[FIX] base_contact: Assign a partner only if there is a location on the address for the creation
[IMP] base_contact: Add a view for the location - 5797. By Stephane Wirtel (OpenERP)
-
[MERGE] Upstream
- 5798. By Stephane Wirtel (OpenERP)
-
[FIX] base_contact: Increment the last value of the sequence for the locationwq
- 5799. By Stephane Wirtel (OpenERP)
-
[IMP] base_contact: improve the form view if the use_existing_
address field has been selected
Preview Diff
1 | === modified file 'base_contact/__init__.py' | |||
2 | --- base_contact/__init__.py 2011-01-14 00:11:01 +0000 | |||
3 | +++ base_contact/__init__.py 2011-12-14 09:21:40 +0000 | |||
4 | @@ -20,7 +20,6 @@ | |||
5 | 20 | ############################################################################## | 20 | ############################################################################## |
6 | 21 | 21 | ||
7 | 22 | import base_contact | 22 | import base_contact |
8 | 23 | import base_contact_installer | ||
9 | 24 | 23 | ||
10 | 25 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 24 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
11 | 26 | 25 | ||
12 | 27 | 26 | ||
13 | === modified file 'base_contact/__openerp__.py' | |||
14 | --- base_contact/__openerp__.py 2011-12-13 14:19:49 +0000 | |||
15 | +++ base_contact/__openerp__.py 2011-12-14 09:21:40 +0000 | |||
16 | @@ -47,7 +47,6 @@ | |||
17 | 47 | 'update_xml': [ | 47 | 'update_xml': [ |
18 | 48 | 'security/ir.model.access.csv', | 48 | 'security/ir.model.access.csv', |
19 | 49 | 'base_contact_view.xml', | 49 | 'base_contact_view.xml', |
20 | 50 | 'base_contact_installer_view.xml', | ||
21 | 51 | 'process/base_contact_process.xml' | 50 | 'process/base_contact_process.xml' |
22 | 52 | ], | 51 | ], |
23 | 53 | 'demo_xml': ['base_contact_demo.xml'], | 52 | 'demo_xml': ['base_contact_demo.xml'], |
24 | 54 | 53 | ||
25 | === modified file 'base_contact/base_contact.py' | |||
26 | --- base_contact/base_contact.py 2011-10-27 21:11:24 +0000 | |||
27 | +++ base_contact/base_contact.py 2011-12-14 09:21:40 +0000 | |||
28 | @@ -20,6 +20,7 @@ | |||
29 | 20 | ############################################################################## | 20 | ############################################################################## |
30 | 21 | 21 | ||
31 | 22 | from osv import fields, osv | 22 | from osv import fields, osv |
32 | 23 | import addons | ||
33 | 23 | 24 | ||
34 | 24 | class res_partner_contact(osv.osv): | 25 | class res_partner_contact(osv.osv): |
35 | 25 | """ Partner Contact """ | 26 | """ Partner Contact """ |
36 | @@ -27,27 +28,6 @@ | |||
37 | 27 | _name = "res.partner.contact" | 28 | _name = "res.partner.contact" |
38 | 28 | _description = "Contact" | 29 | _description = "Contact" |
39 | 29 | 30 | ||
40 | 30 | def _main_job(self, cr, uid, ids, fields, arg, context=None): | ||
41 | 31 | """ | ||
42 | 32 | @param self: The object pointer | ||
43 | 33 | @param cr: the current row, from the database cursor, | ||
44 | 34 | @param uid: the current user’s ID for security checks, | ||
45 | 35 | @param ids: List of partner contact’s IDs | ||
46 | 36 | @fields: Get Fields | ||
47 | 37 | @param context: A standard dictionary for contextual values | ||
48 | 38 | @param arg: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. """ | ||
49 | 39 | res = dict.fromkeys(ids, False) | ||
50 | 40 | |||
51 | 41 | res_partner_job_obj = self.pool.get('res.partner.job') | ||
52 | 42 | all_job_ids = res_partner_job_obj.search(cr, uid, []) | ||
53 | 43 | all_job_names = dict(zip(all_job_ids, res_partner_job_obj.name_get(cr, uid, all_job_ids, context=context))) | ||
54 | 44 | |||
55 | 45 | for contact in self.browse(cr, uid, ids, context=context): | ||
56 | 46 | if contact.job_ids: | ||
57 | 47 | res[contact.id] = all_job_names.get(contact.job_ids[0].id, False) | ||
58 | 48 | |||
59 | 49 | return res | ||
60 | 50 | |||
61 | 51 | _columns = { | 31 | _columns = { |
62 | 52 | 'name': fields.char('Last Name', size=64, required=True), | 32 | 'name': fields.char('Last Name', size=64, required=True), |
63 | 53 | 'first_name': fields.char('First Name', size=64), | 33 | 'first_name': fields.char('First Name', size=64), |
64 | @@ -55,53 +35,32 @@ | |||
65 | 55 | 'title': fields.many2one('res.partner.title','Title'), | 35 | 'title': fields.many2one('res.partner.title','Title'), |
66 | 56 | 'website': fields.char('Website', size=120), | 36 | 'website': fields.char('Website', size=120), |
67 | 57 | 'lang_id': fields.many2one('res.lang', 'Language'), | 37 | 'lang_id': fields.many2one('res.lang', 'Language'), |
69 | 58 | 'job_ids': fields.one2many('res.partner.job', 'contact_id', 'Functions and Addresses'), | 38 | 'job_ids': fields.one2many('res.partner.address', 'contact_id', 'Functions and Addresses'), |
70 | 59 | 'country_id': fields.many2one('res.country','Nationality'), | 39 | 'country_id': fields.many2one('res.country','Nationality'), |
71 | 60 | 'birthdate': fields.date('Birth Date'), | 40 | 'birthdate': fields.date('Birth Date'), |
72 | 61 | 'active': fields.boolean('Active', help="If the active field is set to False,\ | 41 | 'active': fields.boolean('Active', help="If the active field is set to False,\ |
73 | 62 | it will allow you to hide the partner contact without removing it."), | 42 | it will allow you to hide the partner contact without removing it."), |
75 | 63 | 'partner_id': fields.related('job_ids', 'address_id', 'partner_id', type='many2one',\ | 43 | 'partner_id': fields.related('job_ids', 'location_id', 'partner_id', type='many2one',\ |
76 | 64 | relation='res.partner', string='Main Employer'), | 44 | relation='res.partner', string='Main Employer'), |
77 | 65 | 'function': fields.related('job_ids', 'function', type='char', \ | 45 | 'function': fields.related('job_ids', 'function', type='char', \ |
78 | 66 | string='Main Function'), | 46 | string='Main Function'), |
79 | 67 | 'job_id': fields.function(_main_job, type='many2one',\ | ||
80 | 68 | relation='res.partner.job', string='Main Job'), | ||
81 | 69 | 'email': fields.char('E-Mail', size=240), | 47 | 'email': fields.char('E-Mail', size=240), |
82 | 70 | 'comment': fields.text('Notes', translate=True), | 48 | 'comment': fields.text('Notes', translate=True), |
84 | 71 | 'photo': fields.binary('Image'), | 49 | 'photo': fields.binary('Photo'), |
85 | 72 | 50 | ||
86 | 73 | } | 51 | } |
87 | 52 | |||
88 | 53 | def _get_photo(self, cr, uid, context=None): | ||
89 | 54 | photo_path = addons.get_module_resource('base_contact', 'images', 'photo.png') | ||
90 | 55 | return open(photo_path, 'rb').read().encode('base64') | ||
91 | 56 | |||
92 | 74 | _defaults = { | 57 | _defaults = { |
93 | 58 | 'photo' : _get_photo, | ||
94 | 75 | 'active' : lambda *a: True, | 59 | 'active' : lambda *a: True, |
95 | 76 | } | 60 | } |
96 | 77 | 61 | ||
97 | 78 | _order = "name,first_name" | 62 | _order = "name,first_name" |
98 | 79 | 63 | ||
99 | 80 | def name_get(self, cr, user, ids, context=None): | ||
100 | 81 | |||
101 | 82 | """ will return name and first_name....... | ||
102 | 83 | @param self: The object pointer | ||
103 | 84 | @param cr: the current row, from the database cursor, | ||
104 | 85 | @param user: the current user’s ID for security checks, | ||
105 | 86 | @param ids: List of create menu’s IDs | ||
106 | 87 | @return: name and first_name | ||
107 | 88 | @param context: A standard dictionary for contextual values | ||
108 | 89 | """ | ||
109 | 90 | |||
110 | 91 | if not len(ids): | ||
111 | 92 | return [] | ||
112 | 93 | res = [] | ||
113 | 94 | for contact in self.browse(cr, user, ids, context=context): | ||
114 | 95 | _contact = "" | ||
115 | 96 | if contact.title: | ||
116 | 97 | _contact += "%s "%(contact.title.name) | ||
117 | 98 | _contact += contact.name or "" | ||
118 | 99 | if contact.name and contact.first_name: | ||
119 | 100 | _contact += " " | ||
120 | 101 | _contact += contact.first_name or "" | ||
121 | 102 | res.append((contact.id, _contact)) | ||
122 | 103 | return res | ||
123 | 104 | |||
124 | 105 | def name_search(self, cr, uid, name='', args=None, operator='ilike', context=None, limit=None): | 64 | def name_search(self, cr, uid, name='', args=None, operator='ilike', context=None, limit=None): |
125 | 106 | if not args: | 65 | if not args: |
126 | 107 | args = [] | 66 | args = [] |
127 | @@ -112,151 +71,154 @@ | |||
128 | 112 | else: | 71 | else: |
129 | 113 | ids = self.search(cr, uid, args, limit=limit, context=context) | 72 | ids = self.search(cr, uid, args, limit=limit, context=context) |
130 | 114 | return self.name_get(cr, uid, ids, context=context) | 73 | return self.name_get(cr, uid, ids, context=context) |
131 | 74 | |||
132 | 75 | def name_get(self, cr, uid, ids, context=None): | ||
133 | 76 | return [ | ||
134 | 77 | (obj.id, " ".join(filter(None, [obj.first_name, obj.name])),) | ||
135 | 78 | for obj in self.browse(cr, uid, ids, context=context) | ||
136 | 79 | ] | ||
137 | 80 | |||
138 | 115 | 81 | ||
139 | 116 | res_partner_contact() | 82 | res_partner_contact() |
140 | 117 | 83 | ||
141 | 84 | class res_partner(osv.osv): | ||
142 | 85 | _inherit = 'res.partner' | ||
143 | 86 | |||
144 | 87 | _columns = { | ||
145 | 88 | 'address': fields.one2many('res.partner.location', 'partner_id', 'Address') | ||
146 | 89 | } | ||
147 | 90 | |||
148 | 91 | res_partner() | ||
149 | 92 | |||
150 | 93 | class res_partner_location(osv.osv): | ||
151 | 94 | _name = 'res.partner.location' | ||
152 | 95 | _inherit = 'res.partner.address' | ||
153 | 96 | _columns = { | ||
154 | 97 | 'job_ids': fields.one2many('res.partner.address', 'location2_id', 'Contacts'), | ||
155 | 98 | } | ||
156 | 99 | |||
157 | 100 | def _auto_init(self, cr, context=None): | ||
158 | 101 | def table_exists(view_name): | ||
159 | 102 | cr.execute('SELECT count(relname) FROM pg_class WHERE relname = %s', (view_name,)) | ||
160 | 103 | value = cr.fetchone()[0] | ||
161 | 104 | return bool(value == 1) | ||
162 | 105 | |||
163 | 106 | exists = table_exists(self._table) | ||
164 | 107 | super(res_partner_location, self)._auto_init(cr, context) | ||
165 | 108 | |||
166 | 109 | if not exists: | ||
167 | 110 | sequence_name = self.pool.get('res.partner.address')._sequence | ||
168 | 111 | cr.execute("SELECT last_value FROM " + sequence_name) | ||
169 | 112 | last_sequence = cr.fetchone()[0] | ||
170 | 113 | |||
171 | 114 | cr.execute("INSERT INTO res_partner_location SELECT * FROM res_partner_address") | ||
172 | 115 | cr.execute("ALTER SEQUENCE " + self._sequence + " RESTART WITH " + str(last_sequence)) | ||
173 | 116 | |||
174 | 117 | |||
175 | 118 | res_partner_location() | ||
176 | 118 | 119 | ||
177 | 119 | class res_partner_address(osv.osv): | 120 | class res_partner_address(osv.osv): |
178 | 120 | |||
179 | 121 | #overriding of the name_get defined in base in order to remove the old contact name | ||
180 | 122 | def name_get(self, cr, user, ids, context=None): | ||
181 | 123 | """ | ||
182 | 124 | @param self: The object pointer | ||
183 | 125 | @param cr: the current row, from the database cursor, | ||
184 | 126 | @param user: the current user, | ||
185 | 127 | @param ids: List of partner address’s IDs | ||
186 | 128 | @param context: A standard dictionary for contextual values | ||
187 | 129 | """ | ||
188 | 130 | |||
189 | 131 | if not len(ids): | ||
190 | 132 | return [] | ||
191 | 133 | res = [] | ||
192 | 134 | if context is None: | ||
193 | 135 | context = {} | ||
194 | 136 | for r in self.read(cr, user, ids, ['zip', 'city', 'partner_id', 'street']): | ||
195 | 137 | if context.get('contact_display', 'contact')=='partner' and r['partner_id']: | ||
196 | 138 | res.append((r['id'], r['partner_id'][1])) | ||
197 | 139 | else: | ||
198 | 140 | addr = str('') | ||
199 | 141 | addr += "%s %s %s" % (r.get('street', '') or '', r.get('zip', '') \ | ||
200 | 142 | or '', r.get('city', '') or '') | ||
201 | 143 | res.append((r['id'], addr.strip() or '/')) | ||
202 | 144 | return res | ||
203 | 145 | |||
204 | 146 | def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): | ||
205 | 147 | if not args: | ||
206 | 148 | args=[] | ||
207 | 149 | ids = self.search(cr, user, [('name',operator,name)] + args, limit=limit, context=context) | ||
208 | 150 | jobs = self.pool.get('res.partner.job') | ||
209 | 151 | if name: | ||
210 | 152 | job_ids = jobs.search(cr, user, [('contact_id', operator, name)] + args, limit=limit, context=context) | ||
211 | 153 | for job in jobs.browse(cr, user, job_ids): | ||
212 | 154 | ids += [job.address_id.id] | ||
213 | 155 | return self.name_get(cr, user, ids, context) | ||
214 | 156 | |||
215 | 157 | _name = 'res.partner.address' | 121 | _name = 'res.partner.address' |
265 | 158 | _inherit = 'res.partner.address' | 122 | _inherits = { 'res.partner.location' : 'location_id' } |
266 | 159 | _description ='Partner Address' | 123 | |
267 | 160 | 124 | def _get_use_existing_address(self, cr, uid, ids, fieldnames, args, context=None): | |
268 | 161 | _columns = { | 125 | result = dict.fromkeys(ids, 0) |
269 | 162 | 'job_id': fields.related('job_ids','contact_id','job_id',type='many2one',\ | 126 | for obj in self.browse(cr, uid, ids, context=context): |
270 | 163 | relation='res.partner.job', string='Main Job'), | 127 | result[obj.id] = 0 |
271 | 164 | 'job_ids': fields.one2many('res.partner.job', 'address_id', 'Contacts'), | 128 | return result |
272 | 165 | } | 129 | |
273 | 166 | res_partner_address() | 130 | def _set_use_existing_address(self, cr, uid, ids, field, value, arg, context=None): |
274 | 167 | 131 | if isinstance(ids, (int, long)): | |
275 | 168 | class res_partner_job(osv.osv): | 132 | ids = [ids] |
276 | 169 | def name_get(self, cr, uid, ids, context=None): | 133 | |
277 | 170 | """ | 134 | return True |
278 | 171 | @param self: The object pointer | 135 | |
279 | 172 | @param cr: the current row, from the database cursor, | 136 | _columns = { |
280 | 173 | @param user: the current user, | 137 | 'location_id' : fields.many2one('res.partner.location', 'Location'), |
281 | 174 | @param ids: List of partner address’s IDs | 138 | 'location2_id' : fields.many2one('res.partner.location', 'Location'), |
282 | 175 | @param context: A standard dictionary for contextual values | 139 | 'contact_id' : fields.many2one('res.partner.contact', 'Contact', required=True), |
283 | 176 | """ | 140 | |
284 | 177 | if context is None: | 141 | 'partner_id' : fields.many2one('res.partner', 'Partner'), |
285 | 178 | context = {} | 142 | 'contact_firstname' : fields.related('contact_id', 'first_name', type='char', size=64, string='Firstname'), |
286 | 179 | 143 | 'contact_name' : fields.related('contact_id', 'name', type='char', size='64', string="Lastname"), | |
238 | 180 | if not ids: | ||
239 | 181 | return [] | ||
240 | 182 | res = [] | ||
241 | 183 | |||
242 | 184 | jobs = self.browse(cr, uid, ids, context=context) | ||
243 | 185 | |||
244 | 186 | contact_ids = [rec.contact_id.id for rec in jobs] | ||
245 | 187 | contact_names = dict(self.pool.get('res.partner.contact').name_get(cr, uid, contact_ids, context=context)) | ||
246 | 188 | |||
247 | 189 | for r in jobs: | ||
248 | 190 | function_name = r.function | ||
249 | 191 | funct = function_name and (", " + function_name) or "" | ||
250 | 192 | res.append((r.id, contact_names.get(r.contact_id.id, '') + funct)) | ||
251 | 193 | |||
252 | 194 | return res | ||
253 | 195 | |||
254 | 196 | _name = 'res.partner.job' | ||
255 | 197 | _description ='Contact Partner Function' | ||
256 | 198 | _order = 'sequence_contact' | ||
257 | 199 | |||
258 | 200 | _columns = { | ||
259 | 201 | 'name': fields.related('address_id', 'partner_id', type='many2one',\ | ||
260 | 202 | relation='res.partner', string='Partner', help="You may\ | ||
261 | 203 | enter Address first,Partner will be linked automatically if any."), | ||
262 | 204 | 'address_id': fields.many2one('res.partner.address', 'Address', \ | ||
263 | 205 | help='Address which is linked to the Partner'), # TO Correct: domain=[('partner_id', '=', name)] | ||
264 | 206 | 'contact_id': fields.many2one('res.partner.contact','Contact', required=True, ondelete='cascade'), | ||
287 | 207 | 'function': fields.char('Partner Function', size=64, help="Function of this contact with this partner"), | 144 | 'function': fields.char('Partner Function', size=64, help="Function of this contact with this partner"), |
288 | 208 | 'sequence_contact': fields.integer('Contact Seq.',help='Order of\ | ||
289 | 209 | importance of this address in the list of addresses of the linked contact'), | ||
290 | 210 | 'sequence_partner': fields.integer('Partner Seq.',help='Order of importance\ | ||
291 | 211 | of this job title in the list of job title of the linked partner'), | ||
292 | 212 | 'email': fields.char('E-Mail', size=240, help="Job E-Mail"), | ||
293 | 213 | 'phone': fields.char('Phone', size=64, help="Job Phone no."), | ||
294 | 214 | 'fax': fields.char('Fax', size=64, help="Job FAX no."), | ||
295 | 215 | 'extension': fields.char('Extension', size=64, help='Internal/External extension phone number'), | ||
296 | 216 | 'other': fields.char('Other', size=64, help='Additional phone field'), | ||
297 | 217 | 'date_start': fields.date('Date Start',help="Start date of job(Joining Date)"), | 145 | 'date_start': fields.date('Date Start',help="Start date of job(Joining Date)"), |
298 | 218 | 'date_stop': fields.date('Date Stop', help="Last date of job"), | 146 | 'date_stop': fields.date('Date Stop', help="Last date of job"), |
299 | 219 | 'state': fields.selection([('past', 'Past'),('current', 'Current')], \ | 147 | 'state': fields.selection([('past', 'Past'),('current', 'Current')], \ |
301 | 220 | 'State', required=True, help="Status of Address"), | 148 | 'State', required=True, help="Status of Address"), |
302 | 149 | 'use_existing_address' : fields.function(_get_use_existing_address, type="boolean", | ||
303 | 150 | fnct_inv=_set_use_existing_address, | ||
304 | 151 | string='Use Existing Address'), | ||
305 | 221 | } | 152 | } |
306 | 222 | 153 | ||
307 | 154 | def name_get(self, cr, uid, ids, context=None): | ||
308 | 155 | result = [] | ||
309 | 156 | |||
310 | 157 | append_call = result.append | ||
311 | 158 | for obj in self.browse(cr, uid, ids, context=context): | ||
312 | 159 | append_call((obj.id, "%s, %s" % (obj.contact_id.name_get()[0][1], obj.location_id.name_get()[0][1],))) | ||
313 | 160 | return result | ||
314 | 161 | |||
315 | 162 | |||
316 | 163 | _description ='Contact Partner Function' | ||
317 | 164 | |||
318 | 223 | _defaults = { | 165 | _defaults = { |
321 | 224 | 'sequence_contact' : lambda *a: 0, | 166 | 'state': 'current', |
320 | 225 | 'state': lambda *a: 'current', | ||
322 | 226 | } | 167 | } |
356 | 227 | 168 | ||
357 | 228 | def onchange_name(self, cr, uid, ids, address_id='', name='', context=None): | 169 | def create(self, cr, uid, values, context=None): |
358 | 229 | return {'value': {'address_id': address_id}, 'domain':{'partner_id':'name'}} | 170 | record_id = super(res_partner_address, self).create(cr, uid, values, context=context) |
359 | 230 | 171 | record = self.browse(cr, uid, record_id, context=context) | |
360 | 231 | def onchange_partner(self, cr, uid, _, partner_id, context=None): | 172 | if not record.partner_id: |
361 | 232 | """ | 173 | record.write({'partner_id' : record.location2_id.partner_id.id}, context=context) |
362 | 233 | @param self: The object pointer | 174 | return record_id |
363 | 234 | @param cr: the current row, from the database cursor, | 175 | |
364 | 235 | @param uid: the current user, | 176 | def _auto_init(self, cr, context=None): |
365 | 236 | @param _: List of IDs, | 177 | def column_exists(column): |
366 | 237 | @partner_id : ID of the Partner selected, | 178 | cr.execute("select count(attname) from pg_attribute where attrelid = \ |
367 | 238 | @param context: A standard dictionary for contextual values | 179 | (select oid from pg_class where relname = %s) \ |
368 | 239 | """ | 180 | and attname = %s", (self._table, column,)) |
369 | 240 | return {'value': {'address_id': False}} | 181 | value = cr.fetchone()[0] |
370 | 241 | 182 | return bool(value == 1) | |
371 | 242 | def onchange_address(self, cr, uid, _, address_id, context=None): | 183 | |
372 | 243 | """ | 184 | exists = column_exists('location_id') |
373 | 244 | @@param self: The object pointer | 185 | super(res_partner_address, self)._auto_init(cr, context) |
374 | 245 | @param cr: the current row, from the database cursor, | 186 | |
375 | 246 | @param uid: the current user, | 187 | if not exists: |
376 | 247 | @param _: List of IDs, | 188 | cr.execute("UPDATE res_partner_address SET location_id = id, location2_id = id") |
377 | 248 | @address_id : ID of the Address selected, | 189 | |
378 | 249 | @param context: A standard dictionary for contextual values | 190 | contact_proxy = self.pool.get('res.partner.contact') |
379 | 250 | """ | 191 | uid = 1 |
380 | 251 | partner_id = False | 192 | |
381 | 252 | if address_id: | 193 | cr.execute("SELECT id, name, mobile, country_id, partner_id, phone, email, street, street2, city, company_id, state_id, zip, location_id \ |
382 | 253 | address = self.pool.get('res.partner.address')\ | 194 | FROM res_partner_address \ |
383 | 254 | .browse(cr, uid, address_id, context=context) | 195 | WHERE contact_id IS NULL AND name IS NOT NULL AND location_id IS NOT NULL") |
384 | 255 | partner_id = address.partner_id.id | 196 | for item in cr.fetchall(): |
385 | 256 | return {'value': {'name': partner_id}} | 197 | |
386 | 257 | 198 | values = { | |
387 | 258 | res_partner_job() | 199 | 'name' : item[1], |
388 | 259 | 200 | 'mobile' : item[2], | |
389 | 201 | 'country_id' : item[3], | ||
390 | 202 | 'phone' : item[5], | ||
391 | 203 | 'email' : item[6], | ||
392 | 204 | 'company_id' : item[10], | ||
393 | 205 | } | ||
394 | 206 | |||
395 | 207 | contact_id = contact_proxy.create(cr, uid, values, context=context) | ||
396 | 208 | values = { | ||
397 | 209 | 'street' : item[7], | ||
398 | 210 | 'street2' : item[8], | ||
399 | 211 | 'city' : item[9], | ||
400 | 212 | 'country_id' : item[3], | ||
401 | 213 | 'company_id' : item[10], | ||
402 | 214 | 'state_id' : item[11], | ||
403 | 215 | 'zip' : item[12], | ||
404 | 216 | } | ||
405 | 217 | location_id = self.pool.get('res.partner.location').create(cr, uid, values, context=context) | ||
406 | 218 | |||
407 | 219 | cr.execute("UPDATE res_partner_address SET location_id = %s, contact_id = %s, partner_id = %s WHERE id = %s", | ||
408 | 220 | (location_id, contact_id, item[4], item[0],)) | ||
409 | 221 | |||
410 | 222 | res_partner_address() | ||
411 | 260 | 223 | ||
412 | 261 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 224 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
413 | 262 | |||
414 | 263 | 225 | ||
415 | === modified file 'base_contact/base_contact_demo.xml' | |||
416 | --- base_contact/base_contact_demo.xml 2011-11-28 16:04:32 +0000 | |||
417 | +++ base_contact/base_contact_demo.xml 2011-12-14 09:21:40 +0000 | |||
418 | @@ -180,6 +180,7 @@ | |||
419 | 180 | </record> | 180 | </record> |
420 | 181 | 181 | ||
421 | 182 | <!-- Create the jobs --> | 182 | <!-- Create the jobs --> |
422 | 183 | <!-- | ||
423 | 183 | <record id="res_partner_job_0" model="res.partner.job"> | 184 | <record id="res_partner_job_0" model="res.partner.job"> |
424 | 184 | <field name="address_id" ref="base.res_partner_address_1"/> | 185 | <field name="address_id" ref="base.res_partner_address_1"/> |
425 | 185 | <field name="function">Salesman</field> | 186 | <field name="function">Salesman</field> |
426 | @@ -334,5 +335,6 @@ | |||
427 | 334 | <field name="function">CEO</field> | 335 | <field name="function">CEO</field> |
428 | 335 | <field name="sequence_contact">1</field> | 336 | <field name="sequence_contact">1</field> |
429 | 336 | </record> | 337 | </record> |
430 | 338 | --> | ||
431 | 337 | </data> | 339 | </data> |
432 | 338 | </openerp> | 340 | </openerp> |
433 | 339 | 341 | ||
434 | === removed file 'base_contact/base_contact_installer.py' | |||
435 | --- base_contact/base_contact_installer.py 2011-01-17 09:36:23 +0000 | |||
436 | +++ base_contact/base_contact_installer.py 1970-01-01 00:00:00 +0000 | |||
437 | @@ -1,67 +0,0 @@ | |||
438 | 1 | # -*- coding: utf-8 -*- | ||
439 | 2 | ############################################################################## | ||
440 | 3 | # | ||
441 | 4 | # OpenERP, Open Source Management Solution | ||
442 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
443 | 6 | # | ||
444 | 7 | # This program is free software: you can redistribute it and/or modify | ||
445 | 8 | # it under the terms of the GNU Affero General Public License as | ||
446 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
447 | 10 | # License, or (at your option) any later version. | ||
448 | 11 | # | ||
449 | 12 | # This program is distributed in the hope that it will be useful, | ||
450 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
451 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
452 | 15 | # GNU Affero General Public License for more details. | ||
453 | 16 | # | ||
454 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
455 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
456 | 19 | # | ||
457 | 20 | ############################################################################## | ||
458 | 21 | |||
459 | 22 | from osv import fields, osv | ||
460 | 23 | |||
461 | 24 | class base_contact_installer(osv.osv_memory): | ||
462 | 25 | _name = 'base.contact.installer' | ||
463 | 26 | _inherit = 'res.config.installer' | ||
464 | 27 | |||
465 | 28 | _columns = { | ||
466 | 29 | 'name': fields.char('Name', size=64), | ||
467 | 30 | 'migrate': fields.boolean('Migrate', help="If you select this, all addresses will be migrated."), | ||
468 | 31 | } | ||
469 | 32 | |||
470 | 33 | def execute(self, cr, uid, ids, context=None): | ||
471 | 34 | """ | ||
472 | 35 | This function is used to create contact and address from existing partner address | ||
473 | 36 | """ | ||
474 | 37 | obj = self.pool.get("base.contact.installer").browse(cr, uid, uid, context=context) | ||
475 | 38 | if obj.migrate: | ||
476 | 39 | # Enable PL/pgSQL if not enabled yet in the database | ||
477 | 40 | cr.execute("SELECT 1 FROM pg_language WHERE lanname = 'plpgsql'") | ||
478 | 41 | if not cr.fetchone(): | ||
479 | 42 | cr.execute("CREATE LANGUAGE plpgsql;") | ||
480 | 43 | |||
481 | 44 | cr.execute("""DROP TRIGGER IF EXISTS contactjob on res_partner_contact; | ||
482 | 45 | CREATE OR REPLACE FUNCTION add_to_job() RETURNS TRIGGER AS $contactjob$ | ||
483 | 46 | DECLARE | ||
484 | 47 | new_name varchar; | ||
485 | 48 | new_phonenum varchar; | ||
486 | 49 | BEGIN | ||
487 | 50 | IF(TG_OP='INSERT') THEN | ||
488 | 51 | INSERT INTO res_partner_job(contact_id, address_id, function, state) VALUES(NEW.id, NEW.website::integer,NEW.first_name, 'current'); | ||
489 | 52 | UPDATE res_partner_contact set first_name=Null, website=Null, active=True where id=NEW.id; | ||
490 | 53 | END IF; | ||
491 | 54 | RETURN NEW; | ||
492 | 55 | END; | ||
493 | 56 | $contactjob$ LANGUAGE plpgsql; | ||
494 | 57 | CREATE TRIGGER contactjob AFTER INSERT ON res_partner_contact FOR EACH ROW EXECUTE PROCEDURE add_to_job();""") | ||
495 | 58 | |||
496 | 59 | cr.execute("INSERT into res_partner_contact (name, title, email, first_name, website) (SELECT coalesce(name, 'Noname'), title, email, function , to_char(id, '99999999') from res_partner_address)") | ||
497 | 60 | |||
498 | 61 | cr.execute("DROP TRIGGER IF EXISTS contactjob on res_partner_contact") | ||
499 | 62 | |||
500 | 63 | cr.execute("DROP FUNCTION IF EXISTS add_to_job()") | ||
501 | 64 | |||
502 | 65 | base_contact_installer() | ||
503 | 66 | |||
504 | 67 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
505 | 68 | 0 | ||
506 | === removed file 'base_contact/base_contact_installer_view.xml' | |||
507 | --- base_contact/base_contact_installer_view.xml 2011-08-04 12:09:57 +0000 | |||
508 | +++ base_contact/base_contact_installer_view.xml 1970-01-01 00:00:00 +0000 | |||
509 | @@ -1,59 +0,0 @@ | |||
510 | 1 | <openerp> | ||
511 | 2 | <data> | ||
512 | 3 | <record id="view_base_contact_installer" model="ir.ui.view"> | ||
513 | 4 | <field name="name">base.contact.installer.view</field> | ||
514 | 5 | <field name="model">base.contact.installer</field> | ||
515 | 6 | <field name="type">form</field> | ||
516 | 7 | <field name="inherit_id" ref="base.res_config_installer"/> | ||
517 | 8 | <field name="arch" type="xml"> | ||
518 | 9 | <data> | ||
519 | 10 | <form position="attributes"> | ||
520 | 11 | <attribute name="string">Address's Migration to Contacts</attribute> | ||
521 | 12 | </form> | ||
522 | 13 | |||
523 | 14 | <separator string="title" position="attributes"> | ||
524 | 15 | <attribute name="string">Select the Option for Addresses Migration</attribute> | ||
525 | 16 | </separator> | ||
526 | 17 | <xpath expr="//label[@string='description']" position="attributes"> | ||
527 | 18 | <attribute name="string">You can migrate Partner's current addresses to the contact.</attribute> | ||
528 | 19 | </xpath> | ||
529 | 20 | <xpath expr="//separator[@string="vsep"]" position="attributes"> | ||
530 | 21 | <attribute name="rowspan">13</attribute> | ||
531 | 22 | <attribute name="string"/> | ||
532 | 23 | </xpath> | ||
533 | 24 | <xpath expr="//button[@string='Install Modules']" position="attributes"> | ||
534 | 25 | <attribute name="string">Configure</attribute> | ||
535 | 26 | </xpath> | ||
536 | 27 | <group colspan="8"> | ||
537 | 28 | <group colspan="2" col="2"> | ||
538 | 29 | <label string="Due to changes in Address and Partner's relation, some of the details from address are needed to be migrated into contact information." colspan="4"/> | ||
539 | 30 | <label string="Otherwise these details will not be visible from address/contact." colspan="4"/> | ||
540 | 31 | <label string="Do you want to migrate your Address data in Contact Data?" colspan="4"/> | ||
541 | 32 | <group colspan="6"> | ||
542 | 33 | <field name="migrate" string="Migrate" colspan="1"/> | ||
543 | 34 | </group> | ||
544 | 35 | </group> | ||
545 | 36 | </group> | ||
546 | 37 | </data> | ||
547 | 38 | </field> | ||
548 | 39 | </record> | ||
549 | 40 | |||
550 | 41 | <record id="action_base_contact_installer" model="ir.actions.act_window"> | ||
551 | 42 | <field name="name">Address Migration</field> | ||
552 | 43 | <field name="type">ir.actions.act_window</field> | ||
553 | 44 | <field name="res_model">base.contact.installer</field> | ||
554 | 45 | <field name="view_id" ref="view_base_contact_installer"/> | ||
555 | 46 | <field name="view_type">form</field> | ||
556 | 47 | <field name="view_mode">form</field> | ||
557 | 48 | <field name="target">new</field> | ||
558 | 49 | </record> | ||
559 | 50 | |||
560 | 51 | <record id="base_contact_installer_todo" model="ir.actions.todo"> | ||
561 | 52 | <field name="action_id" ref="action_base_contact_installer"/> | ||
562 | 53 | <field name="category_id" ref="base.category_administration_config"/> | ||
563 | 54 | <field name="sequence">3</field> | ||
564 | 55 | <field name="type">automatic</field> | ||
565 | 56 | </record> | ||
566 | 57 | |||
567 | 58 | </data> | ||
568 | 59 | </openerp> | ||
569 | 60 | 0 | ||
570 | === modified file 'base_contact/base_contact_view.xml' | |||
571 | --- base_contact/base_contact_view.xml 2011-10-27 21:11:24 +0000 | |||
572 | +++ base_contact/base_contact_view.xml 2011-12-14 09:21:40 +0000 | |||
573 | @@ -51,10 +51,8 @@ | |||
574 | 51 | <field name="job_ids" colspan="4" nolabel="1" mode="tree,form"> | 51 | <field name="job_ids" colspan="4" nolabel="1" mode="tree,form"> |
575 | 52 | <form string="Functions and Addresses"> | 52 | <form string="Functions and Addresses"> |
576 | 53 | <group colspan="4" col="4"> | 53 | <group colspan="4" col="4"> |
577 | 54 | <field name="sequence_contact" /> | ||
578 | 55 | <field name="function"/> | 54 | <field name="function"/> |
581 | 56 | <field name="name" on_change="onchange_name(name,address_id)"/> | 55 | <field name="name" /> |
580 | 57 | <field name="address_id"/> | ||
582 | 58 | <field name="date_start" /> | 56 | <field name="date_start" /> |
583 | 59 | <field name="date_stop" /> | 57 | <field name="date_stop" /> |
584 | 60 | <field name="state" /> | 58 | <field name="state" /> |
585 | @@ -65,19 +63,13 @@ | |||
586 | 65 | <field name="phone"/> | 63 | <field name="phone"/> |
587 | 66 | <field name="fax"/> | 64 | <field name="fax"/> |
588 | 67 | <field name="email" widget="email"/> | 65 | <field name="email" widget="email"/> |
589 | 68 | <field name="extension"/> | ||
590 | 69 | <field name="other"/> | ||
591 | 70 | </group> | 66 | </group> |
592 | 71 | </form> | 67 | </form> |
593 | 72 | <tree string="Functions and Addresses"> | 68 | <tree string="Functions and Addresses"> |
594 | 73 | <field name="sequence_contact" string="Seq."/> | ||
595 | 74 | <field name="function"/> | 69 | <field name="function"/> |
596 | 75 | <field name="name" on_change="onchange_partner(name)"/> | 70 | <field name="name" on_change="onchange_partner(name)"/> |
597 | 76 | <field name="address_id" attrs="{'required': [('name', '!=', False)]}" on_change="onchange_address(address_id)"/> | ||
598 | 77 | <field name="phone"/> | 71 | <field name="phone"/> |
599 | 78 | <field name="fax"/> | 72 | <field name="fax"/> |
600 | 79 | <field name="extension"/> | ||
601 | 80 | <field name="other"/> | ||
602 | 81 | <field name="email"/> | 73 | <field name="email"/> |
603 | 82 | <field name="state" /> | 74 | <field name="state" /> |
604 | 83 | </tree> | 75 | </tree> |
605 | @@ -173,29 +165,23 @@ | |||
606 | 173 | </group> | 165 | </group> |
607 | 174 | <field name="job_ids" mode="tree,form" nolabel="1" colspan="4"> | 166 | <field name="job_ids" mode="tree,form" nolabel="1" colspan="4"> |
608 | 175 | <tree string="Contacts" editable="top"> | 167 | <tree string="Contacts" editable="top"> |
609 | 176 | <field name="sequence_partner"/> | ||
610 | 177 | <field name="contact_id"/> | 168 | <field name="contact_id"/> |
611 | 178 | <field name="function"/> | 169 | <field name="function"/> |
612 | 179 | <field name="phone"/> | 170 | <field name="phone"/> |
613 | 180 | <field name="fax"/> | 171 | <field name="fax"/> |
614 | 181 | <field name="extension"/> | ||
615 | 182 | <field name="other"/> | ||
616 | 183 | <field name="email"/> | 172 | <field name="email"/> |
617 | 184 | </tree> | 173 | </tree> |
618 | 185 | <form string="Contacts"> | 174 | <form string="Contacts"> |
632 | 186 | <group colspan="4" col="4"> | 175 | <group colspan="4" col="4"> |
633 | 187 | <field name="sequence_partner"/> | 176 | <field name="contact_id"/> |
634 | 188 | <field name="contact_id"/> | 177 | <field name="function"/> |
635 | 189 | <field name="function"/> | 178 | </group> |
636 | 190 | </group> | 179 | <separator string="Communication" colspan="4"/> |
637 | 191 | <separator string="Communication" colspan="4"/> | 180 | <group colspan="4" col="4"> |
638 | 192 | <group colspan="4" col="4"> | 181 | <field name="phone"/> |
639 | 193 | <field name="phone"/> | 182 | <field name="fax"/> |
640 | 194 | <field name="fax"/> | 183 | <field name="email" widget="email"/> |
641 | 195 | <field name="extension"/> | 184 | </group> |
629 | 196 | <field name="other"/> | ||
630 | 197 | <field name="email" widget="email"/> | ||
631 | 198 | </group> | ||
642 | 199 | </form> | 185 | </form> |
643 | 200 | </field> | 186 | </field> |
644 | 201 | </form> | 187 | </form> |
645 | @@ -256,83 +242,29 @@ | |||
646 | 256 | 242 | ||
647 | 257 | <!-- Views for Addresses --> | 243 | <!-- Views for Addresses --> |
648 | 258 | 244 | ||
649 | 259 | <record model="ir.ui.view" id="view_partner_address_tree_inherited1"> | ||
650 | 260 | <field name="name">Partner addresses inherited</field> | ||
651 | 261 | <field name="model">res.partner.address</field> | ||
652 | 262 | <field name="inherit_id" ref="base.view_partner_address_tree"/> | ||
653 | 263 | <field name="type">tree</field> | ||
654 | 264 | <field name="arch" type="xml"> | ||
655 | 265 | <field name="name" position="replace"> | ||
656 | 266 | <field name='job_ids' string='# of Contacts'/> | ||
657 | 267 | </field> | ||
658 | 268 | </field> | ||
659 | 269 | </record> | ||
660 | 270 | |||
661 | 271 | <record model="ir.ui.view" id="view_partner_address_form_inherited0"> | 245 | <record model="ir.ui.view" id="view_partner_address_form_inherited0"> |
662 | 272 | <field name='name'>res.partner.address.form.inherited0</field> | 246 | <field name='name'>res.partner.address.form.inherited0</field> |
663 | 273 | <field name='model'>res.partner.address</field> | 247 | <field name='model'>res.partner.address</field> |
664 | 274 | <field name="inherit_id" ref="base.view_partner_address_form1"/> | 248 | <field name="inherit_id" ref="base.view_partner_address_form1"/> |
665 | 275 | <field name='type'>form</field> | 249 | <field name='type'>form</field> |
666 | 276 | <field name='arch' type='xml'> | 250 | <field name='arch' type='xml'> |
722 | 277 | <field name="type" position="replace"> | 251 | <field name="type" position="replace" /> |
723 | 278 | </field> | 252 | <field name="title" position="replace" /> |
724 | 279 | </field> | 253 | <field name="function" position="replace" /> |
725 | 280 | </record> | 254 | <field name="name" position="replace" /> |
726 | 281 | 255 | <field name="active" position="after"> | |
727 | 282 | <record model="ir.ui.view" id="view_partner_address_form_inherited1"> | 256 | <separator string="Contact" colspan="6" /> |
728 | 283 | <field name='name'>res.partner.address.form.inherited1</field> | 257 | <group colspan="6" col="2"> |
729 | 284 | <field name='model'>res.partner.address</field> | 258 | <field name="title" /> |
730 | 285 | <field name="inherit_id" ref="base.view_partner_address_form1"/> | 259 | <field name="contact_id" /> |
731 | 286 | <field name='type'>form</field> | 260 | <field name="contact_firstname" /> |
732 | 287 | <field name='arch' type='xml'> | 261 | <field name="contact_name" /> |
733 | 288 | <field name="name" position="replace"> | 262 | </group> |
734 | 289 | </field> | 263 | </field> |
680 | 290 | </field> | ||
681 | 291 | </record> | ||
682 | 292 | |||
683 | 293 | <record id='view_partner_address_form_inherited2' model='ir.ui.view'> | ||
684 | 294 | <field name='name'>res.partner.address.form.inherited2</field> | ||
685 | 295 | <field name='model'>res.partner.address</field> | ||
686 | 296 | <field name="inherit_id" ref="base.view_partner_address_form1"/> | ||
687 | 297 | <field name='type'>form</field> | ||
688 | 298 | <field name='arch' type='xml'> | ||
689 | 299 | <field name="title" position="replace"> | ||
690 | 300 | </field> | ||
691 | 301 | </field> | ||
692 | 302 | </record> | ||
693 | 303 | |||
694 | 304 | <record id='view_partner_address_form_inherited3' model='ir.ui.view'> | ||
695 | 305 | <field name='name'>res.partner.address.form.inherited3</field> | ||
696 | 306 | <field name='model'>res.partner.address</field> | ||
697 | 307 | <field name="inherit_id" ref="base.view_partner_address_form1"/> | ||
698 | 308 | <field name='type'>form</field> | ||
699 | 309 | <field name='arch' type='xml'> | ||
700 | 310 | <field name="function" position="replace"> | ||
701 | 311 | </field> | ||
702 | 312 | </field> | ||
703 | 313 | </record> | ||
704 | 314 | |||
705 | 315 | <record id='view_partner_address_form_inherited4' model='ir.ui.view'> | ||
706 | 316 | <field name='name'>res.partner.address.form.inherited4</field> | ||
707 | 317 | <field name='model'>res.partner.address</field> | ||
708 | 318 | <field name="inherit_id" ref="base.view_partner_address_form1"/> | ||
709 | 319 | <field name='type'>form</field> | ||
710 | 320 | <field name='arch' type='xml'> | ||
711 | 321 | <field name='mobile' position="replace"> | ||
712 | 322 | </field> | ||
713 | 323 | </field> | ||
714 | 324 | </record> | ||
715 | 325 | |||
716 | 326 | <record model="ir.ui.view" id="view_partner_address_form_inherited6"> | ||
717 | 327 | <field name='name'>res.partner.address.form.inherited6</field> | ||
718 | 328 | <field name='model'>res.partner.address</field> | ||
719 | 329 | <field name="inherit_id" ref="base.view_partner_address_form1"/> | ||
720 | 330 | <field name='type'>form</field> | ||
721 | 331 | <field name='arch' type='xml'> | ||
735 | 332 | <field name="partner_id" position="replace"> | 264 | <field name="partner_id" position="replace"> |
736 | 333 | <field name='partner_id' select='1'/> | 265 | <field name='partner_id' select='1'/> |
739 | 334 | <field name='type' select='2'/> | 266 | <field name='type' select='2' invisible="1"/> |
740 | 335 | <field name='job_id' invisible="1"/> | 267 | <field name="function" /> |
741 | 336 | </field> | 268 | </field> |
742 | 337 | </field> | 269 | </field> |
743 | 338 | </record> | 270 | </record> |
744 | @@ -344,13 +276,14 @@ | |||
745 | 344 | <field name="inherit_id" ref="base.view_res_partner_address_filter"/> | 276 | <field name="inherit_id" ref="base.view_res_partner_address_filter"/> |
746 | 345 | <field name="arch" type="xml"> | 277 | <field name="arch" type="xml"> |
747 | 346 | <search string="Search Contact"> | 278 | <search string="Search Contact"> |
749 | 347 | <field name="job_ids"/> | 279 | <field name="job_ids"/> |
750 | 348 | </search> | 280 | </search> |
751 | 349 | </field> | 281 | </field> |
752 | 350 | </record> | 282 | </record> |
753 | 351 | 283 | ||
754 | 352 | <!-- Views for partner job Tree view --> | 284 | <!-- Views for partner job Tree view --> |
755 | 353 | 285 | ||
756 | 286 | <!-- | ||
757 | 354 | <record model="ir.ui.view" id="view_partner_job_tree"> | 287 | <record model="ir.ui.view" id="view_partner_job_tree"> |
758 | 355 | <field name="name">res.partner.job.tree</field> | 288 | <field name="name">res.partner.job.tree</field> |
759 | 356 | <field name="model">res.partner.job</field> | 289 | <field name="model">res.partner.job</field> |
760 | @@ -364,14 +297,15 @@ | |||
761 | 364 | <field name="email"/> | 297 | <field name="email"/> |
762 | 365 | <field name="phone"/> | 298 | <field name="phone"/> |
763 | 366 | <field name="fax"/> | 299 | <field name="fax"/> |
764 | 367 | <field name="extension"/> | ||
765 | 368 | <field name="state" /> | 300 | <field name="state" /> |
766 | 369 | </tree> | 301 | </tree> |
767 | 370 | </field> | 302 | </field> |
768 | 371 | </record> | 303 | </record> |
769 | 304 | --> | ||
770 | 372 | 305 | ||
771 | 373 | <!-- Views for partner job Form view --> | 306 | <!-- Views for partner job Form view --> |
772 | 374 | 307 | ||
773 | 308 | <!-- | ||
774 | 375 | <record model="ir.ui.view" id="view_partner_job_form"> | 309 | <record model="ir.ui.view" id="view_partner_job_form"> |
775 | 376 | <field name="name">res.partner.job.form</field> | 310 | <field name="name">res.partner.job.form</field> |
776 | 377 | <field name="model">res.partner.job</field> | 311 | <field name="model">res.partner.job</field> |
777 | @@ -385,18 +319,17 @@ | |||
778 | 385 | <field name="email" widget="email"/> | 319 | <field name="email" widget="email"/> |
779 | 386 | <field name="phone"/> | 320 | <field name="phone"/> |
780 | 387 | <field name="fax"/> | 321 | <field name="fax"/> |
781 | 388 | <field name="extension"/> | ||
782 | 389 | <field name="sequence_contact" groups="base.group_user"/> | ||
783 | 390 | <field name="sequence_partner" groups="base.group_user"/> | ||
784 | 391 | <field name="date_start" groups="base.group_user"/> | 322 | <field name="date_start" groups="base.group_user"/> |
785 | 392 | <field name="date_stop" groups="base.group_user"/> | 323 | <field name="date_stop" groups="base.group_user"/> |
786 | 393 | <field name="state" /> | 324 | <field name="state" /> |
787 | 394 | </form> | 325 | </form> |
788 | 395 | </field> | 326 | </field> |
789 | 396 | </record> | 327 | </record> |
790 | 328 | --> | ||
791 | 397 | 329 | ||
792 | 398 | <!-- Menuitem for res.partner.job --> | 330 | <!-- Menuitem for res.partner.job --> |
793 | 399 | 331 | ||
794 | 332 | <!-- | ||
795 | 400 | <record model="ir.actions.act_window" id="action_res_partner_job"> | 333 | <record model="ir.actions.act_window" id="action_res_partner_job"> |
796 | 401 | <field name="name">Contact's Jobs</field> | 334 | <field name="name">Contact's Jobs</field> |
797 | 402 | <field name="type">ir.actions.act_window</field> | 335 | <field name="type">ir.actions.act_window</field> |
798 | @@ -409,9 +342,11 @@ | |||
799 | 409 | res_model="res.partner.job" | 342 | res_model="res.partner.job" |
800 | 410 | src_model="res.partner" | 343 | src_model="res.partner" |
801 | 411 | /> | 344 | /> |
802 | 345 | --> | ||
803 | 412 | 346 | ||
804 | 413 | <!-- Act window defining a shorcut on partner address to open all his jobs --> | 347 | <!-- Act window defining a shorcut on partner address to open all his jobs --> |
805 | 414 | 348 | ||
806 | 349 | <!-- | ||
807 | 415 | <act_window | 350 | <act_window |
808 | 416 | id="act_res_partner_jobs" | 351 | id="act_res_partner_jobs" |
809 | 417 | name="Open Jobs" | 352 | name="Open Jobs" |
810 | @@ -419,6 +354,7 @@ | |||
811 | 419 | res_model="res.partner.job" | 354 | res_model="res.partner.job" |
812 | 420 | src_model="res.partner.address" | 355 | src_model="res.partner.address" |
813 | 421 | /> | 356 | /> |
814 | 357 | --> | ||
815 | 422 | 358 | ||
816 | 423 | </data> | 359 | </data> |
817 | 424 | </openerp> | 360 | </openerp> |
818 | 425 | 361 | ||
819 | === added file 'base_contact/images/photo.png' | |||
820 | 426 | Binary files base_contact/images/photo.png 1970-01-01 00:00:00 +0000 and base_contact/images/photo.png 2011-12-14 09:21:40 +0000 differ | 362 | Binary files base_contact/images/photo.png 1970-01-01 00:00:00 +0000 and base_contact/images/photo.png 2011-12-14 09:21:40 +0000 differ |
821 | === modified file 'base_contact/process/base_contact_process.xml' | |||
822 | --- base_contact/process/base_contact_process.xml 2011-01-14 00:11:01 +0000 | |||
823 | +++ base_contact/process/base_contact_process.xml 2011-12-14 09:21:40 +0000 | |||
824 | @@ -36,15 +36,6 @@ | |||
825 | 36 | <field eval="1" name="flow_start"/> | 36 | <field eval="1" name="flow_start"/> |
826 | 37 | </record> | 37 | </record> |
827 | 38 | 38 | ||
828 | 39 | <record id="process_node_function0" model="process.node"> | ||
829 | 40 | <field name="model_id" ref="base_contact.model_res_partner_job"/> | ||
830 | 41 | <field eval=""""state"""" name="kind"/> | ||
831 | 42 | <field eval=""""Jobs at a same partner address."""" name="note"/> | ||
832 | 43 | <field eval=""""Function"""" name="name"/> | ||
833 | 44 | <field name="process_id" ref="process_process_basecontactprocess0"/> | ||
834 | 45 | <field eval="0" name="flow_start"/> | ||
835 | 46 | </record> | ||
836 | 47 | |||
837 | 48 | <record id="process_node_addresses0" model="process.node"> | 39 | <record id="process_node_addresses0" model="process.node"> |
838 | 49 | <field name="menu_id" ref="base.menu_partner_address_form"/> | 40 | <field name="menu_id" ref="base.menu_partner_address_form"/> |
839 | 50 | <field name="model_id" ref="base.model_res_partner_address"/> | 41 | <field name="model_id" ref="base.model_res_partner_address"/> |
840 | @@ -59,22 +50,6 @@ | |||
841 | 59 | Process Transition | 50 | Process Transition |
842 | 60 | --> | 51 | --> |
843 | 61 | 52 | ||
844 | 62 | <record id="process_transition_contacttofunction0" model="process.transition"> | ||
845 | 63 | <field eval="[(6,0,[])]" name="transition_ids"/> | ||
846 | 64 | <field eval=""""Contact to function"""" name="name"/> | ||
847 | 65 | <field eval=""""Defines contacts and functions."""" name="note"/> | ||
848 | 66 | <field model="process.node" name="target_node_id" ref="process_node_function0"/> | ||
849 | 67 | <field model="process.node" name="source_node_id" ref="process_node_contacts0"/> | ||
850 | 68 | </record> | ||
851 | 69 | |||
852 | 70 | <record id="process_transition_functiontoaddress0" model="process.transition"> | ||
853 | 71 | <field eval="[(6,0,[])]" name="transition_ids"/> | ||
854 | 72 | <field eval=""""Function to address"""" name="name"/> | ||
855 | 73 | <field eval=""""Define functions and address."""" name="note"/> | ||
856 | 74 | <field model="process.node" name="target_node_id" ref="process_node_addresses0"/> | ||
857 | 75 | <field model="process.node" name="source_node_id" ref="process_node_function0"/> | ||
858 | 76 | </record> | ||
859 | 77 | |||
860 | 78 | <record id="process_transition_partnertoaddress0" model="process.transition"> | 53 | <record id="process_transition_partnertoaddress0" model="process.transition"> |
861 | 79 | <field eval="[(6,0,[])]" name="transition_ids"/> | 54 | <field eval="[(6,0,[])]" name="transition_ids"/> |
862 | 80 | <field eval=""""Partner to address"""" name="name"/> | 55 | <field eval=""""Partner to address"""" name="name"/> |
863 | @@ -84,4 +59,4 @@ | |||
864 | 84 | </record> | 59 | </record> |
865 | 85 | 60 | ||
866 | 86 | </data> | 61 | </data> |
867 | 87 | </openerp> | ||
868 | 88 | \ No newline at end of file | 62 | \ No newline at end of file |
869 | 63 | </openerp> | ||
870 | 89 | 64 | ||
871 | === modified file 'base_contact/security/ir.model.access.csv' | |||
872 | --- base_contact/security/ir.model.access.csv 2011-12-12 18:11:13 +0000 | |||
873 | +++ base_contact/security/ir.model.access.csv 2011-12-14 09:21:40 +0000 | |||
874 | @@ -1,3 +1,4 @@ | |||
875 | 1 | <<<<<<< TREE | ||
876 | 1 | id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | 2 | id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink |
877 | 2 | access_res_partner_contact,res.partner.contact,model_res_partner_contact,base.group_partner_manager,1,1,1,1 | 3 | access_res_partner_contact,res.partner.contact,model_res_partner_contact,base.group_partner_manager,1,1,1,1 |
878 | 3 | access_res_partner_job,res.partner.job,model_res_partner_job,base.group_partner_manager,1,1,1,1 | 4 | access_res_partner_job,res.partner.job,model_res_partner_job,base.group_partner_manager,1,1,1,1 |
879 | @@ -5,3 +6,9 @@ | |||
880 | 5 | access_res_partner_job_all,res.partner.job all,model_res_partner_job,base.group_user,1,0,0,0 | 6 | access_res_partner_job_all,res.partner.job all,model_res_partner_job,base.group_user,1,0,0,0 |
881 | 6 | access_group_sale_salesman,res.partner.contact.sale.salesman,model_res_partner_contact,base.group_sale_salesman,1,1,1,0 | 7 | access_group_sale_salesman,res.partner.contact.sale.salesman,model_res_partner_contact,base.group_sale_salesman,1,1,1,0 |
882 | 7 | access_res_partner_job_salesman,res.partner.job.salesman,model_res_partner_job,base.group_sale_salesman,1,1,1,0 | 8 | access_res_partner_job_salesman,res.partner.job.salesman,model_res_partner_job,base.group_sale_salesman,1,1,1,0 |
883 | 9 | ======= | ||
884 | 10 | "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" | ||
885 | 11 | "access_res_partner_contact","res.partner.contact","model_res_partner_contact","base.group_partner_manager",1,1,1,1 | ||
886 | 12 | "access_res_partner_contact_all","res.partner.contact all","model_res_partner_contact","base.group_user",1,0,0,0 | ||
887 | 13 | "access_group_sale_salesman","res.partner.contact.sale.salesman","model_res_partner_contact","base.group_sale_salesman",1,1,1,0 | ||
888 | 14 | >>>>>>> MERGE-SOURCE | ||
889 | 8 | 15 | ||
890 | === modified file 'base_contact/test/base_contact00.yml' | |||
891 | --- base_contact/test/base_contact00.yml 2011-11-28 16:04:32 +0000 | |||
892 | +++ base_contact/test/base_contact00.yml 2011-12-14 09:21:40 +0000 | |||
893 | @@ -25,7 +25,6 @@ | |||
894 | 25 | - email: lwilliams@mydomain.com | 25 | - email: lwilliams@mydomain.com |
895 | 26 | function: PA | 26 | function: PA |
896 | 27 | phone: (+32).10.45.18.77 | 27 | phone: (+32).10.45.18.77 |
897 | 28 | sequence_contact: 1 | ||
898 | 29 | state: current | 28 | state: current |
899 | 30 | lang_id: res_lang_french0 | 29 | lang_id: res_lang_french0 |
900 | 31 | mobile: (+32).10.45.18.77 | 30 | mobile: (+32).10.45.18.77 |
901 | @@ -45,7 +44,6 @@ | |||
902 | 45 | - address_id: res_partner_address_1 | 44 | - address_id: res_partner_address_1 |
903 | 46 | function: CEO | 45 | function: CEO |
904 | 47 | contact_id: res_partner_contact_williams0 | 46 | contact_id: res_partner_contact_williams0 |
905 | 48 | sequence_partner: 2 | ||
906 | 49 | state: current | 47 | state: current |
907 | 50 | lang: fr_BE | 48 | lang: fr_BE |
908 | 51 | name: Laura's Company | 49 | name: Laura's Company |
909 | 52 | 50 | ||
910 | === modified file 'event/__openerp__.py' | |||
911 | --- event/__openerp__.py 2011-12-13 14:19:49 +0000 | |||
912 | +++ event/__openerp__.py 2011-12-14 09:21:40 +0000 | |||
913 | @@ -39,7 +39,7 @@ | |||
914 | 39 | Association / Configuration / Types of Events | 39 | Association / Configuration / Types of Events |
915 | 40 | """, | 40 | """, |
916 | 41 | 'author': 'OpenERP SA', | 41 | 'author': 'OpenERP SA', |
918 | 42 | 'depends': ['crm', 'base_contact', 'account', 'marketing', 'mail'], | 42 | 'depends': ['crm', 'account', 'marketing', 'mail'], |
919 | 43 | 'init_xml': [], | 43 | 'init_xml': [], |
920 | 44 | 'update_xml': [ | 44 | 'update_xml': [ |
921 | 45 | 'security/ir.model.access.csv', | 45 | 'security/ir.model.access.csv', |
922 | 46 | 46 | ||
923 | === modified file 'event/event.py' | |||
924 | --- event/event.py 2011-11-14 22:08:36 +0000 | |||
925 | +++ event/event.py 2011-12-14 09:21:40 +0000 | |||
926 | @@ -303,7 +303,7 @@ | |||
927 | 303 | 'event_id': fields.many2one('event.event', 'Event', required=True, readonly=True, states={'draft': [('readonly', False)]}), | 303 | 'event_id': fields.many2one('event.event', 'Event', required=True, readonly=True, states={'draft': [('readonly', False)]}), |
928 | 304 | 'partner_id': fields.many2one('res.partner', 'Partner', states={'done': [('readonly', True)]}), | 304 | 'partner_id': fields.many2one('res.partner', 'Partner', states={'done': [('readonly', True)]}), |
929 | 305 | "partner_invoice_id": fields.many2one('res.partner', 'Partner Invoiced', readonly=True, states={'draft': [('readonly', False)]}), | 305 | "partner_invoice_id": fields.many2one('res.partner', 'Partner Invoiced', readonly=True, states={'draft': [('readonly', False)]}), |
931 | 306 | "contact_id": fields.many2one('res.partner.contact', 'Partner Contact', readonly=False, states={'done': [('readonly', True)]}), #TODO: filter only the contacts that have a function into the selected partner_id | 306 | "contact_id": fields.many2one('res.partner.address', 'Partner Contact', readonly=False, states={'done': [('readonly', True)]}), #TODO: filter only the contacts that have a function into the selected partner_id |
932 | 307 | "unit_price": fields.float('Unit Price', required=True, digits_compute=dp.get_precision('Sale Price'), readonly=True, states={'draft': [('readonly', False)]}), | 307 | "unit_price": fields.float('Unit Price', required=True, digits_compute=dp.get_precision('Sale Price'), readonly=True, states={'draft': [('readonly', False)]}), |
933 | 308 | 'price_subtotal': fields.function(_amount_line, string='Subtotal', digits_compute=dp.get_precision('Sale Price'), store=True), | 308 | 'price_subtotal': fields.function(_amount_line, string='Subtotal', digits_compute=dp.get_precision('Sale Price'), store=True), |
934 | 309 | "badge_ids": fields.one2many('event.registration.badge', 'registration_id', 'Badges', readonly=False, states={'done': [('readonly', True)]}), | 309 | "badge_ids": fields.one2many('event.registration.badge', 'registration_id', 'Badges', readonly=False, states={'done': [('readonly', True)]}), |
935 | @@ -382,7 +382,7 @@ | |||
936 | 382 | inv_lines_pool = self.pool.get('account.invoice.line') | 382 | inv_lines_pool = self.pool.get('account.invoice.line') |
937 | 383 | inv_pool = self.pool.get('account.invoice') | 383 | inv_pool = self.pool.get('account.invoice') |
938 | 384 | product_pool = self.pool.get('product.product') | 384 | product_pool = self.pool.get('product.product') |
940 | 385 | contact_pool = self.pool.get('res.partner.contact') | 385 | contact_pool = self.pool.get('res.partner.address') |
941 | 386 | if context is None: | 386 | if context is None: |
942 | 387 | context = {} | 387 | context = {} |
943 | 388 | # If date was specified, use it as date invoiced, usefull when invoices are generated this month and put the | 388 | # If date was specified, use it as date invoiced, usefull when invoices are generated this month and put the |
It breaks module stock.
I created a database, and installed base_contact, then sale. The following error occurs:
[2011-11-30 15:09:12,683][foo] INFO:init. load:module stock: loading test/stock_test.yml id","name" ,"auto_ picking" ,"move_ type"," company_ id","invoice_ state", "state" ,"date" ,"type" ,create_ uid,create_ date) values (2,41,' test_picking' ,'False' ,'direct' ,1,'2binvoiced' ,'draft' ,'2011- 11-30 15:09:15' ,'out', 1,now() ) openerp/ openerp/ server/ trunk/openerp/ sql_db. py", line 215, in execute execute( query, params) picking_ address_ id_fkey"
[2011-11-30 15:09:15,241][foo] ERROR:db.cursor:bad query: insert into "stock_picking" (id,"address_
Traceback (most recent call last):
File "/home/
res = self._obj.
IntegrityError: insert or update on table "stock_picking" violates foreign key constraint "stock_
DETAIL: Key (address_id)=(41) is not present in table "res_partner_job".