[REMOVE]: mx.Date from trunk
bzr revid: aag@tinyerp.co.in-20100929080501-j7hqsb3qfftp6qbo
This commit is contained in:
parent
3833852f93
commit
7b2e3875b1
|
@ -20,9 +20,8 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
import datetime
|
||||
import mx.DateTime
|
||||
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import pooler
|
||||
import tools
|
||||
from osv import fields,osv
|
||||
|
@ -128,13 +127,13 @@ class report_aged_receivable(osv.osv):
|
|||
LIST_RANGES = []
|
||||
if fy_id:
|
||||
fy_start_date = pool_obj_fy.read(cr, uid, fy_id, ['date_start'])['date_start']
|
||||
fy_start_date = mx.DateTime.strptime(fy_start_date, '%Y-%m-%d')
|
||||
last_month_date = mx.DateTime.strptime(today, '%Y-%m-%d') - mx.DateTime.RelativeDateTime(months=1)
|
||||
fy_start_date = datetime.strptime(fy_start_date, '%Y-%m-%d')
|
||||
last_month_date = datetime.strptime(today, '%Y-%m-%d') - relativedelta(months=1)
|
||||
|
||||
while (last_month_date > fy_start_date):
|
||||
LIST_RANGES.append(today + " to " + last_month_date.strftime('%Y-%m-%d'))
|
||||
today = (last_month_date- 1).strftime('%Y-%m-%d')
|
||||
last_month_date = mx.DateTime.strptime(today, '%Y-%m-%d') - mx.DateTime.RelativeDateTime(months=1)
|
||||
last_month_date = datetime.strptime(today, '%Y-%m-%d') - relativedelta(months=1)
|
||||
|
||||
LIST_RANGES.append(today +" to " + fy_start_date.strftime('%Y-%m-%d'))
|
||||
cr.execute('delete from temp_range')
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
import datetime
|
||||
from mx.DateTime import *
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from lxml import etree
|
||||
|
||||
from osv import osv, fields
|
||||
|
@ -69,26 +69,26 @@ class account_aged_trial_balance(osv.osv_memory):
|
|||
if not data['form']['date_from']:
|
||||
raise osv.except_osv(_('UserError'), _('Enter a Start date !'))
|
||||
|
||||
start = datetime.date.fromtimestamp(time.mktime(time.strptime(data['form']['date_from'], "%Y-%m-%d")))
|
||||
start = DateTime(int(start.year), int(start.month), int(start.day))
|
||||
start = datetime.strptime(data['form']['date_from'], "%Y-%m-%d")
|
||||
|
||||
if data['form']['direction_selection'] == 'past':
|
||||
for i in range(5)[::-1]:
|
||||
stop = start - RelativeDateTime(days=period_length)
|
||||
stop = start - relativedelta(days=period_length)
|
||||
res[str(i)] = {
|
||||
'name': (i!=0 and (str((5-(i+1)) * period_length) + '-' + str((5-i) * period_length)) or ('+'+str(4 * period_length))),
|
||||
'stop': start.strftime('%Y-%m-%d'),
|
||||
'start': (i!=0 and stop.strftime('%Y-%m-%d') or False),
|
||||
}
|
||||
start = stop - RelativeDateTime(days=1)
|
||||
start = stop - relativedelta(days=1)
|
||||
else:
|
||||
for i in range(5):
|
||||
stop = start + RelativeDateTime(days=period_length)
|
||||
stop = start + relativedelta(days=period_length)
|
||||
res[str(5-(i+1))] = {
|
||||
'name' : (i!=4 and str((i) * period_length)+'-' + str((i+1) * period_length) or ('+'+str(4 * period_length))),
|
||||
'start': start.strftime('%Y-%m-%d'),
|
||||
'stop': (i!=4 and stop.strftime('%Y-%m-%d') or False),
|
||||
}
|
||||
start = stop + RelativeDateTime(days=1)
|
||||
start = stop + relativedelta(days=1)
|
||||
data['form'].update(res)
|
||||
|
||||
return {
|
||||
|
|
|
@ -26,9 +26,6 @@ import pooler
|
|||
from tools.misc import currency
|
||||
from tools.translate import _
|
||||
|
||||
import mx.DateTime
|
||||
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
|
||||
|
||||
|
||||
class account_report(osv.osv):
|
||||
_name = "account.report.report"
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#
|
||||
##############################################################################
|
||||
import time
|
||||
from mx.DateTime import *
|
||||
import os
|
||||
import base64
|
||||
import StringIO
|
||||
|
|
|
@ -24,9 +24,6 @@ from osv import fields, osv
|
|||
|
||||
from tools.misc import currency
|
||||
|
||||
import mx.DateTime
|
||||
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
|
||||
|
||||
|
||||
class color_rml(osv.osv):
|
||||
_name = "color.rml"
|
||||
|
|
|
@ -23,7 +23,6 @@ from base_calendar import base_calendar
|
|||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
import tools
|
||||
import mx.DateTime
|
||||
import re
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ from osv import fields, osv
|
|||
from datetime import datetime
|
||||
import crm
|
||||
import time
|
||||
import mx.DateTime
|
||||
from tools.translate import _
|
||||
from crm import crm_case
|
||||
import binascii
|
||||
|
@ -84,12 +83,12 @@ class crm_lead(crm_case, osv.osv):
|
|||
new_dates = cal_obj.interval_get(cr,
|
||||
uid,
|
||||
lead.section_id.resource_calendar_id and lead.section_id.resource_calendar_id.id or False,
|
||||
mx.DateTime.strptime(lead.create_date, '%Y-%m-%d %H:%M:%S'),
|
||||
datetime.strptime(lead.create_date, '%Y-%m-%d %H:%M:%S'),
|
||||
duration,
|
||||
resource=resource_id
|
||||
)
|
||||
no_days = []
|
||||
date_until = mx.DateTime.strptime(date_until, '%Y-%m-%d %H:%M:%S')
|
||||
date_until = datetime.strptime(date_until, '%Y-%m-%d %H:%M:%S')
|
||||
for in_time, out_time in new_dates:
|
||||
if in_time.date not in no_days:
|
||||
no_days.append(in_time.date)
|
||||
|
|
|
@ -24,7 +24,6 @@ from osv import fields,osv,orm
|
|||
from tools.translate import _
|
||||
import crm
|
||||
import time
|
||||
import mx.DateTime
|
||||
|
||||
AVAILABLE_STATES = [
|
||||
('draft','Draft'),
|
||||
|
|
|
@ -23,7 +23,6 @@ import time
|
|||
import tools
|
||||
from osv import fields, osv, orm
|
||||
import os
|
||||
import mx.DateTime
|
||||
import base64
|
||||
import pooler
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
from mx import DateTime
|
||||
from mx.DateTime import now
|
||||
import time
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import datetime
|
||||
import netsvc
|
||||
import pooler
|
||||
|
@ -31,7 +31,7 @@ from report.interface import toxml
|
|||
|
||||
from report import report_sxw
|
||||
|
||||
one_day = DateTime.RelativeDateTime(days=1)
|
||||
one_day = relativedelta(days=1)
|
||||
month2name = [0, 'January', 'February', 'March', 'April', 'May', 'Jun', 'July', 'August', 'September', 'October', 'November', 'December']
|
||||
|
||||
#def hour2str(h):
|
||||
|
@ -57,7 +57,7 @@ class report_custom(report_rml):
|
|||
obj_emp = pooler.get_pool(cr.dbname).get('hr.employee')
|
||||
if context is None:
|
||||
context = {}
|
||||
month = DateTime.DateTime(datas['form']['year'], datas['form']['month'], 1)
|
||||
month = datetime(datas['form']['year'], datas['form']['month'], 1)
|
||||
emp_ids = context.get('active_ids', [])
|
||||
user_xml = ['<month>%s</month>' % month2name[month.month], '<year>%s</year>' % month.year]
|
||||
if emp_ids:
|
||||
|
@ -89,7 +89,7 @@ class report_custom(report_rml):
|
|||
attendences.append({'name': tomor.strftime('%Y-%m-%d %H:%M:%S'), 'action':'sign_out'})
|
||||
# sum up the attendances' durations
|
||||
for att in attendences:
|
||||
dt = DateTime.strptime(att['name'], '%Y-%m-%d %H:%M:%S')
|
||||
dt = datetime.strptime(att['name'], '%Y-%m-%d %H:%M:%S')
|
||||
if att['action'] == 'sign_out':
|
||||
wh += (dt - ldt).hours
|
||||
ldt = dt
|
||||
|
|
|
@ -19,16 +19,16 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
from mx import DateTime
|
||||
from mx.DateTime import now
|
||||
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
import pooler
|
||||
|
||||
from report.interface import report_rml
|
||||
from report.interface import toxml
|
||||
|
||||
one_week = DateTime.RelativeDateTime(days=7)
|
||||
one_week = relativedelta(days=7)
|
||||
num2day = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
|
||||
|
||||
def to_hour(h):
|
||||
|
@ -38,10 +38,12 @@ class report_custom(report_rml):
|
|||
|
||||
def create_xml(self, cr, uid, ids, datas, context=None):
|
||||
obj_emp = pooler.get_pool(cr.dbname).get('hr.employee')
|
||||
start_date = DateTime.strptime(datas['form']['init_date'], '%Y-%m-%d')
|
||||
end_date = DateTime.strptime(datas['form']['end_date'], '%Y-%m-%d')
|
||||
first_monday = start_date - DateTime.RelativeDateTime(days=start_date.day_of_week)
|
||||
last_monday = end_date + DateTime.RelativeDateTime(days=7 - end_date.day_of_week)
|
||||
|
||||
start_date = datetime.strptime(datas['form']['init_date'], '%Y-%m-%d')
|
||||
end_date = datetime.strptime(datas['form']['end_date'], '%Y-%m-%d')
|
||||
first_monday = start_date - relativedelta(days=start_date.day_of_week)
|
||||
last_monday = end_date + relativedelta(days=7 - end_date.day_of_week)
|
||||
|
||||
if last_monday < first_monday:
|
||||
first_monday, last_monday = last_monday, first_monday
|
||||
|
||||
|
@ -67,7 +69,7 @@ class report_custom(report_rml):
|
|||
order by att.name
|
||||
'''
|
||||
for idx in range(7):
|
||||
cr.execute(sql, (monday.strftime('%Y-%m-%d %H:%M:%S'), (monday + DateTime.RelativeDateTime(days=idx+1)).strftime('%Y-%m-%d %H:%M:%S'), employee_id))
|
||||
cr.execute(sql, (monday.strftime('%Y-%m-%d %H:%M:%S'), (monday + relativedelta(days=idx+1)).strftime('%Y-%m-%d %H:%M:%S'), employee_id))
|
||||
attendances = cr.dictfetchall()
|
||||
week_wh = {}
|
||||
# Fake sign ins/outs at week ends, to take attendances across week ends into account
|
||||
|
@ -78,7 +80,7 @@ class report_custom(report_rml):
|
|||
attendances.append({'name': n_monday.strftime('%Y-%m-%d %H:%M:%S'), 'action': 'sign_out'})
|
||||
# sum up the attendances' durations
|
||||
for att in attendances:
|
||||
dt = DateTime.strptime(att['name'], '%Y-%m-%d %H:%M:%S')
|
||||
dt = datetime.strptime(att['name'], '%Y-%m-%d %H:%M:%S')
|
||||
if att['action'] == 'sign_out':
|
||||
week_wh[ldt.day_of_week] = week_wh.get(ldt.day_of_week, 0) + (dt - ldt).hours
|
||||
ldt = dt
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
import mx.DateTime
|
||||
from report import report_sxw
|
||||
from tools import amount_to_text_en
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ from report import report_sxw
|
|||
import time
|
||||
import pooler
|
||||
import rml_parse
|
||||
import mx.DateTime
|
||||
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
|
||||
|
||||
class employees_salary_report(rml_parse.rml_parse):
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import time
|
||||
import mx.DateTime
|
||||
from datetime import datetime
|
||||
from report import report_sxw
|
||||
from tools import amount_to_text_en
|
||||
|
||||
|
@ -22,7 +22,7 @@ class payroll_advice_report(report_sxw.rml_parse):
|
|||
res = {
|
||||
'mname':''
|
||||
}
|
||||
date = mx.DateTime.strptime(input_date, '%Y-%m-%d')
|
||||
date = datetime.strptime(input_date, '%Y-%m-%d')
|
||||
res['mname']= date.strftime('%B')+'-'+date.strftime('%Y')
|
||||
return res
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import time
|
||||
import mx.DateTime
|
||||
from datetime import datetime
|
||||
from report import report_sxw
|
||||
from tools import amount_to_text_en
|
||||
|
||||
|
@ -56,7 +56,7 @@ class report_payroll_register(report_sxw.rml_parse):
|
|||
return self.net
|
||||
|
||||
def get_month(self, indate):
|
||||
new_date = mx.DateTime.strptime(indate, '%Y-%m-%d')
|
||||
new_date = datetime.strptime(indate, '%Y-%m-%d')
|
||||
out_date = new_date.strftime('%B')+'-'+new_date.strftime('%Y')
|
||||
return out_date
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
import mx.DateTime
|
||||
from datetime import datetime
|
||||
from report import report_sxw
|
||||
from tools import amount_to_text_en
|
||||
|
||||
|
@ -93,7 +93,7 @@ class payslip_report(report_sxw.rml_parse):
|
|||
res = {
|
||||
'mname':''
|
||||
}
|
||||
date = mx.DateTime.strptime(obj.date, '%Y-%m-%d')
|
||||
date = datetime.strptime(obj.date, '%Y-%m-%d')
|
||||
res['mname']= date.strftime('%B')+"-"+date.strftime('%Y')
|
||||
return res['mname']
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ from report import report_sxw
|
|||
import time
|
||||
import pooler
|
||||
import rml_parse
|
||||
import mx.DateTime
|
||||
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
|
||||
|
||||
class year_salary_report(rml_parse.rml_parse):
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import os
|
|||
import sys
|
||||
import shutil
|
||||
import time
|
||||
from mx.DateTime import *
|
||||
from datetime import datetime
|
||||
|
||||
from report import report_sxw
|
||||
from tools import mod10r
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
import mx.DateTime
|
||||
from datetime import datetime
|
||||
import base64
|
||||
|
||||
from osv import osv, fields
|
||||
|
@ -469,11 +469,11 @@ def _create_dta(obj, cr, uid, data, context=None):
|
|||
'on line: ' + pline.name)
|
||||
|
||||
if pline.order_id.date_scheduled:
|
||||
date_value = mx.DateTime.strptime(pline.order_id.date_scheduled, '%Y-%m-%d')
|
||||
date_value = datetime.strptime(pline.order_id.date_scheduled, '%Y-%m-%d')
|
||||
elif pline.date:
|
||||
date_value = mx.DateTime.strptime(pline.date, '%Y-%m-%d')
|
||||
date_value = datetime.strptime(pline.date, '%Y-%m-%d')
|
||||
else:
|
||||
date_value = mx.DateTime.now()
|
||||
date_value = datetime.now()
|
||||
v['date_value'] = date_value.strftime("%y%m%d")
|
||||
|
||||
# si compte iban -> iban (836)
|
||||
|
|
|
@ -23,8 +23,12 @@ from report.render import render
|
|||
from report.interface import report_int
|
||||
from pychart import *
|
||||
from mx.DateTime import *
|
||||
import time
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from report.misc import choice_colors
|
||||
import time, mx
|
||||
|
||||
import random
|
||||
import StringIO
|
||||
|
||||
|
@ -62,8 +66,8 @@ class report_custom(report_int):
|
|||
months = {1:"January",2:"February",3:"March",4:"April",5:"May",6:"June",7:"July",8:"August",9:"September",10:"October",11:"November",12:"December"}
|
||||
dates[i] = {
|
||||
'name' :months[month],
|
||||
'start':(Date(year, month, 2) + RelativeDateTime(day=1)).strftime('%Y-%m-%d'),
|
||||
'stop' :(Date(year, month, 2) + RelativeDateTime(day=-1)).strftime('%Y-%m-%d'),
|
||||
'start':(datetime.date(year, month, 2) + relativedelta(day=1)).strftime('%Y-%m-%d'),
|
||||
'stop' :(datetime.date(year, month, 2) + relativedelta(day=-1)).strftime('%Y-%m-%d'),
|
||||
}
|
||||
return dates
|
||||
elif time_unit == 'week':
|
||||
|
@ -90,7 +94,7 @@ class report_custom(report_int):
|
|||
'start':i.strftime('%Y-%m-%d'),
|
||||
'stop' :i.strftime('%Y-%m-%d'),
|
||||
}
|
||||
i = i + RelativeDateTime(days=+1)
|
||||
i = i + relativedelta(days=+1)
|
||||
return dates
|
||||
return {}
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
from osv import fields,osv
|
||||
import netsvc
|
||||
import mx.DateTime
|
||||
from mx.DateTime import RelativeDateTime, today
|
||||
from datetime import datetime, date
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from tools.translate import _
|
||||
import decimal_precision as dp
|
||||
|
||||
|
@ -222,8 +222,7 @@ class mrp_repair(osv.osv):
|
|||
if move_id:
|
||||
move = self.pool.get('stock.move').browse(cr, uid, move_id)
|
||||
product = self.pool.get('product.product').browse(cr, uid, prod_id)
|
||||
date = move.date_planned
|
||||
limit = mx.DateTime.strptime(date, '%Y-%m-%d %H:%M:%S') + RelativeDateTime(months=product.warranty)
|
||||
limit = datetime.strptime(move.date_planned, '%Y-%m-%d %H:%M:%S') + relativedelta(months=product.warranty)
|
||||
data['value']['guarantee_limit'] = limit.strftime('%Y-%m-%d')
|
||||
data['value']['location_id'] = move.location_dest_id.id
|
||||
data['value']['location_dest_id'] = move.location_dest_id.id
|
||||
|
@ -688,7 +687,7 @@ class mrp_repair_line(osv.osv, ProductChangeMixin):
|
|||
if type == 'add':
|
||||
stock_id = self.pool.get('stock.location').search(cr, uid, [('name','=','Stock')])[0]
|
||||
to_invoice = False
|
||||
if guarantee_limit and today() > mx.DateTime.strptime(guarantee_limit, '%Y-%m-%d'):
|
||||
if guarantee_limit and date.today() > datetime.strptime(guarantee_limit, '%Y-%m-%d'):
|
||||
to_invoice=True
|
||||
return {'value': {
|
||||
'to_invoice': to_invoice,
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
import mx.DateTime
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
@ -139,7 +140,7 @@ class report_account_analytic_planning(osv.osv):
|
|||
}
|
||||
_defaults = {
|
||||
'date_from': time.strftime('%Y-%m-01'),
|
||||
'date_to': (mx.DateTime.now()+mx.DateTime.RelativeDateTime(months=1, day=1, days=-1)).strftime('%Y-%m-%d'),
|
||||
'date_to': (datetime.now()+relativedelta(months=1, day=1, days=-1)).strftime('%Y-%m-%d'),
|
||||
'user_id': lambda self, cr, uid, c: uid,
|
||||
'state': 'draft',
|
||||
'business_days': 20,
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import mx.DateTime
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from osv import fields,osv
|
||||
import tools
|
||||
|
@ -31,7 +32,7 @@ class report_timesheet_task_user(osv.osv):
|
|||
def _get_task_hours(self, cr, uid, ids, name,args,context):
|
||||
result = {}
|
||||
for record in self.browse(cr, uid, ids,context):
|
||||
last_date = mx.DateTime.strptime(record.name, '%Y-%m-%d') + mx.DateTime.RelativeDateTime(months=1) - 1
|
||||
last_date = datetime(record.name, '%Y-%m-%d') + relativedelta(months=1) - 1
|
||||
task_obj=self.pool.get('project.task.work')
|
||||
task_ids = task_obj.search(cr, uid, [('user_id','=',record.user_id.id),('date','>=',record.name),('date','<=',last_date.strftime('%Y-%m-%d'))])
|
||||
tsk_hrs = task_obj.read(cr, uid, task_ids, ['hours','date','user_id'])
|
||||
|
@ -45,7 +46,7 @@ class report_timesheet_task_user(osv.osv):
|
|||
result = {}
|
||||
sum = 0.0
|
||||
for record in self.browse(cr, uid, ids, context):
|
||||
last_date = mx.DateTime.strptime(record.name, '%Y-%m-%d') + mx.DateTime.RelativeDateTime(months=1) - 1
|
||||
last_date = datetime.strptime(record.name, '%Y-%m-%d') + relativedelta(months=1) - 1
|
||||
obj=self.pool.get('hr_timesheet_sheet.sheet.day')
|
||||
sheet_ids = obj.search(cr, uid, [('sheet_id.user_id','=',record.user_id.id),('name','>=',record.name),('name','<=',last_date.strftime('%Y-%m-%d'))])
|
||||
data_days = obj.read(cr, uid, sheet_ids, ['name','sheet_id.user_id','total_attendance'])
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
import mx.DateTime
|
||||
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from osv import osv, fields
|
||||
import netsvc
|
||||
|
@ -538,14 +538,14 @@ class stock_planning(osv.osv):
|
|||
return res / product.uom_id.factor, uom.rounding
|
||||
|
||||
def calculate_planning(self, cr, uid, ids, context, *args):
|
||||
one_minute = RelativeDateTime(minutes=1)
|
||||
current_date_beginning_c = mx.DateTime.today()
|
||||
current_date_end_c = current_date_beginning_c + RelativeDateTime(days=1, minutes=-1) # to get hour 23:59:00
|
||||
one_minute = relativedelta(minutes=1)
|
||||
current_date_beginning_c = datetime.today()
|
||||
current_date_end_c = current_date_beginning_c + relativedelta(days=1, minutes=-1) # to get hour 23:59:00
|
||||
current_date_beginning = current_date_beginning_c.strftime('%Y-%m-%d %H:%M:%S')
|
||||
current_date_end = current_date_end_c.strftime('%Y-%m-%d %H:%M:%S')
|
||||
for val in self.browse(cr, uid, ids, context=context):
|
||||
day = mx.DateTime.strptime(val.period_id.date_start, '%Y-%m-%d %H:%M:%S')
|
||||
dbefore = mx.DateTime.DateTime(day.year, day.month, day.day) - one_minute
|
||||
day = datetime.strptime(val.period_id.date_start, '%Y-%m-%d %H:%M:%S')
|
||||
dbefore = datetime(day.year, day.month, day.day) - one_minute
|
||||
day_before_calculated_period = dbefore.strftime('%Y-%m-%d %H:%M:%S') # one day before start of calculated period
|
||||
cr.execute("SELECT date_start \
|
||||
FROM stock_period AS period \
|
||||
|
@ -556,8 +556,9 @@ class stock_planning(osv.osv):
|
|||
date = cr.fetchone()
|
||||
start_date_current_period = date and date[0] or False
|
||||
start_date_current_period = start_date_current_period or current_date_beginning
|
||||
day = mx.DateTime.strptime(start_date_current_period, '%Y-%m-%d %H:%M:%S')
|
||||
dbefore = mx.DateTime.DateTime(day.year, day.month, day.day) - one_minute
|
||||
|
||||
day = datetime.strptime(start_date_current_period, '%Y-%m-%d %H:%M:%S')
|
||||
dbefore = datetime.datetime(day.year, day.month, day.day) - one_minute
|
||||
date_for_start = dbefore.strftime('%Y-%m-%d %H:%M:%S') # one day before current period
|
||||
already_out = self._get_in_out(cr, uid, val, start_date_current_period, current_date_end, direction='out', done=True, context=context),
|
||||
already_in = self._get_in_out(cr, uid, val, start_date_current_period, current_date_end, direction='in', done=True, context=context),
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
import mx.DateTime
|
||||
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from osv import osv, fields
|
||||
|
||||
|
@ -35,10 +35,10 @@ class stock_period_createlines(osv.osv_memory):
|
|||
result = cr.fetchone()
|
||||
last_date = result and result[0] or False
|
||||
if last_date:
|
||||
period_start = mx.DateTime.strptime(last_date,"%Y-%m-%d %H:%M:%S")+ RelativeDateTime(days=1)
|
||||
period_start = period_start - RelativeDateTime(hours=period_start.hour, minutes=period_start.minute, seconds=period_start.second)
|
||||
period_start = datetime(last_date,"%Y-%m-%d %H:%M:%S")+ relativedelta(days=1)
|
||||
period_start = period_start - relativedelta(hours=period_start.hour, minutes=period_start.minute, seconds=period_start.second)
|
||||
else:
|
||||
period_start = mx.DateTime.today()
|
||||
period_start = datetime.today()
|
||||
return period_start.strftime('%Y-%m-%d')
|
||||
|
||||
|
||||
|
@ -59,35 +59,35 @@ class stock_period_createlines(osv.osv_memory):
|
|||
lines = []
|
||||
for p in self.browse(cr, uid, ids, context=context):
|
||||
dt = p.date_start
|
||||
ds = mx.DateTime.strptime(p.date_start, '%Y-%m-%d')
|
||||
ds = datetime.strptime(p.date_start, '%Y-%m-%d')
|
||||
while ds.strftime('%Y-%m-%d') < p.date_stop:
|
||||
if name =='Daily':
|
||||
de = ds + RelativeDateTime(days=interval, minutes =-1)
|
||||
de = ds + relativedelta(days=interval, minutes =-1)
|
||||
new_name = de.strftime('%Y-%m-%d')
|
||||
new_id = period_obj.create(cr, uid, {
|
||||
'name': new_name,
|
||||
'date_start': ds.strftime('%Y-%m-%d'),
|
||||
'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
})
|
||||
ds = ds + RelativeDateTime(days=interval) + 1
|
||||
ds = ds + relativedelta(days=interval) + 1
|
||||
if name =="Weekly":
|
||||
de = ds + RelativeDateTime(days=interval, minutes =-1)
|
||||
de = ds + relativedelta(days=interval, minutes =-1)
|
||||
new_name = de.strftime('%Y, week %W')
|
||||
new_id = period_obj.create(cr, uid, {
|
||||
'name': new_name,
|
||||
'date_start': ds.strftime('%Y-%m-%d'),
|
||||
'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
})
|
||||
ds = ds + RelativeDateTime(days=interval) + 1
|
||||
ds = ds + relativedelta(days=interval) + 1
|
||||
if name == "Monthly":
|
||||
de = ds + RelativeDateTime(months=interval, minutes=-1)
|
||||
de = ds + relativedelta(months=interval, minutes=-1)
|
||||
new_name = ds.strftime('%Y/%m')
|
||||
new_id =period_obj.create(cr, uid, {
|
||||
'name': new_name,
|
||||
'date_start': ds.strftime('%Y-%m-%d'),
|
||||
'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
})
|
||||
ds = ds + RelativeDateTime(months=interval)
|
||||
ds = ds + relativedelta(months=interval)
|
||||
lines.append(new_id)
|
||||
return {
|
||||
'domain': "[('id','in', ["+','.join(map(str, lines))+"])]",
|
||||
|
|
|
@ -27,9 +27,9 @@ import netsvc
|
|||
from tools.translate import _
|
||||
|
||||
from time import strftime
|
||||
import datetime
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import copy
|
||||
from mx.DateTime import *
|
||||
import os
|
||||
|
||||
class survey_type(osv.osv):
|
||||
|
@ -694,7 +694,7 @@ class survey_request(osv.osv):
|
|||
}
|
||||
_defaults = {
|
||||
'state': lambda * a: 'draft',
|
||||
# 'date_deadline': lambda * a : (now() + RelativeDateTime(months=+1)).strftime("%Y-%m-%d %H:%M:%S")
|
||||
# 'date_deadline': lambda * a : (datetime.now() + relativedelta(months=+1)).strftime("%Y-%m-%d %H:%M:%S")
|
||||
}
|
||||
def survey_req_waiting_answer(self, cr, uid, ids, arg):
|
||||
self.write(cr, uid, ids, { 'state' : 'waiting_answer'})
|
||||
|
|
Loading…
Reference in New Issue