diff --git a/addons/account_payment/account_invoice.py b/addons/account_payment/account_invoice.py index 9a45ae29c0b..c05721ce6dc 100644 --- a/addons/account_payment/account_invoice.py +++ b/addons/account_payment/account_invoice.py @@ -19,8 +19,7 @@ # ############################################################################## -from mx import DateTime - +from datetime import datetime from osv import fields, osv class Invoice(osv.osv): @@ -36,8 +35,8 @@ class Invoice(osv.osv): if invoice.move_id: for line in invoice.move_id.line_id: if not line.date_maturity or \ - DateTime.strptime(line.date_maturity, '%Y-%m-%d') \ - < DateTime.now(): + datetime.strptime(line.date_maturity, '%Y-%m-%d') \ + < datetime.today(): res[invoice.id] += line.amount_to_pay return res @@ -50,4 +49,4 @@ class Invoice(osv.osv): Invoice() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auction/report/report_auction.py b/addons/auction/report/report_auction.py index cf1c680c63b..25cdab88e89 100644 --- a/addons/auction/report/report_auction.py +++ b/addons/auction/report/report_auction.py @@ -18,7 +18,6 @@ # along with this program. If not, see . # ############################################################################## -from mx import DateTime from osv import fields, osv, orm from tools import config from tools.translate import _ diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py index 960849bdfd4..098f7e765f0 100644 --- a/addons/hr_evaluation/hr_evaluation.py +++ b/addons/hr_evaluation/hr_evaluation.py @@ -20,8 +20,9 @@ ############################################################################## import time -from mx import DateTime as dt - +from datetime import datetime +from dateutil.relativedelta import relativedelta +from dateutil import parser from osv import fields, osv import tools from tools.translate import _ @@ -109,8 +110,8 @@ class hr_employee(osv.osv): context = {} for id in self.browse(cr, uid, self.search(cr, uid, [], context=context), context=context): if id.evaluation_plan_id and id.evaluation_date: - if (dt.ISO.ParseAny(id.evaluation_date) + dt.RelativeDateTime(months = int(id.evaluation_plan_id.month_next))).strftime('%Y-%m-%d') <= time.strftime("%Y-%m-%d"): - self.write(cr, uid, id.id, {'evaluation_date' : (dt.ISO.ParseAny(id.evaluation_date) + dt.RelativeDateTime(months =+ int(id.evaluation_plan_id.month_next))).strftime('%Y-%m-%d')}, context=context) + if (parser.parse(id.evaluation_date) + relativedelta(months = int(id.evaluation_plan_id.month_next))).strftime('%Y-%m-%d') <= time.strftime("%Y-%m-%d"): + self.write(cr, uid, id.id, {'evaluation_date' : (parser.parse(id.evaluation_date) + relativedelta(months =+ int(id.evaluation_plan_id.month_next))).strftime('%Y-%m-%d')}, context=context) obj_evaluation.create(cr, uid, {'employee_id' : id.id, 'plan_id': id.evaluation_plan_id}, context=context) return True @@ -123,11 +124,11 @@ class hr_employee(osv.osv): flag = False evaluation_plan = evaluation_plan_obj.browse(cr, uid, [evaluation_plan_id], context=context)[0] if not evaluation_date: - evaluation_date=(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d'))+ dt.RelativeDateTime(months=+evaluation_plan.month_first)).strftime('%Y-%m-%d') + evaluation_date=(parser.parse(datetime.date.today().strftime('%Y-%m-%d'))+ relativedelta(months=+evaluation_plan.month_first)).strftime('%Y-%m-%d') flag = True else: - if (dt.ISO.ParseAny(evaluation_date) + dt.RelativeDateTime(months = int(evaluation_plan.month_next))).strftime('%Y-%m-%d') <= time.strftime("%Y-%m-%d"): - evaluation_date=(dt.ISO.ParseAny(evaluation_date)+ dt.RelativeDateTime(months=+evaluation_plan.month_next)).strftime('%Y-%m-%d') + if (parser.parse(evaluation_date) + relativedelta(months = int(evaluation_plan.month_next))).strftime('%Y-%m-%d') <= time.strftime("%Y-%m-%d"): + evaluation_date=(parser.parse(evaluation_date)+ relativedelta(months=+evaluation_plan.month_next)).strftime('%Y-%m-%d') flag = True if ids and flag: obj_evaluation.create(cr, uid, {'employee_id': ids[0], 'plan_id': evaluation_plan_id}, context=context) @@ -174,7 +175,7 @@ class hr_evaluation(osv.osv): 'progress' : fields.float("Progress"), } _defaults = { - 'date' : lambda *a: (dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d')) + dt.RelativeDateTime(months =+ 1)).strftime('%Y-%m-%d'), + 'date' : lambda *a: (parser.parse(datetime.date.today().strftime('%Y-%m-%d')) + relativedelta(months =+ 1)).strftime('%Y-%m-%d'), 'state' : lambda *a: 'draft', } @@ -225,7 +226,7 @@ class hr_evaluation(osv.osv): int_id = hr_eval_inter_obj.create(cr, uid, { 'evaluation_id': evaluation.id, 'survey_id': phase.survey_id.id, - 'date_deadline': (dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d')) + dt.RelativeDateTime(months =+ 1)).strftime('%Y-%m-%d'), + 'date_deadline': (parser.parse(datetime.date.today().strftime('%Y-%m-%d')) + relativedelta(months =+ 1)).strftime('%Y-%m-%d'), 'user_id': child.user_id.id, 'user_to_review_id': evaluation.employee_id.id }, context=context) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 44bda56739f..b152e0112eb 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -23,7 +23,8 @@ import time import netsvc from osv import fields, osv -from mx import DateTime +from datetime import datetime +from dateutil.relativedelta import relativedelta from tools.translate import _ class one2many_mod2(fields.one2many): @@ -210,9 +211,9 @@ class hr_timesheet_sheet(osv.osv): if context is None: context = {} for sheet in self.browse(cr, uid, ids, context=context): - if DateTime.now() <= DateTime.strptime(sheet.date_from, '%Y-%m-%d'): + if datetime.today() <= datetime.strptime(sheet.date_from, '%Y-%m-%d'): self.write(cr, uid, [sheet.id], {'date_current': sheet.date_from,}, context=context) - elif DateTime.now() >= DateTime.strptime(sheet.date_to, '%Y-%m-%d'): + elif datetime.now() >= datetime.strptime(sheet.date_to, '%Y-%m-%d'): self.write(cr, uid, [sheet.id], {'date_current': sheet.date_to,}, context=context) else: self.write(cr, uid, [sheet.id], {'date_current': time.strftime('%Y-%m-%d')}, context=context) @@ -222,11 +223,11 @@ class hr_timesheet_sheet(osv.osv): if context is None: context = {} for sheet in self.browse(cr, uid, ids, context=context): - if DateTime.strptime(sheet.date_current, '%Y-%m-%d') <= DateTime.strptime(sheet.date_from, '%Y-%m-%d'): + if datetime.strptime(sheet.date_current, '%Y-%m-%d') <= datetime.strptime(sheet.date_from, '%Y-%m-%d'): self.write(cr, uid, [sheet.id], {'date_current': sheet.date_from,}, context=context) else: self.write(cr, uid, [sheet.id], { - 'date_current': (DateTime.strptime(sheet.date_current, '%Y-%m-%d') + DateTime.RelativeDateTime(days=-1)).strftime('%Y-%m-%d'), + 'date_current': (datetime.strptime(sheet.date_current, '%Y-%m-%d') + relativedelta(days=-1)).strftime('%Y-%m-%d'), }, context=context) return True @@ -234,11 +235,11 @@ class hr_timesheet_sheet(osv.osv): if context is None: context = {} for sheet in self.browse(cr, uid, ids, context=context): - if DateTime.strptime(sheet.date_current, '%Y-%m-%d') >= DateTime.strptime(sheet.date_to, '%Y-%m-%d'): + if datetime.strptime(sheet.date_current, '%Y-%m-%d') >= datetime.strptime(sheet.date_to, '%Y-%m-%d'): self.write(cr, uid, [sheet.id], {'date_current': sheet.date_to,}, context=context) else: self.write(cr, uid, [sheet.id], { - 'date_current': (DateTime.strptime(sheet.date_current, '%Y-%m-%d') + DateTime.RelativeDateTime(days=1)).strftime('%Y-%m-%d'), + 'date_current': (datetime.strptime(sheet.date_current, '%Y-%m-%d') + relativedelta(days=1)).strftime('%Y-%m-%d'), }, context=context) return True @@ -246,9 +247,9 @@ class hr_timesheet_sheet(osv.osv): if context is None: context = {} for sheet in self.browse(cr, uid, ids, context=context): - if DateTime.strptime(sheet.date_current, '%Y-%m-%d') <= DateTime.strptime(sheet.date_from, '%Y-%m-%d'): + if datetime.strptime(sheet.date_current, '%Y-%m-%d') <= datetime.strptime(sheet.date_from, '%Y-%m-%d'): self.write(cr, uid, [sheet.id], {'date_current': sheet.date_from,}, context=context) - elif DateTime.strptime(sheet.date_current, '%Y-%m-%d') >= DateTime.strptime(sheet.date_to, '%Y-%m-%d'): + elif datetime.strptime(sheet.date_current, '%Y-%m-%d') >= datetime.strptime(sheet.date_to, '%Y-%m-%d'): self.write(cr, uid, [sheet.id], {'date_current': sheet.date_to,}, context=context) return True @@ -318,7 +319,7 @@ class hr_timesheet_sheet(osv.osv): if r=='month': return time.strftime('%Y-%m-01') elif r=='week': - return (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Monday,0))).strftime('%Y-%m-%d') + return (datetime.today() + relativedelta(weekday=0)).strftime('%Y-%m-%d') elif r=='year': return time.strftime('%Y-01-01') return time.strftime('%Y-%m-%d') @@ -327,9 +328,9 @@ class hr_timesheet_sheet(osv.osv): user = self.pool.get('res.users').browse(cr, uid, uid, context=context) r = user.company_id and user.company_id.timesheet_range or 'month' if r=='month': - return (DateTime.now() + DateTime.RelativeDateTime(months=+1,day=1,days=-1)).strftime('%Y-%m-%d') + return (datetime.today() + relativedelta(months=+1,day=1,days=-1)).strftime('%Y-%m-%d') elif r=='week': - return (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Sunday,0))).strftime('%Y-%m-%d') + return (datetime.today() + relativedelta(weekday=6)).strftime('%Y-%m-%d') elif r=='year': return time.strftime('%Y-12-31') return time.strftime('%Y-%m-%d') diff --git a/addons/l10n_ch/invoice.py b/addons/l10n_ch/invoice.py index 1057fc379fd..1f836c4466a 100644 --- a/addons/l10n_ch/invoice.py +++ b/addons/l10n_ch/invoice.py @@ -30,7 +30,7 @@ # ############################################################################## -from mx import DateTime +from datetime import datetime from osv import fields, osv from tools import mod10r @@ -71,8 +71,8 @@ class account_invoice(osv.osv): if invoice.move_id: for line in invoice.move_id.line_id: if not line.date_maturity or \ - DateTime.strptime(line.date_maturity, '%Y-%m-%d') \ - < DateTime.now(): + datetime.strptime(line.date_maturity, '%Y-%m-%d') \ + < datetime.today(): res[invoice.id] += line.amount_to_pay return res @@ -209,4 +209,4 @@ class account_tax_code(osv.osv): account_tax_code() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index 29eb2d3bddf..acc45e48bcf 100644 --- a/addons/mrp/procurement.py +++ b/addons/mrp/procurement.py @@ -19,7 +19,8 @@ # ############################################################################## -from mx import DateTime +from datetime import datetime +from dateutil.relativedelta import relativedelta from osv import fields from osv import osv from tools.translate import _ @@ -81,8 +82,8 @@ class procurement_order(osv.osv): for procurement in procurement_obj.browse(cr, uid, ids): res_id = procurement.move_id.id loc_id = procurement.location_id.id - newdate = DateTime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - DateTime.RelativeDateTime(days=procurement.product_id.product_tmpl_id.produce_delay or 0.0) - newdate = newdate - DateTime.RelativeDateTime(days=company.manufacturing_lead) + newdate = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - relativedelta(days=procurement.product_id.product_tmpl_id.produce_delay or 0.0) + newdate = newdate - relativedelta(days=company.manufacturing_lead) produce_id = production_obj.create(cr, uid, { 'origin': procurement.origin, 'product_id': procurement.product_id.id, diff --git a/addons/point_of_sale/pos.py b/addons/point_of_sale/pos.py index f741522ff97..6429e21c08d 100644 --- a/addons/point_of_sale/pos.py +++ b/addons/point_of_sale/pos.py @@ -22,7 +22,8 @@ import time import netsvc from osv import fields, osv -from mx import DateTime +from datetime import datetime +from dateutil.relativedelta import relativedelta from tools.translate import _ from decimal import Decimal import decimal_precision as dp @@ -337,7 +338,7 @@ class pos_order(osv.osv): 'price_type': lambda *a: 'tax_excluded', 'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'pos.order'), 'date_order': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), - 'date_validity': lambda *a: (DateTime.now() + DateTime.RelativeDateTime(months=+6)).strftime('%Y-%m-%d'), + 'date_validity': lambda *a: (datetime.today() + relativedelta(months=+6)).strftime('%Y-%m-%d'), 'nb_print': lambda *a: 0, 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, 'sale_journal': _sale_journal_get, diff --git a/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py b/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py index 93c25d62e96..58f78902a14 100644 --- a/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py +++ b/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py @@ -22,7 +22,6 @@ import netsvc from osv import osv,fields from tools.translate import _ -from mx import DateTime import time class all_closed_cashbox_of_the_day(osv.osv_memory): diff --git a/addons/point_of_sale/wizard/pos_box_out.py b/addons/point_of_sale/wizard/pos_box_out.py index 92e7dded432..e4aebe2cc1d 100644 --- a/addons/point_of_sale/wizard/pos_box_out.py +++ b/addons/point_of_sale/wizard/pos_box_out.py @@ -22,7 +22,8 @@ from osv import osv, fields import time from tools.translate import _ -from mx import DateTime +from datetime import datetime +from dateutil.relativedelta import relativedelta import pos_box_entries @@ -78,8 +79,8 @@ class pos_box_out(osv.osv_memory): for data in self.read(cr, uid, ids): curr_company = res_obj.browse(cr, uid, uid).company_id.id statement_id = statement_obj.search(cr, uid, [('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid), ('state', '=', 'open')]) - monday = (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Monday, 0))).strftime('%Y-%m-%d') - sunday = (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Sunday, 0))).strftime('%Y-%m-%d') + monday = (datetime.today() + relativedelta(weekday=0)).strftime('%Y-%m-%d') + sunday = (datetime.today() + relativedelta(weekday=6)).strftime('%Y-%m-%d') done_statmt = statement_obj.search(cr, uid, [('date', '>=', monday+' 00:00:00'), ('date', '<=', sunday+' 23:59:59'), ('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid)]) stat_done = statement_obj.browse(cr, uid, done_statmt) address_u = res_obj.browse(cr, uid, uid).address_id diff --git a/addons/procurement/schedulers.py b/addons/procurement/schedulers.py index 1a1222ffa7b..b3d3c3bb98d 100644 --- a/addons/procurement/schedulers.py +++ b/addons/procurement/schedulers.py @@ -20,8 +20,8 @@ ############################################################################## import time -from mx import DateTime - +from datetime import datetime +from dateutil.relativedelta import relativedelta from osv import osv from tools.translate import _ import tools @@ -59,7 +59,7 @@ class procurement_order(osv.osv): if use_new_cursor: cr.commit() company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id - maxdate = (DateTime.now() + DateTime.RelativeDateTime(days=company.schedule_range)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT) + maxdate = (datetime.today() + relativedelta(days=company.schedule_range)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT) start_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss') offset = 0 report = [] @@ -166,7 +166,7 @@ class procurement_order(osv.osv): if product.virtual_available >= 0.0: continue - newdate = DateTime.now() + newdate = datetime.today() if product.supply_method == 'buy': location_id = warehouse.lot_input_id.id elif product.supply_method == 'produce': @@ -228,7 +228,7 @@ class procurement_order(osv.osv): reste = qty % op.qty_multiple if reste > 0: qty += op.qty_multiple - reste - newdate = DateTime.now() + DateTime.RelativeDateTime( + newdate = datetime.today() + relativedelta( days = int(op.product_id.seller_delay)) if qty <= 0: continue diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 655e74a74a8..18f341399c3 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -19,7 +19,6 @@ # ############################################################################## -from mx import DateTime import time from datetime import datetime from dateutil.relativedelta import relativedelta @@ -765,9 +764,8 @@ class procurement_order(osv.osv): price = pricelist_obj.price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, False, {'uom': uom_id})[pricelist_id] - newdate = DateTime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead) - newdate = newdate - seller_delay + newdate = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') + newdate = (newdate - relativedelta(days=company.po_lead)) - relativedelta(days=seller_delay) #Passing partner_id to context for purchase order line integrity of Line name context.update({'lang': partner.lang, 'partner_id': partner_id}) diff --git a/addons/purchase_requisition/wizard/purchase_requisition_partner.py b/addons/purchase_requisition/wizard/purchase_requisition_partner.py index 297286ce472..2ae3ae795e9 100644 --- a/addons/purchase_requisition/wizard/purchase_requisition_partner.py +++ b/addons/purchase_requisition/wizard/purchase_requisition_partner.py @@ -20,8 +20,8 @@ ############################################################################## import time -from mx import DateTime - +from datetime import datetime +from dateutil.relativedelta import relativedelta from osv import fields, osv from osv.orm import browse_record, browse_null @@ -84,10 +84,10 @@ class purchase_requisition_partner(osv.osv_memory): partner_list = sorted([(partner.sequence, partner) for partner in line.product_id.seller_ids if partner]) partner_rec = partner_list and partner_list[0] and partner_list[0][1] or False uom_id = line.product_id.uom_po_id and line.product_id.uom_po_id.id or False - newdate = DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') - newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead) + newdate = datetime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') + newdate = newdate - relativedelta(days=company.po_lead) delay = partner_rec and partner_rec.delay or False - newdate = newdate -(delay or DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') ) + newdate = newdate -(delay or datetime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') ) partner = partner_rec and partner_rec.name or supplier_data pricelist_id = partner.property_product_pricelist_purchase and partner.property_product_pricelist_purchase.id or False price = pricelist_obj.price_get(cr, uid, [pricelist_id], line.product_id.id, line.product_qty, False, {'uom': uom_id})[pricelist_id] diff --git a/addons/resource/resource.py b/addons/resource/resource.py index 24efc179c03..5401c052dce 100644 --- a/addons/resource/resource.py +++ b/addons/resource/resource.py @@ -20,7 +20,6 @@ ############################################################################## from datetime import datetime, timedelta -from mx import DateTime import math from faces import * from new import classobj @@ -113,7 +112,7 @@ class resource_calendar(osv.osv): results = {} for d, hours, id in date_and_hours_by_cal: - dt_from = DateTime.strptime(d, '%Y-%m-%d %H:%M:%S') + dt_from = datetime.strptime(d, '%Y-%m-%d %H:%M:%S') if not id: td = int(hours)*3 results[(d, hours, id)] = [(dt_from, dt_from + timedelta(hours=td))] diff --git a/addons/subscription/subscription.py b/addons/subscription/subscription.py index 307f06c6f91..ef959a5fd67 100644 --- a/addons/subscription/subscription.py +++ b/addons/subscription/subscription.py @@ -22,7 +22,6 @@ # TODO: # Error treatment: exception, request, ... -> send request to user_id -from mx import DateTime import time from osv import fields,osv from tools.translate import _