Merge lp:~vauxoo/addons-vauxoo/7.0-addons-vauxoo-pylint-datetime-dev-alan into lp:~vauxoo/addons-vauxoo/7.0-addons-vauxoo-imp-datetime-dev-ernesto
- 7.0-addons-vauxoo-pylint-datetime-dev-alan
- Merge into 7.0-addons-vauxoo-imp-date...
Status: | Merged |
---|---|
Merged at revision: | 1124 |
Proposed branch: | lp:~vauxoo/addons-vauxoo/7.0-addons-vauxoo-pylint-datetime-dev-alan |
Merge into: | lp:~vauxoo/addons-vauxoo/7.0-addons-vauxoo-imp-datetime-dev-ernesto |
Diff against target: |
453 lines (+151/-106) 6 files modified
invoice_datetime/__init__.py (+2/-2) invoice_datetime/__openerp__.py (+22/-20) invoice_datetime/invoice.py (+67/-39) invoice_datetime/res_config.py (+26/-10) invoice_datetime/tests/__init__.py (+0/-4) invoice_datetime/tests/test_invoice_datetime.py (+34/-31) |
To merge this branch: | bzr merge lp:~vauxoo/addons-vauxoo/7.0-addons-vauxoo-pylint-datetime-dev-alan |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Luis Ernesto García Medina - http://www.vauxoo.com | Needs Fixing | ||
Jesus Alan Guzman Escalante | Pending | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
- 1124. By Luis Ernesto García Medina - http://www.vauxoo.com
-
[MERGE] merge with lp:~vauxoo/addons-vauxoo/7.0-addons-vauxoo-imp-datetime-dev-ernesto
- 1125. By Luis Ernesto García Medina - http://www.vauxoo.com
-
from Jorge [IMP][invoice_
datetime] Flake8 invoice.py
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Luis Ernesto García Medina - http://www.vauxoo.com (ernesto-gm) wrote : | # |
review:
Approve
- 1126. By Jesus Alan Guzman Escalante
-
[FIX] pylint y flake8 in this module
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Luis Ernesto García Medina - http://www.vauxoo.com (ernesto-gm) wrote : | # |
alana te comente en la linea 348
review:
Needs Fixing
- 1127. By Jesus Alan Guzman Escalante
-
[FIX]correction code
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'invoice_datetime/__init__.py' |
2 | --- invoice_datetime/__init__.py 2014-10-03 00:28:23 +0000 |
3 | +++ invoice_datetime/__init__.py 2014-11-11 22:10:57 +0000 |
4 | @@ -7,7 +7,8 @@ |
5 | # info Vauxoo (info@vauxoo.com) |
6 | ############################################################################ |
7 | # Coded by: moylop260 (moylop260@vauxoo.com) |
8 | -# Launchpad Project Manager for Publication: Nhomar Hernandez - nhomar@vauxoo.com |
9 | +# Launchpad Project Manager for Publication: |
10 | +# Nhomar Hernandez - nhomar@vauxoo.com |
11 | ############################################################################ |
12 | # |
13 | # This program is free software: you can redistribute it and/or modify |
14 | @@ -27,4 +28,3 @@ |
15 | |
16 | from . import invoice |
17 | from . import res_config |
18 | - |
19 | |
20 | === modified file 'invoice_datetime/__openerp__.py' |
21 | --- invoice_datetime/__openerp__.py 2014-10-03 08:22:36 +0000 |
22 | +++ invoice_datetime/__openerp__.py 2014-11-11 22:10:57 +0000 |
23 | @@ -6,8 +6,10 @@ |
24 | # All Rights Reserved. |
25 | # info Vauxoo (info@vauxoo.com) |
26 | ############################################################################ |
27 | -# Coded by: moylop260 (moylop260@vauxoo.com) modified by carlosecv74@gmail.com |
28 | -# Launchpad Project Manager for Publication: Nhomar Hernandez - nhomar@vauxoo.com |
29 | +# Coded by: moylop260 (moylop260@vauxoo.com) |
30 | +# modified by carlosecv74@gmail.com |
31 | +# Launchpad Project Manager for Publication: |
32 | +# Nhomar Hernandez - nhomar@vauxoo.com |
33 | ############################################################################ |
34 | # |
35 | # This program is free software: you can redistribute it and/or modify |
36 | @@ -25,28 +27,28 @@ |
37 | # |
38 | ############################################################################## |
39 | { |
40 | - "name": "invoice_datetime", |
41 | - "version": "1.0", |
42 | - "author": "Vauxoo", |
43 | - "category": "Localization/Mexico", |
44 | + "name": "invoice_datetime", |
45 | + "version": "1.0", |
46 | + "author": "Vauxoo", |
47 | + "category": "Localization/Mexico", |
48 | "description": """Add new field invoice_datetime for electronic invoice data |
49 | and add hour & minute to field date_invoice |
50 | - """, |
51 | - "website": "http://www.vauxoo.com/", |
52 | - "license": "AGPL-3", |
53 | + """, |
54 | + "website": "http://www.vauxoo.com/", |
55 | + "license": "AGPL-3", |
56 | "depends": [ |
57 | "account" |
58 | - ], |
59 | - "demo": [], |
60 | + ], |
61 | + "demo": [], |
62 | "data": [ |
63 | - "account_invoice_view.xml", |
64 | + "account_invoice_view.xml", |
65 | "res_config_acc_view.xml" |
66 | - ], |
67 | - "test": [], |
68 | - "js": [], |
69 | - "css": [], |
70 | - "qweb": [], |
71 | - "installable": True, |
72 | - "auto_install": False, |
73 | + ], |
74 | + "test": [], |
75 | + "js": [], |
76 | + "css": [], |
77 | + "qweb": [], |
78 | + "installable": True, |
79 | + "auto_install": False, |
80 | "active": False |
81 | -} |
82 | \ No newline at end of file |
83 | +} |
84 | |
85 | === modified file 'invoice_datetime/invoice.py' |
86 | --- invoice_datetime/invoice.py 2014-11-07 18:41:44 +0000 |
87 | +++ invoice_datetime/invoice.py 2014-11-11 22:10:57 +0000 |
88 | @@ -7,7 +7,8 @@ |
89 | # info Vauxoo (info@vauxoo.com) |
90 | ############################################################################ |
91 | # Coded by: moylop260 (moylop260@vauxoo.com) |
92 | -# Launchpad Project Manager for Publication: Nhomar Hernandez - nhomar@vauxoo.com |
93 | +# Launchpad Project Manager for Publication: |
94 | +# * Nhomar Hernandez - nhomar@vauxoo.com |
95 | ############################################################################ |
96 | # |
97 | # This program is free software: you can redistribute it and/or modify |
98 | @@ -47,15 +48,16 @@ |
99 | date_ref, '%Y-%m-%d %H:%M:%S')) |
100 | except BaseException: |
101 | pass |
102 | - return super(account_payment_term, self).compute(cr, uid, ids, value, |
103 | - date_ref, context=context) |
104 | + return super(account_payment_term, self).compute( |
105 | + cr, uid, ids, value, date_ref, context=context) |
106 | |
107 | |
108 | class account_invoice(osv.Model): |
109 | _inherit = 'account.invoice' |
110 | - #_order = 'invoice_datetime asc' |
111 | + # _order = 'invoice_datetime asc' |
112 | |
113 | - def _get_date_invoice_tz(self, cr, uid, ids, field_names=None, arg=False, context=None): |
114 | + def _get_date_invoice_tz(self, cr, uid, ids, field_names=None, arg=False, |
115 | + context=None): |
116 | if context is None: |
117 | context = {} |
118 | res = {} |
119 | @@ -63,9 +65,10 @@ |
120 | tz = self.pool.get('res.users').browse(cr, uid, uid).tz |
121 | for invoice in self.browse(cr, uid, ids, context=context): |
122 | res[invoice.id] = invoice.invoice_datetime and tools.\ |
123 | - server_to_local_timestamp(invoice.invoice_datetime, |
124 | - tools.DEFAULT_SERVER_DATETIME_FORMAT, |
125 | - tools.DEFAULT_SERVER_DATETIME_FORMAT, tz) or False |
126 | + server_to_local_timestamp( |
127 | + invoice.invoice_datetime, |
128 | + tools.DEFAULT_SERVER_DATETIME_FORMAT, |
129 | + tools.DEFAULT_SERVER_DATETIME_FORMAT, tz) or False |
130 | elif release.version < '6': |
131 | # TODO: tz change for openerp5 |
132 | for invoice in self.browse(cr, uid, ids, context=context): |
133 | @@ -75,33 +78,47 @@ |
134 | def _get_field_params(self, cr, uid, ids, name, unknow_none, context=None): |
135 | if context is None: |
136 | context = {} |
137 | + account_setting_obj = self.pool.get("account.config.settings") |
138 | ids = isinstance(ids, (int, long)) and [ids] or ids |
139 | res = {} |
140 | - key_by_company_id = "acc_invoice.date_invoice_type_" + str(self.pool.get("account.config.settings")._default_company(cr, uid)) |
141 | - res[ids[0]] = self.pool.get("ir.config_parameter").get_param(cr, uid, key_by_company_id, default='date', context=context) |
142 | + key_by_company_id = "acc_invoice.date_invoice_type_" + \ |
143 | + str(account_setting_obj._default_company(cr, uid)) |
144 | + res[ids[0]] = self.pool.get("ir.config_parameter").get_param( |
145 | + cr, uid, key_by_company_id, default='date', context=context) |
146 | return res |
147 | |
148 | _columns = { |
149 | # Extract date_invoice from original, but add datetime |
150 | - #'date_invoice': fields.datetime('Date Invoiced', states={'open':[ |
151 | - #('readonly',True)],'close':[('readonly',True)]}, |
152 | + # 'date_invoice': fields.datetime('Date Invoiced', states={'open':[ |
153 | + # ('readonly',True)],'close':[('readonly',True)]}, |
154 | # help="Keep empty to use the current date"), |
155 | - 'invoice_datetime': fields.datetime('Date time of invoice', |
156 | - states={'open': [('readonly', True)], 'close': [('readonly', True)]}, |
157 | + 'invoice_datetime': fields.datetime( |
158 | + 'Date time of invoice', |
159 | + states={ |
160 | + 'open': [('readonly', True)], |
161 | + 'close': [('readonly', True)]}, |
162 | help="Keep empty to use the current date"), |
163 | - 'date_invoice_tz': fields.function(_get_date_invoice_tz, method=True, |
164 | - type='datetime', string='Date Invoiced with TZ', store=True, |
165 | + 'date_invoice_tz': fields.function( |
166 | + _get_date_invoice_tz, |
167 | + method=True, |
168 | + type='datetime', |
169 | + string='Date Invoiced with TZ', |
170 | + store=True, |
171 | help='Date of Invoice with Time Zone'), |
172 | - 'date_type': fields.function(_get_field_params, storage=False, type='char', string="Date type") |
173 | + 'date_type': fields.function(_get_field_params, storage=False, |
174 | + type='char', string="Date type") |
175 | } |
176 | |
177 | def _get_default_type(self, cr, uid, ids): |
178 | - key_by_company_id = "acc_invoice.date_invoice_type_" + str(self.pool.get("account.config.settings")._default_company(cr, uid)) |
179 | - type_show_date = self.pool.get("ir.config_parameter").get_param(cr, uid, key_by_company_id, default='date') |
180 | + account_setting_obj = self.pool.get("account.config.settings") |
181 | + key_by_company_id = "acc_invoice.date_invoice_type_" + \ |
182 | + str(account_setting_obj._default_company(cr, uid)) |
183 | + type_show_date = self.pool.get("ir.config_parameter").get_param( |
184 | + cr, uid, key_by_company_id, default='date') |
185 | return type_show_date |
186 | |
187 | _defaults = { |
188 | - #'date_invoice': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), |
189 | + # 'date_invoice': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), |
190 | "date_type": _get_default_type |
191 | } |
192 | |
193 | @@ -111,7 +128,8 @@ |
194 | if default is None: |
195 | default = {} |
196 | default.update({'invoice_datetime': False, 'date_invoice': False}) |
197 | - return super(account_invoice, self).copy(cr, uid, ids, default, context) |
198 | + return super(account_invoice, self).copy( |
199 | + cr, uid, ids, default, context) |
200 | |
201 | def _get_time_zone(self, cr, uid, invoice_id, context=None): |
202 | if context is None: |
203 | @@ -123,8 +141,9 @@ |
204 | hours = timezone(userstz) |
205 | fmt = '%Y-%m-%d %H:%M:%S %Z%z' |
206 | now = datetime.datetime.now() |
207 | - loc_dt = hours.localize(datetime.datetime(now.year, now.month, now.day, |
208 | - now.hour, now.minute, now.second)) |
209 | + loc_dt = hours.localize(datetime.datetime(now.year, now.month, |
210 | + now.day, now.hour, |
211 | + now.minute, now.second)) |
212 | timezone_loc = (loc_dt.strftime(fmt)) |
213 | diff_timezone_original = timezone_loc[-5:-2] |
214 | timezone_original = int(diff_timezone_original) |
215 | @@ -155,9 +174,10 @@ |
216 | |
217 | if values.get('invoice_datetime', False) and not\ |
218 | values.get('date_invoice', False): |
219 | - date_invoice = fields.datetime.context_timestamp(cr, uid, |
220 | - datetime.datetime.strptime(values['invoice_datetime'], |
221 | - tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context) |
222 | + date_invoice = fields.datetime.context_timestamp( |
223 | + cr, uid, datetime.datetime.strptime( |
224 | + values['invoice_datetime'], |
225 | + tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context) |
226 | res['date_invoice'] = date_invoice |
227 | res['invoice_datetime'] = values['invoice_datetime'] |
228 | |
229 | @@ -168,31 +188,39 @@ |
230 | '%Y-%m-%d %H:%M:%S').date().strftime('%Y-%m-%d') |
231 | if date_invoice != values['date_invoice']: |
232 | if self.browse(cr, uid, ids)[0].date_type == 'datetime': |
233 | - date_invoice = fields.datetime.context_timestamp(cr, uid, |
234 | - datetime.datetime.strptime(values['invoice_datetime'], |
235 | - tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context) |
236 | + date_invoice = fields.datetime.context_timestamp( |
237 | + cr, uid, datetime.datetime.strptime( |
238 | + values['invoice_datetime'], |
239 | + tools.DEFAULT_SERVER_DATETIME_FORMAT), |
240 | + context=context) |
241 | res['date_invoice'] = date_invoice |
242 | res['invoice_datetime'] = values['invoice_datetime'] |
243 | elif self.browse(cr, uid, ids)[0].date_type == 'date': |
244 | - user_hour = self._get_time_zone(cr, uid, [], context=context) |
245 | + user_hour = self._get_time_zone( |
246 | + cr, uid, [], context=context) |
247 | time_invoice = datetime.time(abs(user_hour), 0, 0) |
248 | |
249 | date_invoice = datetime.datetime.strptime( |
250 | values['date_invoice'], '%Y-%m-%d').date() |
251 | |
252 | dt_invoice = datetime.datetime.combine( |
253 | - date_invoice, time_invoice).strftime('%Y-%m-%d %H:%M:%S') |
254 | + date_invoice, |
255 | + time_invoice).strftime('%Y-%m-%d %H:%M:%S') |
256 | |
257 | res['invoice_datetime'] = dt_invoice |
258 | res['date_invoice'] = values['date_invoice'] |
259 | else: |
260 | - raise osv.except_osv(_('Warning!'), _('Invoice dates should be equal')) |
261 | - #~ else: |
262 | - #~ raise osv.except_osv(_('Warning!'), _('Invoice dates should be equal')) |
263 | + raise osv.except_osv(_('Warning!'), |
264 | + _('Invoice dates should be equal') |
265 | + ) |
266 | + # ~ else: |
267 | + # ~ raise osv.except_osv(_('Warning!'), |
268 | + # _('Invoice dates should be equal')) |
269 | |
270 | - if not values.get('invoice_datetime', False) and\ |
271 | + if not values.get('invoice_datetime', False) and\ |
272 | not values.get('date_invoice', False): |
273 | - res['date_invoice'] = fields.date.context_today(self, cr, uid, context=context) |
274 | + res['date_invoice'] = fields.date.context_today( |
275 | + self, cr, uid, context=context) |
276 | res['invoice_datetime'] = fields.datetime.now() |
277 | |
278 | return res |
279 | @@ -200,9 +228,9 @@ |
280 | def action_move_create(self, cr, uid, ids, context=None): |
281 | for inv in self.browse(cr, uid, ids, context=context): |
282 | if inv.type in ('out_invoice', 'out_refund'): |
283 | - vals_date = self.assigned_datetime(cr, uid, ids, |
284 | - {'invoice_datetime': inv.invoice_datetime, |
285 | - 'date_invoice': inv.date_invoice}, |
286 | + vals_date = self.assigned_datetime( |
287 | + cr, uid, ids, {'invoice_datetime': inv.invoice_datetime, |
288 | + 'date_invoice': inv.date_invoice}, |
289 | context=context) |
290 | self.write(cr, uid, ids, vals_date, context=context) |
291 | return super(account_invoice, |
292 | |
293 | === modified file 'invoice_datetime/res_config.py' |
294 | --- invoice_datetime/res_config.py 2014-10-03 07:19:35 +0000 |
295 | +++ invoice_datetime/res_config.py 2014-11-11 22:10:57 +0000 |
296 | @@ -31,29 +31,45 @@ |
297 | |
298 | _columns = { |
299 | 'groups_id': fields.many2one('res.groups', 'Category',), |
300 | - 'select_date': fields.selection([('date', 'Date'), ('datetime', 'Datetime')], string="Default date of invoices", help="Select the field you want to displayed in the invoice for the selected company."), |
301 | + 'select_date': fields.selection([('date', 'Date'), ( |
302 | + 'datetime', 'Datetime')], |
303 | + string="Default date of invoices", |
304 | + help="Select the field you want to displayed in the \ |
305 | + invoice for the selected company."), |
306 | } |
307 | |
308 | def get_default_select_date(self, cr, uid, fields_name, context=None): |
309 | - key_by_company_id = "acc_invoice.date_invoice_type_" + str(self._default_company(cr, uid)) |
310 | - type_show_date = self.pool.get("ir.config_parameter").get_param(cr, uid, key_by_company_id, default='date', context=context) |
311 | + key_by_company_id = "acc_invoice.date_invoice_type_" + str( |
312 | + self._default_company(cr, uid)) |
313 | + type_show_date = self.pool.get("ir.config_parameter").get_param( |
314 | + cr, uid, key_by_company_id, default='date', context=context) |
315 | return {'select_date': type_show_date} |
316 | |
317 | def set_default_select_date(self, cr, uid, ids, context=None): |
318 | """ set default sale and purchase taxes for products """ |
319 | - if uid != SUPERUSER_ID and not self.pool['res.users'].has_group(cr, uid, 'base.group_erp_manager'): |
320 | - raise openerp.exceptions.AccessError(_("Only administrators can change the settings")) |
321 | + if uid != SUPERUSER_ID and not self.pool['res.users'].has_group( |
322 | + cr, uid, 'base.group_erp_manager'): |
323 | + raise openerp.exceptions.AccessError( |
324 | + _("Only administrators can change the settings")) |
325 | config_parameters = self.pool.get("ir.config_parameter") |
326 | for record in self.browse(cr, uid, ids, context=context): |
327 | - company_id = str(record.company_id and record.company_id.id or self._default_company(cr, uid)) |
328 | + company_id = str(record.company_id and |
329 | + record.company_id.id or |
330 | + self._default_company(cr, uid)) |
331 | key_by_company_id = "acc_invoice.date_invoice_type_" + company_id |
332 | - config_parameters.set_param(cr, uid, key_by_company_id, record.select_date or '', context=context) |
333 | + config_parameters.set_param( |
334 | + cr, uid, key_by_company_id, record.select_date or '', |
335 | + context=context) |
336 | |
337 | def onchange_company_id(self, cr, uid, ids, company_id, context=None): |
338 | - result = super(account_config_settings, self).onchange_company_id(cr, uid, ids, company_id, context=context) |
339 | + result = super(account_config_settings, self).onchange_company_id( |
340 | + cr, uid, ids, company_id, context=context) |
341 | type_date = False |
342 | type_date = result.get('value', {}) |
343 | - key_by_company_id = "acc_invoice.date_invoice_type_" + str(company_id or self._default_company(cr, uid)) |
344 | - type_date['select_date'] = self.pool.get("ir.config_parameter").get_param(cr, uid, key_by_company_id, default='date', context=context) |
345 | + key_by_company_id = "acc_invoice.date_invoice_type_" + str( |
346 | + company_id or self._default_company(cr, uid)) |
347 | + type_date['select_date'] = self.pool.get( |
348 | + "ir.config_parameter").get_param( |
349 | + cr, uid, key_by_company_id, default='date', context=context) |
350 | result.update({'value': type_date}) |
351 | return result |
352 | |
353 | === modified file 'invoice_datetime/tests/__init__.py' |
354 | --- invoice_datetime/tests/__init__.py 2014-09-02 23:17:12 +0000 |
355 | +++ invoice_datetime/tests/__init__.py 2014-11-11 22:10:57 +0000 |
356 | @@ -25,7 +25,3 @@ |
357 | # |
358 | |
359 | from . import test_invoice_datetime |
360 | - |
361 | -fast_suite = [ |
362 | - test_invoice_datetime |
363 | -] |
364 | |
365 | === modified file 'invoice_datetime/tests/test_invoice_datetime.py' |
366 | --- invoice_datetime/tests/test_invoice_datetime.py 2014-10-07 21:42:33 +0000 |
367 | +++ invoice_datetime/tests/test_invoice_datetime.py 2014-11-11 22:10:57 +0000 |
368 | @@ -25,13 +25,7 @@ |
369 | # |
370 | |
371 | from openerp.tests.common import TransactionCase |
372 | -from openerp.exceptions import AccessError |
373 | -from openerp.osv.orm import except_orm |
374 | -from openerp import SUPERUSER_ID |
375 | -import mock |
376 | -from openerp.addons.invoice_datetime.invoice import account_invoice |
377 | from openerp.tools import mute_logger |
378 | -import pytz |
379 | import time |
380 | import datetime |
381 | import logging |
382 | @@ -49,37 +43,46 @@ |
383 | cr, uid = self.cr, self.uid |
384 | # get datetime of server in string |
385 | dt_server = time.strftime('%Y-%m-%d %H:%M:%S') |
386 | - # I generate object of type datetime to send at function _get_datetime_with_user_tz |
387 | + # I generate object of type datetime |
388 | + # to send at function _get_datetime_with_user_tz |
389 | datetime_object = datetime.datetime.strptime(dt_server, |
390 | '%Y-%m-%d %H:%M:%S') |
391 | # create list with tz to apply in datetime |
392 | - self.user.write(cr, uid, uid, {'tz': 'Europe/Rome'}) #Assign tz to user |
393 | - #call the function _get_datetime_with_user_tz to get the date with tz applied |
394 | - datetime_tz_rome = self.invoice._get_datetime_with_user_tz(cr, uid, |
395 | - datetime_object) |
396 | + self.user.write(cr, uid, uid, {'tz': 'Europe/Rome'}) |
397 | + # Assign tz to user |
398 | + # call the function _get_datetime_with_user_tz |
399 | + # to get the date with tz applied |
400 | + datetime_tz_rome = self.invoice._get_datetime_with_user_tz( |
401 | + cr, uid, datetime_object) |
402 | # Create an invoice with last tz of cycle America/Mexico_City |
403 | - invoice_tz_rome_id = self.invoice.create(cr, uid, { |
404 | - 'partner_id':1, |
405 | - 'account_id':1, |
406 | - 'invoice_datetime': dt_server}) |
407 | - self.user.write(cr, uid, uid, {'tz': 'America/Mexico_City'}) #Assign tz to user |
408 | - datetime_tz_mx = self.invoice._get_datetime_with_user_tz(cr, uid, |
409 | - datetime_object) |
410 | - invoice_tz_mx_id = self.invoice.create(cr, uid, { |
411 | - 'partner_id':1, |
412 | - 'account_id':1, |
413 | - 'invoice_datetime': dt_server}) |
414 | - dt_inv_tz_rome = self.invoice.read(cr, uid, invoice_tz_rome_id, []).get('date_invoice_tz') |
415 | - dt_inv_tz_mx = self.invoice.read(cr, uid, invoice_tz_mx_id, []).get('date_invoice_tz') |
416 | + invoice_tz_rome_id = self.invoice.create( |
417 | + cr, uid, |
418 | + {'partner_id': 1, |
419 | + 'account_id': 1, |
420 | + 'invoice_datetime': dt_server}) |
421 | + self.user.write(cr, uid, uid, {'tz': 'America/Mexico_City'}) |
422 | + # Assign tz to user |
423 | + datetime_tz_mx = self.invoice._get_datetime_with_user_tz( |
424 | + cr, uid, datetime_object) |
425 | + invoice_tz_mx_id = self.invoice.create( |
426 | + cr, uid, |
427 | + {'partner_id': 1, |
428 | + 'account_id': 1, |
429 | + 'invoice_datetime': dt_server}) |
430 | + dt_inv_tz_rome = self.invoice.read( |
431 | + cr, uid, invoice_tz_rome_id, []).get('date_invoice_tz') |
432 | + dt_inv_tz_mx = self.invoice.read( |
433 | + cr, uid, invoice_tz_mx_id, []).get('date_invoice_tz') |
434 | _logger.info("Validate datetime of function, for Rome-Mexico_City TZ") |
435 | - self.assertNotEqual(datetime_tz_rome, |
436 | - datetime_tz_mx, 'Dates are equal, should be different') |
437 | + self.assertNotEqual( |
438 | + datetime_tz_rome, |
439 | + datetime_tz_mx, 'Dates are equal, should be different') |
440 | _logger.info("Validate datetime of function versus invoice datetime") |
441 | self.assertEquals(datetime_tz_rome, dt_inv_tz_rome, |
442 | - 'Date calculated and date of invoice are not equals') |
443 | + 'Date calculated and date of invoice are not equals') |
444 | self.assertEquals(datetime_tz_mx, dt_inv_tz_mx, |
445 | - 'Date calculated and date of invoice are not equals') |
446 | + 'Date calculated and date of invoice are not equals') |
447 | _logger.info("Validate invoice datetime, for Rome-Mexico_City TZ") |
448 | - self.assertNotEqual(dt_inv_tz_rome, |
449 | - dt_inv_tz_mx, 'Dates are equal, must be different on invoices') |
450 | - |
451 | + self.assertNotEqual( |
452 | + dt_inv_tz_rome, |
453 | + dt_inv_tz_mx, 'Dates are equal, must be different on invoices') |
Probado en local y funciona correctamente