Merge lp:~akretion-team/openobject-addons/addons-mxdatetime-free into lp:openobject-addons
- addons-mxdatetime-free
- Merge into trunk
Proposed by
Raphaël Valyi - http://www.akretion.com
Status: | Merged |
---|---|
Merged at revision: | 3144 |
Proposed branch: | lp:~akretion-team/openobject-addons/addons-mxdatetime-free |
Merge into: | lp:openobject-addons |
Diff against target: |
295 lines (+32/-41) 12 files modified
account/account.py (+13/-13) account/account_bank_statement.py (+0/-4) account/account_move_line.py (+2/-3) account/invoice.py (+0/-2) account/report/general_ledger.py (+0/-1) account/report/general_ledger_landscape.py (+0/-1) hr/hr.py (+0/-4) purchase/purchase.py (+3/-2) sale/sale.py (+4/-3) stock/report/product_stock.py (+4/-3) stock/report/stock_graph.py (+0/-1) stock/stock.py (+6/-4) |
To merge this branch: | bzr merge lp:~akretion-team/openobject-addons/addons-mxdatetime-free |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email: mp+20342@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote : | # |
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote : | # |
Merged. Thanks.
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote : | # |
Thank you too!
On Fri, Mar 5, 2010 at 6:45 AM, Xavier (Open ERP) <email address hidden> wrote:
> Merged. Thanks.
> --
>
> https:/
> You proposed lp:~akretion-team/openobject-addons/addons-mxdatetime-free for
> merging.
>
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote : | # |
More is coming then...
2010/3/5 Raphaël Valyi <email address hidden>
> Thank you too!
>
>
> On Fri, Mar 5, 2010 at 6:45 AM, Xavier (Open ERP) <email address hidden> wrote:
>
>> Merged. Thanks.
>> --
>>
>> https:/
>> You proposed lp:~akretion-team/openobject-addons/addons-mxdatetime-free
>> for merging.
>>
>
>
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'account/account.py' |
2 | --- account/account.py 2010-02-24 10:55:29 +0000 |
3 | +++ account/account.py 2010-03-01 05:35:23 +0000 |
4 | @@ -27,8 +27,8 @@ |
5 | from tools.misc import currency |
6 | from tools.translate import _ |
7 | import pooler |
8 | -import mx.DateTime |
9 | -from mx.DateTime import RelativeDateTime, now, DateTime, localtime |
10 | +from datetime import datetime |
11 | +from dateutil.relativedelta import relativedelta |
12 | |
13 | from tools import config |
14 | |
15 | @@ -48,7 +48,7 @@ |
16 | |
17 | def compute(self, cr, uid, id, value, date_ref=False, context={}): |
18 | if not date_ref: |
19 | - date_ref = now().strftime('%Y-%m-%d') |
20 | + date_ref = datetime.now().strftime('%Y-%m-%d') |
21 | pt = self.browse(cr, uid, id, context) |
22 | amount = value |
23 | result = [] |
24 | @@ -60,11 +60,11 @@ |
25 | elif line.value == 'balance': |
26 | amt = round(amount, int(config['price_accuracy'])) |
27 | if amt: |
28 | - next_date = mx.DateTime.strptime(date_ref, '%Y-%m-%d') + RelativeDateTime(days=line.days) |
29 | + next_date = datetime.strptime(date_ref, '%y-%m-%d') + relativedelta(days=line.days) |
30 | if line.days2 < 0: |
31 | - next_date += RelativeDateTime(day=line.days2) |
32 | + next_date += relativedelta(day=line.days2) |
33 | if line.days2 > 0: |
34 | - next_date += RelativeDateTime(day=line.days2, months=1) |
35 | + next_date += relativedelta(day=line.days2, months=1) |
36 | result.append( (next_date.strftime('%Y-%m-%d'), amt) ) |
37 | amount -= amt |
38 | return result |
39 | @@ -582,12 +582,12 @@ |
40 | |
41 | def create_period(self,cr, uid, ids, context={}, interval=1): |
42 | for fy in self.browse(cr, uid, ids, context): |
43 | - ds = mx.DateTime.strptime(fy.date_start, '%Y-%m-%d') |
44 | + ds = datetime.strptime(fy.date_start, '%Y-%m-%d') |
45 | while ds.strftime('%Y-%m-%d')<fy.date_stop: |
46 | - de = ds + RelativeDateTime(months=interval, days=-1) |
47 | + de = ds + relativedelta(months=interval, days=-1) |
48 | |
49 | if de.strftime('%Y-%m-%d')>fy.date_stop: |
50 | - de=mx.DateTime.strptime(fy.date_stop, '%Y-%m-%d') |
51 | + de = datetime.strptime(fy.date_stop, '%Y-%m-%d') |
52 | |
53 | self.pool.get('account.period').create(cr, uid, { |
54 | 'name': ds.strftime('%m/%Y'), |
55 | @@ -596,7 +596,7 @@ |
56 | 'date_stop': de.strftime('%Y-%m-%d'), |
57 | 'fiscalyear_id': fy.id, |
58 | }) |
59 | - ds = ds + RelativeDateTime(months=interval) |
60 | + ds = ds + relativedelta(months=interval) |
61 | return True |
62 | |
63 | def find(self, cr, uid, dt=None, exception=True, context={}): |
64 | @@ -1720,11 +1720,11 @@ |
65 | 'subscription_id': sub.id, |
66 | }) |
67 | if sub.period_type=='day': |
68 | - ds = (mx.DateTime.strptime(ds, '%Y-%m-%d') + RelativeDateTime(days=sub.period_nbr)).strftime('%Y-%m-%d') |
69 | + ds = (datetime.strptime(ds, '%Y-%m-%d') + relativedelta(days=sub.period_nbr)).strftime('%Y-%m-%d') |
70 | if sub.period_type=='month': |
71 | - ds = (mx.DateTime.strptime(ds, '%Y-%m-%d') + RelativeDateTime(months=sub.period_nbr)).strftime('%Y-%m-%d') |
72 | + ds = (datetime.strptime(ds, '%Y-%m-%d') + relativedelta(months=sub.period_nbr)).strftime('%Y-%m-%d') |
73 | if sub.period_type=='year': |
74 | - ds = (mx.DateTime.strptime(ds, '%Y-%m-%d') + RelativeDateTime(years=sub.period_nbr)).strftime('%Y-%m-%d') |
75 | + ds = (datetime.strptime(ds, '%Y-%m-%d') + relativedelta(years=sub.period_nbr)).strftime('%Y-%m-%d') |
76 | self.write(cr, uid, ids, {'state':'running'}) |
77 | return True |
78 | account_subscription() |
79 | |
80 | === modified file 'account/account_bank_statement.py' |
81 | --- account/account_bank_statement.py 2010-02-24 10:55:29 +0000 |
82 | +++ account/account_bank_statement.py 2010-03-01 05:35:23 +0000 |
83 | @@ -26,10 +26,6 @@ |
84 | from tools.misc import currency |
85 | from tools.translate import _ |
86 | |
87 | -import mx.DateTime |
88 | -from mx.DateTime import RelativeDateTime, now, DateTime, localtime |
89 | - |
90 | - |
91 | class account_bank_statement(osv.osv): |
92 | def _default_journal_id(self, cr, uid, context={}): |
93 | if context.get('journal_id', False): |
94 | |
95 | === modified file 'account/account_move_line.py' |
96 | --- account/account_move_line.py 2010-02-24 10:55:29 +0000 |
97 | +++ account/account_move_line.py 2010-03-01 05:35:23 +0000 |
98 | @@ -24,8 +24,7 @@ |
99 | from osv import fields, osv |
100 | from tools.translate import _ |
101 | |
102 | -import mx.DateTime |
103 | -from mx.DateTime import RelativeDateTime, now, DateTime, localtime |
104 | +from datetime import datetime |
105 | |
106 | import tools |
107 | |
108 | @@ -485,7 +484,7 @@ |
109 | if not partner_id: |
110 | return {'value':val} |
111 | if not date: |
112 | - date = now().strftime('%Y-%m-%d') |
113 | + date = datetime.now().strftime('%Y-%m-%d') |
114 | part = self.pool.get('res.partner').browse(cr, uid, partner_id) |
115 | |
116 | if part.property_payment_term and part.property_payment_term.line_ids: |
117 | |
118 | === modified file 'account/invoice.py' |
119 | --- account/invoice.py 2010-02-24 10:55:29 +0000 |
120 | +++ account/invoice.py 2010-03-01 05:35:23 +0000 |
121 | @@ -24,8 +24,6 @@ |
122 | from osv import fields, osv |
123 | import ir |
124 | import pooler |
125 | -import mx.DateTime |
126 | -from mx.DateTime import RelativeDateTime |
127 | from tools import config |
128 | from tools.translate import _ |
129 | |
130 | |
131 | === modified file 'account/report/general_ledger.py' |
132 | --- account/report/general_ledger.py 2010-02-24 10:55:29 +0000 |
133 | +++ account/report/general_ledger.py 2010-03-01 05:35:23 +0000 |
134 | @@ -25,7 +25,6 @@ |
135 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
136 | |
137 | import time |
138 | -from mx.DateTime import * |
139 | from report import report_sxw |
140 | import xml |
141 | import rml_parse |
142 | |
143 | === modified file 'account/report/general_ledger_landscape.py' |
144 | --- account/report/general_ledger_landscape.py 2010-02-24 10:55:29 +0000 |
145 | +++ account/report/general_ledger_landscape.py 2010-03-01 05:35:23 +0000 |
146 | @@ -27,7 +27,6 @@ |
147 | ############################################################################## |
148 | |
149 | import time |
150 | -from mx.DateTime import * |
151 | from report import report_sxw |
152 | import xml |
153 | import rml_parse |
154 | |
155 | === modified file 'hr/hr.py' |
156 | --- hr/hr.py 2010-02-28 19:46:55 +0000 |
157 | +++ hr/hr.py 2010-03-01 05:35:23 +0000 |
158 | @@ -19,10 +19,6 @@ |
159 | # |
160 | ############################################################################## |
161 | |
162 | -from mx import DateTime |
163 | -import time |
164 | -import math |
165 | - |
166 | from osv import fields, osv |
167 | from tools.translate import _ |
168 | |
169 | |
170 | === modified file 'purchase/purchase.py' |
171 | --- purchase/purchase.py 2010-02-24 10:55:29 +0000 |
172 | +++ purchase/purchase.py 2010-03-01 05:35:23 +0000 |
173 | @@ -25,7 +25,8 @@ |
174 | import netsvc |
175 | |
176 | import ir |
177 | -from mx import DateTime |
178 | +from datetime import datetime |
179 | +from dateutil.relativedelta import relativedelta |
180 | import pooler |
181 | from tools import config |
182 | from tools.translate import _ |
183 | @@ -518,7 +519,7 @@ |
184 | 'uom': uom, |
185 | 'date': date_order, |
186 | })[pricelist] |
187 | - dt = (DateTime.now() + DateTime.RelativeDateTime(days=seller_delay or 0.0)).strftime('%Y-%m-%d %H:%M:%S') |
188 | + dt = (datetime.now() + relativedelta(days=seller_delay or 0.0)).strftime('%Y-%m-%d %H:%M:%S') |
189 | prod_name = self.pool.get('product.product').name_get(cr, uid, [prod.id])[0][1] |
190 | |
191 | |
192 | |
193 | === modified file 'sale/sale.py' |
194 | --- sale/sale.py 2010-02-24 10:55:29 +0000 |
195 | +++ sale/sale.py 2010-03-01 05:35:23 +0000 |
196 | @@ -22,7 +22,8 @@ |
197 | import time |
198 | import netsvc |
199 | from osv import fields, osv |
200 | -from mx import DateTime |
201 | +from datetime import datetime |
202 | +from dateutil.relativedelta import relativedelta |
203 | from tools import config |
204 | from tools.translate import _ |
205 | |
206 | @@ -581,8 +582,8 @@ |
207 | picking_id = False |
208 | for line in order.order_line: |
209 | proc_id = False |
210 | - date_planned = DateTime.now() + DateTime.DateTimeDeltaFromDays(line.delay or 0.0) |
211 | - date_planned = (date_planned - DateTime.DateTimeDeltaFromDays(company.security_lead)).strftime('%Y-%m-%d %H:%M:%S') |
212 | + date_planned = datetime.now() + relativedelta(days=line.delay or 0.0) |
213 | + date_planned = (date_planned - relativedelta(company.security_lead)).strftime('%Y-%m-%d %H:%M:%S') |
214 | if line.state == 'done': |
215 | continue |
216 | if line.product_id and line.product_id.product_tmpl_id.type in ('product', 'consu'): |
217 | |
218 | === modified file 'stock/report/product_stock.py' |
219 | --- stock/report/product_stock.py 2010-02-24 10:55:29 +0000 |
220 | +++ stock/report/product_stock.py 2010-03-01 05:35:23 +0000 |
221 | @@ -19,7 +19,8 @@ |
222 | # |
223 | ############################################################################## |
224 | |
225 | -from mx import DateTime |
226 | +from datetime import datetime |
227 | +from dateutil.relativedelta import relativedelta |
228 | |
229 | import osv |
230 | import time |
231 | @@ -76,7 +77,7 @@ |
232 | "group by date_planned,product_id",(('confirmed','assigned','waiting'),loc_ids ,product_ids,)) |
233 | for (qty, dt, prod_id) in cr.fetchall(): |
234 | if dt<=dt_from: |
235 | - dt= (DateTime.now() + DateTime.RelativeDateTime(days=1)).strftime('%Y-%m-%d') |
236 | + dt= (datetime.now() + relativedelta(days=1)).strftime('%Y-%m-%d') |
237 | else: |
238 | dt = dt[:10] |
239 | products.setdefault(prod_id, []) |
240 | @@ -91,7 +92,7 @@ |
241 | |
242 | for (qty, dt, prod_id) in cr.fetchall(): |
243 | if dt<=dt_from: |
244 | - dt= (DateTime.now() + DateTime.RelativeDateTime(days=1)).strftime('%Y-%m-%d') |
245 | + dt= (datetime.now() + relativedelta(days=1)).strftime('%Y-%m-%d') |
246 | else: |
247 | dt = dt[:10] |
248 | products.setdefault(prod_id, []) |
249 | |
250 | === modified file 'stock/report/stock_graph.py' |
251 | --- stock/report/stock_graph.py 2010-02-24 10:55:29 +0000 |
252 | +++ stock/report/stock_graph.py 2010-03-01 05:35:23 +0000 |
253 | @@ -18,7 +18,6 @@ |
254 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
255 | # |
256 | ############################################################################## |
257 | -from mx.DateTime import * |
258 | from pychart import * |
259 | import pychart.legend |
260 | import time |
261 | |
262 | === modified file 'stock/stock.py' |
263 | --- stock/stock.py 2010-02-24 12:50:18 +0000 |
264 | +++ stock/stock.py 2010-03-01 05:35:23 +0000 |
265 | @@ -19,7 +19,9 @@ |
266 | # |
267 | ############################################################################## |
268 | |
269 | -from mx import DateTime |
270 | +from datetime import datetime |
271 | +from dateutil.relativedelta import relativedelta |
272 | + |
273 | from osv import fields, osv |
274 | from tools import config |
275 | from tools.translate import _ |
276 | @@ -1169,8 +1171,8 @@ |
277 | if dest: |
278 | if dest[1] == 'transparent': |
279 | self.write(cr, uid, [m.id], { |
280 | - 'date_planned': (DateTime.strptime(m.date_planned, '%Y-%m-%d %H:%M:%S') + \ |
281 | - DateTime.RelativeDateTime(days=dest[2] or 0)).strftime('%Y-%m-%d'), |
282 | + 'date_planned': (datetime.strptime(m.date_planned, '%Y-%m-%d %H:%M:%S') + \ |
283 | + relativedelta(days=dest[2] or 0)).strftime('%Y-%m-%d'), |
284 | 'location_dest_id': dest[0].id}) |
285 | else: |
286 | result.setdefault(m.picking_id, []) |
287 | @@ -1206,7 +1208,7 @@ |
288 | 'picking_id': pickid, |
289 | 'state': 'waiting', |
290 | 'move_history_ids': [], |
291 | - 'date_planned': (DateTime.strptime(move.date_planned, '%Y-%m-%d %H:%M:%S') + DateTime.RelativeDateTime(days=delay or 0)).strftime('%Y-%m-%d'), |
292 | + 'date_planned': (datetime.strptime(move.date_planned, '%Y-%m-%d %H:%M:%S') + relativedelta(days=delay or 0)).strftime('%Y-%m-%d'), |
293 | 'move_history_ids2': []} |
294 | ) |
295 | self.pool.get('stock.move').write(cr, uid, [move.id], { |
Hello,
This branch is the addons equivalent of https:/ /code.launchpad .net/~openerp- commiter/ openobject- server/ server- mxdatetime- free/+merge/ 16099 making our way toward a better OpenERP Python portability, on Jython especially (see https:/ /blueprints. launchpad. net/openobject- server/ +spec/jython- support- as-jython- improves ).
Here I replace mx.DateTime C only usage by pure Python datetime and Labix dateutil equivalents in the following centric modules as a start: wizard/ wizard_ aged_trial_ balance. py which I was not too sure how to refactor).
process, hr, product, account, stock, mrp, sale, purchase.
(on exception is account/
Of course more is required, but it's already a decent step toward better compat. Please merge that first, more might eventually follow from me if I have time (hey folks please help us for that great Jython feature!)
I'm available for any question