[MERGE] merge from trunk addons

bzr revid: mra@mra-laptop-20100929133500-fou24no57ea6a937
This commit is contained in:
Mustufa Rangwala 2010-09-29 19:05:00 +05:30
commit 7959ca299a
56 changed files with 302 additions and 198 deletions

View File

@ -512,15 +512,15 @@
src_model="account.journal"/> src_model="account.journal"/>
<act_window <act_window
domain="[('partner_id', '=', partner_id), ('account_id.reconcile', '=', True)]" domain="[('account_id.reconcile', '=', True)]"
context="{'search_default_unreconciled':True}" context="{'search_default_unreconciled':True,'search_default_partner_id':[partner_id]}"
id="act_account_invoice_account_move_unreconciled" id="act_account_invoice_account_move_unreconciled"
name="Items to Reconcile" name="Items to Reconcile"
res_model="account.move.line" res_model="account.move.line"
src_model="account.invoice"/> src_model="account.invoice"/>
<act_window <act_window
domain="[('move_id', '=', move_id)]" context="{'search_default_move_id':move_id}"
id="act_account_invoice_account_move_invoice_link" id="act_account_invoice_account_move_invoice_link"
name="Invoice Items" name="Invoice Items"
res_model="account.move.line" res_model="account.move.line"

View File

@ -1414,10 +1414,9 @@
</record> </record>
<act_window <act_window
domain="[('move_id','=',active_id)]"
id="act_account_move_to_account_move_line_open" id="act_account_move_to_account_move_line_open"
name="Journal Items" name="Journal Items"
context="{'move_id':active_id}" context="{'search_default_move_id':[active_id]}"
res_model="account.move.line" res_model="account.move.line"
src_model="account.move"/> src_model="account.move"/>

View File

@ -20,9 +20,8 @@
############################################################################## ##############################################################################
import time import time
import datetime from datetime import datetime
import mx.DateTime from dateutil.relativedelta import relativedelta
import pooler import pooler
import tools import tools
from osv import fields,osv from osv import fields,osv
@ -128,13 +127,13 @@ class report_aged_receivable(osv.osv):
LIST_RANGES = [] LIST_RANGES = []
if fy_id: if fy_id:
fy_start_date = pool_obj_fy.read(cr, uid, fy_id, ['date_start'])['date_start'] 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') fy_start_date = datetime.strptime(fy_start_date, '%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)
while (last_month_date > fy_start_date): while (last_month_date > fy_start_date):
LIST_RANGES.append(today + " to " + last_month_date.strftime('%Y-%m-%d')) LIST_RANGES.append(today + " to " + last_month_date.strftime('%Y-%m-%d'))
today = (last_month_date- 1).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')) LIST_RANGES.append(today +" to " + fy_start_date.strftime('%Y-%m-%d'))
cr.execute('delete from temp_range') cr.execute('delete from temp_range')

View File

@ -20,8 +20,8 @@
############################################################################## ##############################################################################
import time import time
import datetime from datetime import datetime
from mx.DateTime import * from dateutil.relativedelta import relativedelta
from lxml import etree from lxml import etree
from osv import osv, fields from osv import osv, fields
@ -69,26 +69,26 @@ class account_aged_trial_balance(osv.osv_memory):
if not data['form']['date_from']: if not data['form']['date_from']:
raise osv.except_osv(_('UserError'), _('Enter a Start date !')) 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.strptime(data['form']['date_from'], "%Y-%m-%d")
start = DateTime(int(start.year), int(start.month), int(start.day))
if data['form']['direction_selection'] == 'past': if data['form']['direction_selection'] == 'past':
for i in range(5)[::-1]: for i in range(5)[::-1]:
stop = start - RelativeDateTime(days=period_length) stop = start - relativedelta(days=period_length)
res[str(i)] = { res[str(i)] = {
'name': (i!=0 and (str((5-(i+1)) * period_length) + '-' + str((5-i) * period_length)) or ('+'+str(4 * period_length))), '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'), 'stop': start.strftime('%Y-%m-%d'),
'start': (i!=0 and stop.strftime('%Y-%m-%d') or False), 'start': (i!=0 and stop.strftime('%Y-%m-%d') or False),
} }
start = stop - RelativeDateTime(days=1) start = stop - relativedelta(days=1)
else: else:
for i in range(5): for i in range(5):
stop = start + RelativeDateTime(days=period_length) stop = start + relativedelta(days=period_length)
res[str(5-(i+1))] = { res[str(5-(i+1))] = {
'name' : (i!=4 and str((i) * period_length)+'-' + str((i+1) * period_length) or ('+'+str(4 * period_length))), 'name' : (i!=4 and str((i) * period_length)+'-' + str((i+1) * period_length) or ('+'+str(4 * period_length))),
'start': start.strftime('%Y-%m-%d'), 'start': start.strftime('%Y-%m-%d'),
'stop': (i!=4 and stop.strftime('%Y-%m-%d') or False), '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) data['form'].update(res)
return { return {

View File

@ -66,14 +66,16 @@
id="act_account_acount_move_line_open" id="act_account_acount_move_line_open"
res_model="account.move.line" res_model="account.move.line"
src_model="account.account" src_model="account.account"
domain="[('account_id', '=', active_id)]"/> context="{'search_default_account_id': [active_id]}"
/>
<act_window <act_window
name="Analytic Rules" name="Analytic Rules"
id="analytic_rule_action_partner" id="analytic_rule_action_partner"
res_model="account.analytic.default" res_model="account.analytic.default"
src_model="res.partner" src_model="res.partner"
domain="[('partner_id','=',active_id)]" context="{'search_default_partner_id': [active_id]}"
groups="base.group_extended"/> groups="base.group_extended"/>
<act_window <act_window
@ -81,7 +83,7 @@
id="analytic_rule_action_user" id="analytic_rule_action_user"
res_model="account.analytic.default" res_model="account.analytic.default"
src_model="res.users" src_model="res.users"
domain="[('user_id','=',active_id)]" context="{'search_default_user_id': [active_id]}"
groups="base.group_extended"/> groups="base.group_extended"/>
<act_window <act_window
@ -89,7 +91,7 @@
res_model="account.analytic.default" res_model="account.analytic.default"
id="analytic_rule_action_product" id="analytic_rule_action_product"
src_model="product.product" src_model="product.product"
domain="[('product_id','=',active_id)]" context="{'search_default_product_id': [active_id]}"
groups="base.group_extended"/> groups="base.group_extended"/>
</data> </data>

View File

@ -260,7 +260,7 @@
<!-- Shortcuts --> <!-- Shortcuts -->
<act_window name="Budget Lines" <act_window name="Budget Lines"
domain="[('analytic_account_id', '=', active_id)]" context="{'search_default_analytic_account_id': [active_id]}"
res_model="crossovered.budget.lines" res_model="crossovered.budget.lines"
src_model="account.analytic.account" src_model="account.analytic.account"
id="act_account_analytic_account_cb_lines"/> id="act_account_analytic_account_cb_lines"/>

View File

@ -26,9 +26,6 @@ import pooler
from tools.misc import currency from tools.misc import currency
from tools.translate import _ from tools.translate import _
import mx.DateTime
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
class account_report(osv.osv): class account_report(osv.osv):
_name = "account.report.report" _name = "account.report.report"

View File

@ -19,7 +19,6 @@
# #
############################################################################## ##############################################################################
import time import time
from mx.DateTime import *
import os import os
import base64 import base64
import StringIO import StringIO

View File

@ -24,9 +24,6 @@ from osv import fields, osv
from tools.misc import currency from tools.misc import currency
import mx.DateTime
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
class color_rml(osv.osv): class color_rml(osv.osv):
_name = "color.rml" _name = "color.rml"

View File

@ -161,10 +161,10 @@
<menuitem action="action_voucher_list" id="menu_encode_entries_by_voucher" parent="account.menu_finance_entries" sequence="6"/> <menuitem action="action_voucher_list" id="menu_encode_entries_by_voucher" parent="account.menu_finance_entries" sequence="6"/>
<act_window <act_window
domain="[('journal_id','=',active_id)]"
id="act_journal_voucher_open" id="act_journal_voucher_open"
name="Voucher Entries" name="Voucher Entries"
context="{'journal_id': active_id, 'type':type}" context="{'search_default_journal_id': active_id, 'type':type}"
res_model="account.voucher" res_model="account.voucher"
src_model="account.journal"/> src_model="account.journal"/>

View File

@ -765,7 +765,7 @@
<menuitem name="Reporting" id="auction_report_menu" parent="auction_menu_root" sequence="6"/> <menuitem name="Reporting" id="auction_report_menu" parent="auction_menu_root" sequence="6"/>
<act_window name="Deposit slip" <act_window name="Deposit slip"
domain="[('partner_id', '=', active_id)]" context="{'search_default_partner_id': [active_id]}"
res_model="auction.deposit" res_model="auction.deposit"
src_model="res.partner" src_model="res.partner"
id="act_auction_lot_open_deposit"/> id="act_auction_lot_open_deposit"/>

View File

@ -23,7 +23,6 @@ from base_calendar import base_calendar
from osv import fields, osv from osv import fields, osv
from tools.translate import _ from tools.translate import _
import tools import tools
import mx.DateTime
import re import re

View File

@ -408,8 +408,9 @@
<!-- Act window defining a shorcut on partner address to open all his jobs --> <!-- Act window defining a shorcut on partner address to open all his jobs -->
<act_window <act_window
id="act_res_partner_jobs" name="Open Jobs" id="act_res_partner_jobs"
domain="[('address_id', '=', active_id)]" name="Open Jobs"
context="{'search_default_address_id': [active_id]}"
res_model="res.partner.job" res_model="res.partner.job"
src_model="res.partner.address" src_model="res.partner.address"
/> />

View File

@ -23,7 +23,6 @@ from osv import fields, osv
from datetime import datetime from datetime import datetime
import crm import crm
import time import time
import mx.DateTime
from tools.translate import _ from tools.translate import _
from crm import crm_case from crm import crm_case
import binascii import binascii
@ -84,12 +83,12 @@ class crm_lead(crm_case, osv.osv):
new_dates = cal_obj.interval_get(cr, new_dates = cal_obj.interval_get(cr,
uid, uid,
lead.section_id.resource_calendar_id and lead.section_id.resource_calendar_id.id or False, 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, duration,
resource=resource_id resource=resource_id
) )
no_days = [] 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: for in_time, out_time in new_dates:
if in_time.date not in no_days: if in_time.date not in no_days:
no_days.append(in_time.date) no_days.append(in_time.date)

View File

@ -8,8 +8,7 @@
res_model="crm.meeting" res_model="crm.meeting"
src_model="res.partner" src_model="res.partner"
view_mode="calendar,tree,form,gantt" view_mode="calendar,tree,form,gantt"
context="{'default_partner_id': active_id, 'default_duration': 4.0}" context="{'search_default_partner_id': active_id, 'default_duration': 4.0}"
domain="[('partner_id', '=', active_id)]"
/> />
<record model="ir.actions.act_window" id="crm_case_categ_meet_create_partner"> <record model="ir.actions.act_window" id="crm_case_categ_meet_create_partner">

View File

@ -24,7 +24,6 @@ from osv import fields,osv,orm
from tools.translate import _ from tools.translate import _
import crm import crm
import time import time
import mx.DateTime
AVAILABLE_STATES = [ AVAILABLE_STATES = [
('draft','Draft'), ('draft','Draft'),

View File

@ -8,8 +8,7 @@
res_model="crm.phonecall" res_model="crm.phonecall"
src_model="res.partner" src_model="res.partner"
view_mode="calendar,tree,form" view_mode="calendar,tree,form"
context="{'default_partner_id': active_id, 'default_duration': 1.0}" context="{'search_default_partner_id': [active_id], 'default_duration': 1.0}"
domain="[('partner_id', '=', active_id)]"
groups="base.group_extended" groups="base.group_extended"
/> />

View File

@ -310,8 +310,7 @@
</record> </record>
<act_window <act_window
domain="[('partner_id', '=', active_id)]" context="{'search_default_partner_id': [active_id]}"
context="{'default_partner_id': active_id}"
id="act_claim_partner" id="act_claim_partner"
name="Report a Claim" name="Report a Claim"
view_mode="form,tree" view_mode="form,tree"

View File

@ -403,7 +403,8 @@
src_model="res.partner" src_model="res.partner"
groups="base.group_extended"/> groups="base.group_extended"/>
<act_window domain="[('parent_id', '=', active_id)]" <act_window
context="{'search_default_parent_id': [active_id]}"
id="zoom_directory" name="Related Documents" id="zoom_directory" name="Related Documents"
res_model="ir.attachment" res_model="ir.attachment"
src_model="document.directory"/> src_model="document.directory"/>

View File

@ -23,7 +23,6 @@ import time
import tools import tools
from osv import fields, osv, orm from osv import fields, osv, orm
import os import os
import mx.DateTime
import base64 import base64
import pooler import pooler

View File

@ -264,7 +264,7 @@
res_model="event.registration" res_model="event.registration"
src_model="event.event" src_model="event.event"
view_mode="tree,form,calendar,graph" view_mode="tree,form,calendar,graph"
domain="[('event_id', '=', active_id)]" context="{'search_default_event_id': [active_id]}"
view_type="form"/> view_type="form"/>
<act_window <act_window
@ -273,7 +273,7 @@
res_model="event.registration" res_model="event.registration"
src_model="res.partner" src_model="res.partner"
view_mode="tree,form,calendar,graph" view_mode="tree,form,calendar,graph"
domain="[('partner_id', '=', active_id)]" context="{'search_default_partner_id': [active_id]}"
view_type="form"/> view_type="form"/>
<menuitem name="Events" id="menu_event_event" action="action_event_view" parent="base.menu_event_main" /> <menuitem name="Events" id="menu_event_event" action="action_event_view" parent="base.menu_event_main" />

View File

@ -36,7 +36,7 @@
res_model="project.task" res_model="project.task"
src_model="event.event" src_model="event.event"
view_mode="tree,form,calendar,graph" view_mode="tree,form,calendar,graph"
domain="[('project_id', '=', project_id)]" context="{'search_default_project_id': project_id}"
view_type="form"/> view_type="form"/>
</data> </data>

View File

@ -19,9 +19,9 @@
# #
############################################################################## ##############################################################################
from mx import DateTime
from mx.DateTime import now
import time import time
from datetime import datetime
from dateutil.relativedelta import relativedelta
import datetime import datetime
import netsvc import netsvc
import pooler import pooler
@ -31,7 +31,7 @@ from report.interface import toxml
from report import report_sxw 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'] month2name = [0, 'January', 'February', 'March', 'April', 'May', 'Jun', 'July', 'August', 'September', 'October', 'November', 'December']
#def hour2str(h): #def hour2str(h):
@ -57,7 +57,7 @@ class report_custom(report_rml):
obj_emp = pooler.get_pool(cr.dbname).get('hr.employee') obj_emp = pooler.get_pool(cr.dbname).get('hr.employee')
if context is None: if context is None:
context = {} 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', []) emp_ids = context.get('active_ids', [])
user_xml = ['<month>%s</month>' % month2name[month.month], '<year>%s</year>' % month.year] user_xml = ['<month>%s</month>' % month2name[month.month], '<year>%s</year>' % month.year]
if emp_ids: 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'}) attendences.append({'name': tomor.strftime('%Y-%m-%d %H:%M:%S'), 'action':'sign_out'})
# sum up the attendances' durations # sum up the attendances' durations
for att in attendences: 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': if att['action'] == 'sign_out':
wh += (dt - ldt).hours wh += (dt - ldt).hours
ldt = dt ldt = dt

View File

@ -19,16 +19,16 @@
# #
############################################################################## ##############################################################################
from mx import DateTime
from mx.DateTime import now
from datetime import datetime
from dateutil.relativedelta import relativedelta
import pooler import pooler
from report.interface import report_rml from report.interface import report_rml
from report.interface import toxml from report.interface import toxml
one_week = DateTime.RelativeDateTime(days=7) one_week = relativedelta(days=7)
num2day = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] num2day = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
def to_hour(h): def to_hour(h):
@ -38,10 +38,12 @@ class report_custom(report_rml):
def create_xml(self, cr, uid, ids, datas, context=None): def create_xml(self, cr, uid, ids, datas, context=None):
obj_emp = pooler.get_pool(cr.dbname).get('hr.employee') 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') start_date = datetime.strptime(datas['form']['init_date'], '%Y-%m-%d')
first_monday = start_date - DateTime.RelativeDateTime(days=start_date.day_of_week) end_date = datetime.strptime(datas['form']['end_date'], '%Y-%m-%d')
last_monday = end_date + DateTime.RelativeDateTime(days=7 - end_date.day_of_week) 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: if last_monday < first_monday:
first_monday, last_monday = 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 order by att.name
''' '''
for idx in range(7): 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() attendances = cr.dictfetchall()
week_wh = {} week_wh = {}
# Fake sign ins/outs at week ends, to take attendances across week ends into account # 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'}) attendances.append({'name': n_monday.strftime('%Y-%m-%d %H:%M:%S'), 'action': 'sign_out'})
# sum up the attendances' durations # sum up the attendances' durations
for att in attendances: 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': if att['action'] == 'sign_out':
week_wh[ldt.day_of_week] = week_wh.get(ldt.day_of_week, 0) + (dt - ldt).hours week_wh[ldt.day_of_week] = week_wh.get(ldt.day_of_week, 0) + (dt - ldt).hours
ldt = dt ldt = dt

View File

@ -279,7 +279,12 @@
<menuitem action="action_hr_contract" id="hr_menu_contract" parent="hr.menu_hr_main" name="Contracts" sequence="4" groups="base.group_system,base.group_hr_manager,base.group_hr_contract"/> <menuitem action="action_hr_contract" id="hr_menu_contract" parent="hr.menu_hr_main" name="Contracts" sequence="4" groups="base.group_system,base.group_hr_manager,base.group_hr_contract"/>
<!-- Contracts Button on Employee Form --> <!-- Contracts Button on Employee Form -->
<act_window domain="[('employee_id', '=', active_id)]" id="act_hr_employee_2_hr_contract" name="Contracts" res_model="hr.contract" src_model="hr.employee"/> <act_window
context="{'search_default_employee_id': [active_id]}"
id="act_hr_employee_2_hr_contract"
name="Contracts"
res_model="hr.contract"
src_model="hr.employee"/>
</data> </data>
</openerp> </openerp>

View File

@ -385,7 +385,12 @@
action="action_hr_evaluation_send_mail" sequence="45"/> action="action_hr_evaluation_send_mail" sequence="45"/>
<!-- Evaluation Interviews Button on Employee Form --> <!-- Evaluation Interviews Button on Employee Form -->
<act_window domain="[('user_to_review_id', '=', active_id)]" id="act_hr_employee_2_hr__evaluation_interview" name="Evaluation Interviews" res_model="hr.evaluation.interview" src_model="hr.employee"/> <act_window
context="{'search_default_user_to_review_id': [active_id]}"
id="act_hr_employee_2_hr__evaluation_interview"
name="Evaluation Interviews"
res_model="hr.evaluation.interview"
src_model="hr.employee"/>
</data> </data>
</openerp> </openerp>

View File

@ -23,7 +23,6 @@
############################################################################## ##############################################################################
import time import time
import mx.DateTime
from report import report_sxw from report import report_sxw
from tools import amount_to_text_en from tools import amount_to_text_en

View File

@ -5,8 +5,6 @@ from report import report_sxw
import time import time
import pooler import pooler
import rml_parse import rml_parse
import mx.DateTime
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
class employees_salary_report(rml_parse.rml_parse): class employees_salary_report(rml_parse.rml_parse):

View File

@ -1,5 +1,5 @@
import time import time
import mx.DateTime from datetime import datetime
from report import report_sxw from report import report_sxw
from tools import amount_to_text_en from tools import amount_to_text_en
@ -22,7 +22,7 @@ class payroll_advice_report(report_sxw.rml_parse):
res = { res = {
'mname':'' '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') res['mname']= date.strftime('%B')+'-'+date.strftime('%Y')
return res return res

View File

@ -1,5 +1,5 @@
import time import time
import mx.DateTime from datetime import datetime
from report import report_sxw from report import report_sxw
from tools import amount_to_text_en from tools import amount_to_text_en
@ -56,7 +56,7 @@ class report_payroll_register(report_sxw.rml_parse):
return self.net return self.net
def get_month(self, indate): 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') out_date = new_date.strftime('%B')+'-'+new_date.strftime('%Y')
return out_date return out_date

View File

@ -23,7 +23,7 @@
############################################################################## ##############################################################################
import time import time
import mx.DateTime from datetime import datetime
from report import report_sxw from report import report_sxw
from tools import amount_to_text_en from tools import amount_to_text_en
@ -93,7 +93,7 @@ class payslip_report(report_sxw.rml_parse):
res = { res = {
'mname':'' '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') res['mname']= date.strftime('%B')+"-"+date.strftime('%Y')
return res['mname'] return res['mname']

View File

@ -5,8 +5,6 @@ from report import report_sxw
import time import time
import pooler import pooler
import rml_parse import rml_parse
import mx.DateTime
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
class year_salary_report(rml_parse.rml_parse): class year_salary_report(rml_parse.rml_parse):

View File

@ -395,13 +395,34 @@
<field name="search_view_id" ref="view_timesheet_account_search"/> <field name="search_view_id" ref="view_timesheet_account_search"/>
</record> </record>
<act_window domain="[('user_id', '=', active_id)]" id="act_res_users_2_report_timesheet_user" name="Timesheets per day" res_model="report_timesheet.user" src_model="res.users"/> <act_window
context="{'search_default_user_id': [active_id]}"
id="act_res_users_2_report_timesheet_user"
name="Timesheets per day"
res_model="report_timesheet.user"
src_model="res.users"/>
<act_window domain="[('user_id', '=', active_id)]" id="act_res_users_2_report_timehsheet_account" name="Timesheets per account" res_model="report_timesheet.account" src_model="res.users"/> <act_window
context="{'search_default_user_id': [active_id]}"
id="act_res_users_2_report_timehsheet_account"
name="Timesheets per account"
res_model="report_timesheet.account"
src_model="res.users"/>
<act_window domain="[('account_id', '=', active_id)]" id="act_account_analytic_account_2_report_timehsheet_account" name="Timesheets" res_model="report_timesheet.account" src_model="account.analytic.account"/> <act_window
context="{'search_default_account_id': [active_id]}"
id="act_account_analytic_account_2_report_timehsheet_account"
name="Timesheets"
res_model="report_timesheet.account"
src_model="account.analytic.account"/>
<act_window domain="[('manager_id', '=', active_id)]" id="act_res_users_2_report_timesheet_invoice" name="Costs to invoice" res_model="report_timesheet.invoice" src_model="res.users"/> <act_window
context="{'search_default_manager_id': [active_id]}"
id="act_res_users_2_report_timesheet_invoice"
name="Costs to invoice"
res_model="report_timesheet.invoice"
src_model="res.users"/>
<!-- Random Timesheet --> <!-- Random Timesheet -->

View File

@ -134,7 +134,13 @@
<field name="search_view_id" ref="account_analytic_line_to_invoice_view_filter"/> <field name="search_view_id" ref="account_analytic_line_to_invoice_view_filter"/>
</record> </record>
<act_window domain="[('account_id', '=', active_id),('invoice_id','=',False),('to_invoice','&lt;&gt;',False)]" id="act_acc_analytic_acc_2_report_acc_analytic_line_to_invoice" name="Lines to Invoice" res_model="account.analytic.line" src_model="account.analytic.account"/> <act_window
domain="[('invoice_id','=',False),('to_invoice','&lt;&gt;',False)]"
context="{'search_default_account_id': [active_id]}"
id="act_acc_analytic_acc_2_report_acc_analytic_line_to_invoice"
name="Lines to Invoice"
res_model="account.analytic.line"
src_model="account.analytic.account"/>
</data> </data>
</openerp> </openerp>

View File

@ -290,11 +290,27 @@
</field> </field>
</record> </record>
<act_window domain="[('sheet_id', '=', active_id)]" id="act_hr_timesheet_sheet_sheet_by_day" name="Timesheet by Account" res_model="hr_timesheet_sheet.sheet.account" src_model="hr_timesheet_sheet.sheet"/> <act_window
context="{'search_default_sheet_id': [active_id]}"
id="act_hr_timesheet_sheet_sheet_by_day"
name="Timesheet by Account"
res_model="hr_timesheet_sheet.sheet.account"
src_model="hr_timesheet_sheet.sheet"/>
<act_window domain="[('sheet_id', '=', active_id)]" id="act_hr_timesheet_sheet_sheet_2_hr_analytic_timesheet" name="Timesheet Lines" res_model="hr.analytic.timesheet" src_model="hr_timesheet_sheet.sheet"/> <act_window
context="{'search_default_sheet_id': [active_id]}"
id="act_hr_timesheet_sheet_sheet_2_hr_analytic_timesheet"
name="Timesheet Lines"
res_model="hr.analytic.timesheet"
src_model="hr_timesheet_sheet.sheet"/>
<act_window domain="[('sheet_id', '=', active_id)]" id="act_hr_timesheet_sheet_sheet_2_hr_attendance" name="Attendances" res_model="hr.attendance" src_model="hr_timesheet_sheet.sheet"/> <act_window
context="{'search_default_sheet_id': [active_id]}"
id="act_hr_timesheet_sheet_sheet_2_hr_attendance"
name="Attendances"
res_model="hr.attendance"
src_model="hr_timesheet_sheet.sheet"/>
<record id="hr_timesheet_sheet_tree_simplified" model="ir.ui.view"> <record id="hr_timesheet_sheet_tree_simplified" model="ir.ui.view">
<field name="name">hr.timesheet.sheet.tree.simplified</field> <field name="name">hr.timesheet.sheet.tree.simplified</field>

View File

@ -35,7 +35,7 @@ import os
import sys import sys
import shutil import shutil
import time import time
from mx.DateTime import * from datetime import datetime
from report import report_sxw from report import report_sxw
from tools import mod10r from tools import mod10r

View File

@ -31,7 +31,7 @@
############################################################################## ##############################################################################
import time import time
import mx.DateTime from datetime import datetime
import base64 import base64
from osv import osv, fields from osv import osv, fields
@ -469,11 +469,11 @@ def _create_dta(obj, cr, uid, data, context=None):
'on line: ' + pline.name) 'on line: ' + pline.name)
if pline.order_id.date_scheduled: 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: elif pline.date:
date_value = mx.DateTime.strptime(pline.date, '%Y-%m-%d') date_value = datetime.strptime(pline.date, '%Y-%m-%d')
else: else:
date_value = mx.DateTime.now() date_value = datetime.now()
v['date_value'] = date_value.strftime("%y%m%d") v['date_value'] = date_value.strftime("%y%m%d")
# si compte iban -> iban (836) # si compte iban -> iban (836)

View File

@ -446,18 +446,20 @@
view_type="form" view_type="form"
view_mode="tree,form" view_mode="tree,form"
id="act_marketing_campaing_segment_opened" id="act_marketing_campaing_segment_opened"
domain="[('campaign_id','=',active_id)]" context="{'search_default_campaign_id': [active_id]}"
/> />
<!-- Campaign Followups --> <!-- Campaign Followups -->
<act_window domain="[('campaign_id', '=', active_id)]" <act_window
context="{'search_default_campaign_id': [active_id]}"
id="act_marketing_campaing_followup" id="act_marketing_campaing_followup"
name="Campaign Follow-up" res_model="marketing.campaign.workitem" name="Campaign Follow-up" res_model="marketing.campaign.workitem"
src_model="marketing.campaign" view_mode="tree,form" src_model="marketing.campaign" view_mode="tree,form"
view_type="form" /> view_type="form" />
<!-- Campaign Statistics --> <!-- Campaign Statistics -->
<act_window domain="[('campaign_id', '=', active_id)]" <act_window
context="{'search_default_campaign_id': [active_id]}"
id="act_marketing_campaing_stat" id="act_marketing_campaing_stat"
name="Campaign Statistics" res_model="campaign.analysis" name="Campaign Statistics" res_model="campaign.analysis"
src_model="marketing.campaign" view_mode="tree,form" src_model="marketing.campaign" view_mode="tree,form"

View File

@ -917,7 +917,8 @@
groups="base.group_extended"/> groups="base.group_extended"/>
<act_window <act_window
domain="[('product_id', '=', active_id),('bom_id','=',False)]" domain="[('bom_id','=',False)]"
context="{'search_default_product_id': [active_id]}"
id="act_product_product_2_mrp_bom" id="act_product_product_2_mrp_bom"
name="Bill of Materials" name="Bill of Materials"
res_model="mrp.bom" res_model="mrp.bom"

View File

@ -23,8 +23,12 @@ from report.render import render
from report.interface import report_int from report.interface import report_int
from pychart import * from pychart import *
from mx.DateTime import * from mx.DateTime import *
import time
from datetime import datetime
from dateutil.relativedelta import relativedelta
from report.misc import choice_colors from report.misc import choice_colors
import time, mx
import random import random
import StringIO 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"} 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] = { dates[i] = {
'name' :months[month], 'name' :months[month],
'start':(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' :(Date(year, month, 2) + RelativeDateTime(day=-1)).strftime('%Y-%m-%d'), 'stop' :(datetime.date(year, month, 2) + relativedelta(day=-1)).strftime('%Y-%m-%d'),
} }
return dates return dates
elif time_unit == 'week': elif time_unit == 'week':
@ -90,7 +94,7 @@ class report_custom(report_int):
'start':i.strftime('%Y-%m-%d'), 'start':i.strftime('%Y-%m-%d'),
'stop' :i.strftime('%Y-%m-%d'), 'stop' :i.strftime('%Y-%m-%d'),
} }
i = i + RelativeDateTime(days=+1) i = i + relativedelta(days=+1)
return dates return dates
return {} return {}

View File

@ -62,26 +62,30 @@ class mrp_production_workcenter_line(osv.osv):
else: else:
res[op.id]=False res[op.id]=False
return res return res
def _get_date_end(self, cr, uid, ids, field_name, arg, context): def _get_date_end(self, cr, uid, ids, field_name, arg, context):
""" Finds ending date. """ Finds ending date.
@return: Dictionary of values. @return: Dictionary of values.
""" """
ops = self.browse(cr, uid, ids, context=context)
date_and_hours_by_cal = [(op.date_planned, op.hour, op.workcenter_id.calendar_id.id) for op in ops]
intervals = self.pool.get('resource.calendar').interval_get_multi(cr, uid, date_and_hours_by_cal)
res = {} res = {}
for op in self.browse(cr, uid, ids, context=context): for op in ops:
res[op.id] = False res[op.id] = False
if op.date_planned: if op.date_planned:
d = DateTime.strptime(op.date_planned,'%Y-%m-%d %H:%M:%S') d = DateTime.strptime(op.date_planned,'%Y-%m-%d %H:%M:%S')
i = self.pool.get('resource.calendar').interval_get(cr, uid, op.workcenter_id.calendar_id.id or False, d, op.hour or 0.0) i = intervals[(op.date_planned, op.hour, op.workcenter_id.calendar_id.id)]
if i: if i:
res[op.id] = i[-1][1].strftime('%Y-%m-%d %H:%M:%S') res[op.id] = i[-1][1].strftime('%Y-%m-%d %H:%M:%S')
else: else:
res[op.id] = op.date_planned res[op.id] = op.date_planned
return res return res
_inherit = 'mrp.production.workcenter.line' _inherit = 'mrp.production.workcenter.line'
_order = "sequence, date_planned" _order = "sequence, date_planned"
_columns = { _columns = {
'state': fields.selection([('draft','Draft'),('startworking', 'In Progress'),('pause','Pause'),('cancel','Cancelled'),('done','Finished')],'State', readonly=True, 'state': fields.selection([('draft','Draft'),('startworking', 'In Progress'),('pause','Pause'),('cancel','Cancelled'),('done','Finished')],'State', readonly=True,
help="* When a work order is created it is set in 'Draft' state.\n" \ help="* When a work order is created it is set in 'Draft' state.\n" \

View File

@ -21,8 +21,8 @@
from osv import fields,osv from osv import fields,osv
import netsvc import netsvc
import mx.DateTime from datetime import datetime, date
from mx.DateTime import RelativeDateTime, today from dateutil.relativedelta import relativedelta
from tools.translate import _ from tools.translate import _
import decimal_precision as dp import decimal_precision as dp
@ -222,8 +222,7 @@ class mrp_repair(osv.osv):
if move_id: if move_id:
move = self.pool.get('stock.move').browse(cr, uid, move_id) move = self.pool.get('stock.move').browse(cr, uid, move_id)
product = self.pool.get('product.product').browse(cr, uid, prod_id) product = self.pool.get('product.product').browse(cr, uid, prod_id)
date = move.date_planned limit = datetime.strptime(move.date_planned, '%Y-%m-%d %H:%M:%S') + relativedelta(months=product.warranty)
limit = mx.DateTime.strptime(date, '%Y-%m-%d %H:%M:%S') + RelativeDateTime(months=product.warranty)
data['value']['guarantee_limit'] = limit.strftime('%Y-%m-%d') data['value']['guarantee_limit'] = limit.strftime('%Y-%m-%d')
data['value']['location_id'] = move.location_dest_id.id data['value']['location_id'] = move.location_dest_id.id
data['value']['location_dest_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': if type == 'add':
stock_id = self.pool.get('stock.location').search(cr, uid, [('name','=','Stock')])[0] stock_id = self.pool.get('stock.location').search(cr, uid, [('name','=','Stock')])[0]
to_invoice = False 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 to_invoice=True
return {'value': { return {'value': {
'to_invoice': to_invoice, 'to_invoice': to_invoice,

View File

@ -240,12 +240,16 @@
<field name="search_view_id" ref="warehouse_orderpoint_search" /> <field name="search_view_id" ref="warehouse_orderpoint_search" />
</record> </record>
<act_window domain="[('warehouse_id', '=', active_id)]" id="act_stock_warehouse_2_stock_warehouse_orderpoint" name="Minimum Stock Rules" res_model="stock.warehouse.orderpoint" src_model="stock.warehouse"/> <act_window
context="{'search_default_warehouse_id': [active_id]}"
id="act_stock_warehouse_2_stock_warehouse_orderpoint"
name="Minimum Stock Rules"
res_model="stock.warehouse.orderpoint"
src_model="stock.warehouse"/>
<!-- add product_uom to context to be the default value when adding new orderpoints --> <!-- add product_uom to context to be the default value when adding new orderpoints -->
<act_window <act_window
context="{'product_uom': locals().has_key('uom_id') and uom_id}" context="{'product_uom': locals().has_key('uom_id') and uom_id,'search_default_product_id': [active_id]}"
domain="[('product_id', '=', active_id)]"
id="act_product_product_2_stock_warehouse_orderpoint" id="act_product_product_2_stock_warehouse_orderpoint"
name="Minimum Stock Rules" name="Minimum Stock Rules"
res_model="stock.warehouse.orderpoint" res_model="stock.warehouse.orderpoint"

View File

@ -9,7 +9,11 @@
<!-- <!--
Board for project managers Board for project managers
--> -->
<act_window domain="[('manager', '=', uid)]" id="act_my_project" name="My projects" res_model="project.project" view_mode="tree,form" view_type="form"/> <act_window
domain="[('manager', '=', uid)]"
id="act_my_project" name="My projects"
res_model="project.project" view_mode="tree,form"
view_type="form"/>
<act_window domain="[('user_id','=',uid),('state','&lt;&gt;','close')]" id="act_my_account" name="My accounts to invoice" res_model="account.analytic.account" view_id="view_account_analytic_simplified" view_mode="tree,form" view_type="form"/> <act_window domain="[('user_id','=',uid),('state','&lt;&gt;','close')]" id="act_my_account" name="My accounts to invoice" res_model="account.analytic.account" view_id="view_account_analytic_simplified" view_mode="tree,form" view_type="form"/>

View File

@ -21,7 +21,8 @@
############################################################################## ##############################################################################
import time import time
import mx.DateTime from datetime import datetime
from dateutil.relativedelta import relativedelta
from osv import fields, osv from osv import fields, osv
from tools.translate import _ from tools.translate import _
@ -139,7 +140,7 @@ class report_account_analytic_planning(osv.osv):
} }
_defaults = { _defaults = {
'date_from': time.strftime('%Y-%m-01'), '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, 'user_id': lambda self, cr, uid, c: uid,
'state': 'draft', 'state': 'draft',
'business_days': 20, 'business_days': 20,

View File

@ -18,7 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # 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 from osv import fields,osv
import tools import tools
@ -31,7 +32,7 @@ class report_timesheet_task_user(osv.osv):
def _get_task_hours(self, cr, uid, ids, name,args,context): def _get_task_hours(self, cr, uid, ids, name,args,context):
result = {} result = {}
for record in self.browse(cr, uid, ids,context): 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_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'))]) 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']) 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 = {} result = {}
sum = 0.0 sum = 0.0
for record in self.browse(cr, uid, ids, context): 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') 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'))]) 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']) data_days = obj.read(cr, uid, sheet_ids, ['name','sheet_id.user_id','total_attendance'])

View File

@ -365,15 +365,14 @@
</record> </record>
<act_window <act_window
context="{'partner_id': active_id}" context="{'search_default_partner_id': [active_id]}"
domain="[('partner_id', '=', active_id)]"
id="act_res_partner_2_purchase_order" id="act_res_partner_2_purchase_order"
name="Purchase orders" name="Purchase orders"
res_model="purchase.order" res_model="purchase.order"
src_model="res.partner"/> src_model="res.partner"/>
<act_window <act_window
domain="[('product_id','=',active_id)]" context="{'search_default_product_id': [active_id]}"
id="action_purchase_line_product_tree" id="action_purchase_line_product_tree"
name="Product purchases" name="Product purchases"
res_model="purchase.order.line" res_model="purchase.order.line"

View File

@ -20,12 +20,17 @@
############################################################################## ##############################################################################
from datetime import datetime, timedelta from datetime import datetime, timedelta
from mx import DateTime
import math import math
from faces import * from faces import *
from new import classobj from new import classobj
from osv import fields, osv from osv import fields, osv
from tools.translate import _ from tools.translate import _
from itertools import groupby
from operator import itemgetter
class resource_calendar(osv.osv): class resource_calendar(osv.osv):
_name = "resource.calendar" _name = "resource.calendar"
_description = "Resource Calendar" _description = "Resource Calendar"
@ -44,11 +49,12 @@ class resource_calendar(osv.osv):
dt_leave = [] dt_leave = []
resource_leave_ids = resource_cal_leaves.search(cr, uid, [('calendar_id','=',id), '|', ('resource_id','=',False), ('resource_id','=',resource)]) resource_leave_ids = resource_cal_leaves.search(cr, uid, [('calendar_id','=',id), '|', ('resource_id','=',False), ('resource_id','=',resource)])
res_leaves = resource_cal_leaves.read(cr, uid, resource_leave_ids, ['date_from', 'date_to']) #res_leaves = resource_cal_leaves.read(cr, uid, resource_leave_ids, ['date_from', 'date_to'])
res_leaves = resource_cal_leaves.browse(cr, uid, resource_leave_ids)
for leave in res_leaves: for leave in res_leaves:
dtf = datetime.strptime(leave['date_from'], '%Y-%m-%d %H:%M:%S') dtf = datetime.strptime(leave.date_from, '%Y-%m-%d %H:%M:%S')
dtt = datetime.strptime(leave['date_to'], '%Y-%m-%d %H:%M:%S') dtt = datetime.strptime(leave.date_to, '%Y-%m-%d %H:%M:%S')
no = dtt - dtf no = dtt - dtf
[dt_leave.append((dtf + timedelta(days=x)).strftime('%Y-%m-%d')) for x in range(int(no.days + 1))] [dt_leave.append((dtf + timedelta(days=x)).strftime('%Y-%m-%d')) for x in range(int(no.days + 1))]
dt_leave.sort() dt_leave.sort()
@ -92,40 +98,61 @@ class resource_calendar(osv.osv):
result.reverse() result.reverse()
return result return result
# def interval_get(self, cr, uid, id, dt_from, hours, resource=False, byday=True):
def interval_get_multi(self, cr, uid, date_and_hours_by_cal, resource=False, byday=True):
def group(lst, key):
lst.sort(key=itemgetter(key))
grouped = groupby(lst, itemgetter(key))
return dict([(k, [v for v in itr]) for k, itr in grouped])
# END group
cr.execute("select calendar_id, dayofweek, hour_from, hour_to from resource_calendar_attendance order by hour_from")
hour_res = cr.dictfetchall()
hours_by_cal = group(hour_res, 'calendar_id')
results = {}
for d, hours, id in date_and_hours_by_cal:
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))]
continue
dt_leave = self._get_leaves(cr, uid, id, resource)
todo = hours
result = []
maxrecur = 100
current_hour = dt_from.hour
while (todo>0) and maxrecur:
for (hour_from,hour_to) in [(item['hour_from'], item['hour_to']) for item in hours_by_cal[id] if item['dayofweek'] == str(dt_from.weekday())]:
leave_flag = False
if (hour_to>current_hour) and (todo>0):
m = max(hour_from, current_hour)
if (hour_to-m)>todo:
hour_to = m+todo
dt_check = dt_from.strftime('%Y-%m-%d')
for leave in dt_leave:
if dt_check == leave:
dt_check = datetime.strptime(dt_check, '%Y-%m-%d') + timedelta(days=1)
leave_flag = True
if leave_flag:
break
else:
d1 = datetime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(m)), int((m%1) * 60))
d2 = datetime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(hour_to)), int((hour_to%1) * 60))
result.append((d1, d2))
current_hour = hour_to
todo -= (hour_to - m)
dt_from += timedelta(days=1)
current_hour = 0
maxrecur -= 1
results[(d, hours, id)] = result
return results
def interval_get(self, cr, uid, id, dt_from, hours, resource=False, byday=True): def interval_get(self, cr, uid, id, dt_from, hours, resource=False, byday=True):
if not id: res = self.interval_get_multi(cr, uid, [(dt_from.strftime('%Y-%m-%d %H:%M:%S'), hours, id)], resource, byday)[(dt_from.strftime('%Y-%m-%d %H:%M:%S'), hours, id)]
td = int(hours)*3 return res
return [(dt_from, dt_from + timedelta(hours=td))]
dt_leave = self._get_leaves(cr, uid, id, resource)
todo = hours
result = []
maxrecur = 100
current_hour = dt_from.hour
while (todo>0) and maxrecur:
cr.execute("select hour_from,hour_to from resource_calendar_attendance where dayofweek='%s' and calendar_id=%s order by hour_from", (dt_from.weekday(),id))
for (hour_from,hour_to) in cr.fetchall():
leave_flag = False
if (hour_to>current_hour) and (todo>0):
m = max(hour_from, current_hour)
if (hour_to-m)>todo:
hour_to = m+todo
dt_check = dt_from.strftime('%Y-%m-%d')
for leave in dt_leave:
if dt_check == leave:
dt_check = datetime.strptime(dt_check, '%Y-%m-%d') + timedelta(days=1)
leave_flag = True
if leave_flag:
break
else:
d1 = datetime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(m)), int((m%1) * 60))
d2 = datetime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(hour_to)), int((hour_to%1) * 60))
result.append((d1, d2))
current_hour = hour_to
todo -= (hour_to - m)
dt_from += timedelta(days=1)
current_hour = 0
maxrecur -= 1
return result
def interval_hours_get(self, cr, uid, id, dt_from, dt_to, resource=False): def interval_hours_get(self, cr, uid, id, dt_from, dt_to, resource=False):
if not id: if not id:

View File

@ -515,9 +515,20 @@ to your configuration: from the sales order, from the pickings, etc.
<field name="filter" eval="True"/> <field name="filter" eval="True"/>
</record> </record>
<act_window context="{'partner_id': active_id}" domain="[('partner_id', '=', active_id)]" id="act_res_partner_2_sale_order" name="Sales" res_model="sale.order" src_model="res.partner"/> <act_window
context="{'search_default_partner_id': [active_id]}"
id="act_res_partner_2_sale_order"
name="Sales"
res_model="sale.order"
src_model="res.partner"/>
<act_window domain="[('product_id','=',active_id)]" id="action_order_line_product_tree" name="Product sales" res_model="sale.order.line" src_model="product.product" groups="base.group_extended"/> <act_window
context="{'search_default_product_id': [active_id]}"
id="action_order_line_product_tree"
name="Product sales"
res_model="sale.order.line"
src_model="product.product"
groups="base.group_extended"/>
<menuitem id="menu_invoiced" name="Billing" parent="base.menu_base_partner" sequence="5"/> <menuitem id="menu_invoiced" name="Billing" parent="base.menu_base_partner" sequence="5"/>
<menuitem action="action_order_line_tree2" id="menu_invoicing_sales_order_lines" parent="menu_invoiced" sequence="2"/> <menuitem action="action_order_line_tree2" id="menu_invoicing_sales_order_lines" parent="menu_invoiced" sequence="2"/>

View File

@ -303,7 +303,7 @@
<!-- Action of sale journal report in sale journal --> <!-- Action of sale journal report in sale journal -->
<act_window name="Monthly sales" <act_window name="Monthly sales"
domain="[('journal_id', '=', active_id)]" context="{'search_default_journal_id': active_id}"
res_model="sale.journal.report" res_model="sale.journal.report"
src_model="sale_journal.sale.journal" src_model="sale_journal.sale.journal"
id="act_sale_journal_sale_journal_2_sale_journal_sale_stats"/> id="act_sale_journal_sale_journal_2_sale_journal_sale_stats"/>
@ -311,7 +311,8 @@
<!-- Action of stock picking in picking journal --> <!-- Action of stock picking in picking journal -->
<act_window name="Assigned picking" <act_window name="Assigned picking"
domain="[('journal_id', '=', active_id),('state', '=', 'assigned')]" domain="[('state', '=', 'assigned')]"
context="{'search_default_journal_id': [active_id]}"
res_model="stock.picking" res_model="stock.picking"
src_model="sale_journal.picking.journal" src_model="sale_journal.picking.journal"
id="act_sale_journal_picking_journal_2_stock_picking_assigned"/> id="act_sale_journal_picking_journal_2_stock_picking_assigned"/>
@ -319,7 +320,8 @@
<!-- Action of stock picking in picking journal --> <!-- Action of stock picking in picking journal -->
<act_window name="Confirmed picking" <act_window name="Confirmed picking"
domain="[('journal_id', '=', active_id),('state', '=', 'confirmed')]" domain="[('state', '=', 'confirmed')]"
context="{'search_default_journal_id': [active_id]}"
res_model="stock.picking" res_model="stock.picking"
src_model="sale_journal.picking.journal" src_model="sale_journal.picking.journal"
id="act_sale_journal_picking_journal_2_stock_picking_confirmed"/> id="act_sale_journal_picking_journal_2_stock_picking_confirmed"/>
@ -327,7 +329,8 @@
<!-- Action of stock picking in sale journal --> <!-- Action of stock picking in sale journal -->
<act_window name="Assigned picking" <act_window name="Assigned picking"
domain="[('sale_journal_id', '=', active_id),('state', '=', 'assigned')]" domain="[('state', '=', 'assigned')]"
context="{'search_default_sale_journal_id': [active_id]}"
res_model="stock.picking" res_model="stock.picking"
src_model="sale_journal.sale.journal" src_model="sale_journal.sale.journal"
id="act_sale_journal_sale_journal_2_stock_picking_assigned"/> id="act_sale_journal_sale_journal_2_stock_picking_assigned"/>
@ -335,7 +338,8 @@
<!-- Action of stock picking in sale journal --> <!-- Action of stock picking in sale journal -->
<act_window name="Confirmed picking" <act_window name="Confirmed picking"
domain="[('sale_journal_id', '=', active_id),('state', '=', 'confirmed')]" domain="[('state', '=', 'confirmed')]"
context="{'search_default_sale_journal_id': [active_id]}"
res_model="stock.picking" res_model="stock.picking"
src_model="sale_journal.sale.journal" src_model="sale_journal.sale.journal"
id="act_sale_journal_sale_journal_2_stock_picking_confirmed"/> id="act_sale_journal_sale_journal_2_stock_picking_confirmed"/>

View File

@ -1851,8 +1851,7 @@
src_model="stock.location"/> src_model="stock.location"/>
<act_window <act_window
context="{'location': active_id, 'search_default_done': 1}" context="{'location': active_id, 'search_default_done': 1,'search_default_product_id': [active_id]}"
domain="[('product_id','=',active_id)]"
id="act_product_stock_move_open" id="act_product_stock_move_open"
name="Stock Moves" name="Stock Moves"
res_model="stock.move" res_model="stock.move"
@ -1866,8 +1865,8 @@
src_model="stock.move"/> src_model="stock.move"/>
<act_window <act_window
context="{'location': active_id, 'search_default_future': 1}" context="{'location': active_id, 'search_default_future': 1,'search_default_product_id': [active_id]}"
domain="[('product_id','=',active_id),('state','in',('waiting','confirmed','assigned'))]" domain="[('state','in',('waiting','confirmed','assigned'))]"
id="act_product_stock_move_futur_open" id="act_product_stock_move_futur_open"
name="Future Stock Moves" name="Future Stock Moves"
res_model="stock.move" res_model="stock.move"

View File

@ -20,8 +20,8 @@
############################################################################## ##############################################################################
import time import time
import mx.DateTime from datetime import datetime
from mx.DateTime import RelativeDateTime, now, DateTime, localtime from dateutil.relativedelta import relativedelta
from osv import osv, fields from osv import osv, fields
import netsvc import netsvc
@ -538,14 +538,14 @@ class stock_planning(osv.osv):
return res / product.uom_id.factor, uom.rounding return res / product.uom_id.factor, uom.rounding
def calculate_planning(self, cr, uid, ids, context, *args): def calculate_planning(self, cr, uid, ids, context, *args):
one_minute = RelativeDateTime(minutes=1) one_minute = relativedelta(minutes=1)
current_date_beginning_c = mx.DateTime.today() current_date_beginning_c = datetime.today()
current_date_end_c = current_date_beginning_c + RelativeDateTime(days=1, minutes=-1) # to get hour 23:59:00 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_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') current_date_end = current_date_end_c.strftime('%Y-%m-%d %H:%M:%S')
for val in self.browse(cr, uid, ids, context=context): 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') day = 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 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 day_before_calculated_period = dbefore.strftime('%Y-%m-%d %H:%M:%S') # one day before start of calculated period
cr.execute("SELECT date_start \ cr.execute("SELECT date_start \
FROM stock_period AS period \ FROM stock_period AS period \
@ -556,8 +556,9 @@ class stock_planning(osv.osv):
date = cr.fetchone() date = cr.fetchone()
start_date_current_period = date and date[0] or False start_date_current_period = date and date[0] or False
start_date_current_period = start_date_current_period or current_date_beginning 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 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_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), already_in = self._get_in_out(cr, uid, val, start_date_current_period, current_date_end, direction='in', done=True, context=context),

View File

@ -20,8 +20,8 @@
############################################################################## ##############################################################################
import time import time
import mx.DateTime from datetime import datetime
from mx.DateTime import RelativeDateTime, now, DateTime, localtime from dateutil.relativedelta import relativedelta
from osv import osv, fields from osv import osv, fields
@ -35,10 +35,10 @@ class stock_period_createlines(osv.osv_memory):
result = cr.fetchone() result = cr.fetchone()
last_date = result and result[0] or False last_date = result and result[0] or False
if last_date: if last_date:
period_start = mx.DateTime.strptime(last_date,"%Y-%m-%d %H:%M:%S")+ RelativeDateTime(days=1) period_start = datetime(last_date,"%Y-%m-%d %H:%M:%S")+ relativedelta(days=1)
period_start = period_start - RelativeDateTime(hours=period_start.hour, minutes=period_start.minute, seconds=period_start.second) period_start = period_start - relativedelta(hours=period_start.hour, minutes=period_start.minute, seconds=period_start.second)
else: else:
period_start = mx.DateTime.today() period_start = datetime.today()
return period_start.strftime('%Y-%m-%d') return period_start.strftime('%Y-%m-%d')
@ -59,35 +59,35 @@ class stock_period_createlines(osv.osv_memory):
lines = [] lines = []
for p in self.browse(cr, uid, ids, context=context): for p in self.browse(cr, uid, ids, context=context):
dt = p.date_start 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: while ds.strftime('%Y-%m-%d') < p.date_stop:
if name =='Daily': 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_name = de.strftime('%Y-%m-%d')
new_id = period_obj.create(cr, uid, { new_id = period_obj.create(cr, uid, {
'name': new_name, 'name': new_name,
'date_start': ds.strftime('%Y-%m-%d'), 'date_start': ds.strftime('%Y-%m-%d'),
'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), '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": 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_name = de.strftime('%Y, week %W')
new_id = period_obj.create(cr, uid, { new_id = period_obj.create(cr, uid, {
'name': new_name, 'name': new_name,
'date_start': ds.strftime('%Y-%m-%d'), 'date_start': ds.strftime('%Y-%m-%d'),
'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), '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": if name == "Monthly":
de = ds + RelativeDateTime(months=interval, minutes=-1) de = ds + relativedelta(months=interval, minutes=-1)
new_name = ds.strftime('%Y/%m') new_name = ds.strftime('%Y/%m')
new_id =period_obj.create(cr, uid, { new_id =period_obj.create(cr, uid, {
'name': new_name, 'name': new_name,
'date_start': ds.strftime('%Y-%m-%d'), 'date_start': ds.strftime('%Y-%m-%d'),
'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'),
}) })
ds = ds + RelativeDateTime(months=interval) ds = ds + relativedelta(months=interval)
lines.append(new_id) lines.append(new_id)
return { return {
'domain': "[('id','in', ["+','.join(map(str, lines))+"])]", 'domain': "[('id','in', ["+','.join(map(str, lines))+"])]",

View File

@ -27,9 +27,9 @@ import netsvc
from tools.translate import _ from tools.translate import _
from time import strftime from time import strftime
import datetime from datetime import datetime
from dateutil.relativedelta import relativedelta
import copy import copy
from mx.DateTime import *
import os import os
class survey_type(osv.osv): class survey_type(osv.osv):
@ -694,7 +694,7 @@ class survey_request(osv.osv):
} }
_defaults = { _defaults = {
'state': lambda * a: 'draft', '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): def survey_req_waiting_answer(self, cr, uid, ids, arg):
self.write(cr, uid, ids, { 'state' : 'waiting_answer'}) self.write(cr, uid, ids, { 'state' : 'waiting_answer'})

View File

@ -1163,20 +1163,23 @@
<field name="view_id" ref="survey_type_tree"></field> <field name="view_id" ref="survey_type_tree"></field>
</record> </record>
<act_window domain="[('survey_id', '=', active_id)]" <act_window
context="{'search_default_survey_id': [active_id]}"
id="act_survey_pages" id="act_survey_pages"
name="Pages" name="Pages"
res_model="survey.page" res_model="survey.page"
src_model="survey"/> src_model="survey"/>
<act_window domain="[('survey', '=', active_id)]" <act_window
context="{'search_default_survey': active_id}"
id="act_survey_question" id="act_survey_question"
name="Questions" name="Questions"
res_model="survey.question" res_model="survey.question"
src_model="survey"/> src_model="survey"/>
<act_window domain="[('page_id', '=', active_id)]" <act_window
context="{'search_default_page_id': active_id}"
id="act_survey_page_question" id="act_survey_page_question"
name="Questions" name="Questions"
res_model="survey.question" res_model="survey.question"

View File

@ -245,13 +245,15 @@
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
</record> </record>
<act_window domain="[('wiki_id', '=', active_id)]" <act_window
context="{'search_default_wiki_id': [active_id]}"
id="act_wiki_wiki_history" id="act_wiki_wiki_history"
name="Page History" name="Page History"
res_model="wiki.wiki.history" res_model="wiki.wiki.history"
src_model="wiki.wiki"/> src_model="wiki.wiki"/>
<act_window domain="[('group_id', '=', active_id)]" <act_window
context="{'search_default_group_id': [active_id]}"
id="act_wiki_group_open" id="act_wiki_group_open"
name="Search Page" name="Search Page"
res_model="wiki.wiki" res_model="wiki.wiki"