diff --git a/addons/account/account.py b/addons/account/account.py index b23ac2d0ee1..1da45c51d14 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1095,11 +1095,7 @@ class account_period(osv.osv): raise osv.except_osv(_('Error'), _('You should have chosen periods that belongs to the same company')) if period_date_start > period_date_stop: raise osv.except_osv(_('Error'), _('Start period should be smaller then End period')) - - # /!\ We do not include a criterion on the company_id field below, to allow producing consolidated reports - # on multiple companies. It will only work when start/end periods are selected and no fiscal year is chosen. - - # for period from = january, we want to exclude the opening period (but it has same date_from, so we have to check if period_from is special or not to include that clause or not in the search). + #for period from = january, we want to exclude the opening period (but it has same date_from, so we have to check if period_from is special or not to include that clause or not in the search). if period_from.special: return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop)]) return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('special', '=', False)]) diff --git a/addons/account/report/account_aged_partner_balance.py b/addons/account/report/account_aged_partner_balance.py index 2812fd409e6..88480a36310 100644 --- a/addons/account/report/account_aged_partner_balance.py +++ b/addons/account/report/account_aged_partner_balance.py @@ -22,6 +22,7 @@ import time from report import report_sxw from common_report_header import common_report_header +from tools.translate import _ class aged_trial_report(report_sxw.rml_parse, common_report_header): @@ -41,6 +42,7 @@ class aged_trial_report(report_sxw.rml_parse, common_report_header): 'get_account': self._get_account, 'get_fiscalyear': self._get_fiscalyear, 'get_target_move': self._get_target_move, + 'get_direction_selection': self._get_direction_selection, }) def set_context(self, objects, data, ids, report_type=None): @@ -367,13 +369,20 @@ class aged_trial_report(report_sxw.rml_parse, common_report_header): def _get_partners(self,data): if data['form']['result_selection'] == 'customer': - return 'Receivable Accounts' + return _('Receivable Accounts') elif data['form']['result_selection'] == 'supplier': - return 'Payable Accounts' + return _('Payable Accounts') elif data['form']['result_selection'] == 'customer_supplier': - return 'Receivable and Payable Accounts' + return _('Receivable and Payable Accounts') return '' + def _get_direction_selection(self, data): + if data['form']['direction_selection'] == 'past': + return _('Past') + elif data['form']['direction_selection'] == 'future': + return _('Future') + return '' + report_sxw.report_sxw('report.account.aged_trial_balance', 'res.partner', 'addons/account/report/account_aged_partner_balance.rml',parser=aged_trial_report, header="internal landscape") diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index c3117e60379..deaf5fb6e4d 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -41,6 +41,7 @@ class account_balance(report_sxw.rml_parse, common_report_header): 'sum_credit': self._sum_credit, 'get_fiscalyear':self._get_fiscalyear, 'get_filter': self._get_filter, + 'has_filter': self._has_filter, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period , 'get_account': self._get_account, diff --git a/addons/account/report/account_general_ledger.py b/addons/account/report/account_general_ledger.py index 294c7fa99cf..0512f69d6e7 100644 --- a/addons/account/report/account_general_ledger.py +++ b/addons/account/report/account_general_ledger.py @@ -83,6 +83,7 @@ class general_ledger(report_sxw.rml_parse, common_report_header): 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_filter': self._get_filter, + 'has_filter': self._has_filter, 'get_sortby': self._get_sortby, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py index 2669a3d174c..c3d0806fc4b 100644 --- a/addons/account/report/account_journal.py +++ b/addons/account/report/account_journal.py @@ -23,6 +23,8 @@ import time from common_report_header import common_report_header from report import report_sxw +from tools.translate import _ + class journal_print(report_sxw.rml_parse, common_report_header): def __init__(self, cr, uid, name, context=None): @@ -189,11 +191,11 @@ class journal_print(report_sxw.rml_parse, common_report_header): return data['form']['amount_currency'] def _get_sortby(self, data): - if self.sort_selection == 'date': - return 'Date' - elif self.sort_selection == 'ref': - return 'Reference Number' - return 'Date' + if self.sort_selection == 'l.date': + return _('Date') + elif self.sort_selection == 'am.name': + return _('Journal Entry Number') + return _('Date') report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print, header='internal') report_sxw.report_sxw('report.account.journal.period.print.sale.purchase', 'account.journal.period', 'addons/account/report/account_journal_sale_purchase.rml', parser=journal_print, header='internal') diff --git a/addons/account/report/account_partner_ledger.py b/addons/account/report/account_partner_ledger.py index ca0515c9f08..007dbcef4a1 100644 --- a/addons/account/report/account_partner_ledger.py +++ b/addons/account/report/account_partner_ledger.py @@ -391,11 +391,11 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): def _get_partners(self): if self.result_selection == 'customer': - return 'Receivable Accounts' + return _('Receivable Accounts') elif self.result_selection == 'supplier': - return 'Payable Accounts' + return _('Payable Accounts') elif self.result_selection == 'customer_supplier': - return 'Receivable and Payable Accounts' + return _('Receivable and Payable Accounts') return '' def _sum_currency_amount_account(self, account, form): diff --git a/addons/account/report/account_tax_report.py b/addons/account/report/account_tax_report.py index 2a0c5987b47..e167d35b888 100644 --- a/addons/account/report/account_tax_report.py +++ b/addons/account/report/account_tax_report.py @@ -23,6 +23,7 @@ import time from common_report_header import common_report_header from report import report_sxw +from tools.translate import _ class tax_report(report_sxw.rml_parse, common_report_header): _name = 'report.account.vat.declaration' @@ -62,7 +63,11 @@ class tax_report(report_sxw.rml_parse, common_report_header): }) def _get_basedon(self, form): - return form['form']['based_on'] + based_on = form['form']['based_on'] + if based_on == 'invoices': + return _('Invoices') + elif based_on == 'payments': + return _('Payments') def _get_lines(self, based_on, company_id=False, parent=False, level=0, context=None): period_list = self.period_ids diff --git a/addons/account/report/common_report_header.py b/addons/account/report/common_report_header.py index c0365875bdc..799ea1c39a5 100644 --- a/addons/account/report/common_report_header.py +++ b/addons/account/report/common_report_header.py @@ -92,12 +92,15 @@ class common_report_header(object): raise (_('Error'), _('Not implemented')) def _get_filter(self, data): - if data.get('form', False) and data['form'].get('filter', False): + if self._has_filter(data): if data['form']['filter'] == 'filter_date': - return 'Date' + return _('Date') elif data['form']['filter'] == 'filter_period': - return 'Periods' - return 'No Filter' + return _('Periods') + return _('No Filters') + + def _has_filter(self, data): + return data.get('form', False) and data['form'].get('filter', False) and data['form'].get('filter', False) != 'filter_no' def _sum_debit_period(self, period_id, journal_id=None): journals = journal_id or self.journal_ids diff --git a/addons/account/wizard/account_report_print_journal.py b/addons/account/wizard/account_report_print_journal.py index 0ffbde3fa9e..799c5349df8 100644 --- a/addons/account/wizard/account_report_print_journal.py +++ b/addons/account/wizard/account_report_print_journal.py @@ -53,7 +53,7 @@ class account_print_journal(osv.osv_memory): if context.get('sale_purchase_only'): domain ="[('type', 'in', ('sale','purchase','sale_refund','purchase_refund'))]" else: - domain ="[('type', 'not in', ('sale','purchase','sale_refund','purchase_refund'))]" + domain ="[]" nodes = doc.xpath("//field[@name='journal_ids']") for node in nodes: node.set('domain', domain) diff --git a/addons/account_budget/report/analytic_account_budget_report.py b/addons/account_budget/report/analytic_account_budget_report.py index aa5d39f8d49..b23e5e5b6ff 100644 --- a/addons/account_budget/report/analytic_account_budget_report.py +++ b/addons/account_budget/report/analytic_account_budget_report.py @@ -167,4 +167,4 @@ class analytic_account_budget_report(report_sxw.rml_parse): report_sxw.report_sxw('report.account.analytic.account.budget', 'account.analytic.account', 'addons/account_budget/report/analytic_account_budget_report.rml',parser=analytic_account_budget_report,header='internal') -# 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/account_payment/report/payment_order.py b/addons/account_payment/report/payment_order.py index 0b2a8061906..68b3bc6c4b5 100644 --- a/addons/account_payment/report/payment_order.py +++ b/addons/account_payment/report/payment_order.py @@ -87,4 +87,4 @@ class payment_order(report_sxw.rml_parse): report_sxw.report_sxw('report.payment.order', 'payment.order', 'addons/account_payment/report/payment_order.rml', parser=payment_order, header="external") -# 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/mail/mail_message.py b/addons/mail/mail_message.py index b69869efa11..295056c66eb 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -536,9 +536,11 @@ class mail_message(osv.osv): if res: message.write({'state':'sent', 'message_id': res}) message_sent = True + print "SENT" else: message.write({'state':'exception'}) message_sent = False + print "NOT SENT" # if auto_delete=True then delete that sent messages as well as attachments if message_sent and message.auto_delete: diff --git a/addons/product/report/product_pricelist.py b/addons/product/report/product_pricelist.py index dca7828a517..09b9881d07b 100644 --- a/addons/product/report/product_pricelist.py +++ b/addons/product/report/product_pricelist.py @@ -46,7 +46,7 @@ class product_pricelist(report_sxw.rml_parse): for i in range(1,6): if form['qty'+str(i)]!=0: - vals['qty'+str(qtys)] = str(form['qty'+str(i)]) + ' units' + vals['qty'+str(qtys)] = str(form['qty'+str(i)]) + ' ' + _('units') qtys += 1 lst.append(vals) return lst diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index f0d78f53dfc..a099f30f561 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -142,27 +142,12 @@ class project_issue(crm.crm_case, osv.osv): resource_ids = res_obj.search(cr, uid, [('user_id','=',issue.user_id.id)]) if resource_ids and len(resource_ids): resource_id = resource_ids[0] - duration = float(ans.days) - if issue.project_id and issue.project_id.resource_calendar_id: - duration = float(ans.days) * 24 - - new_dates = cal_obj.interval_min_get(cr, uid, - issue.project_id.resource_calendar_id.id, - date_create, - duration, resource=resource_id) - no_days = [] - 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) - if out_time > date_until: - break - duration = len(no_days) + duration = float(ans.days) + float(ans.seconds)/(24*3600) if field in ['working_hours_open','working_hours_close']: res[issue.id][field] = hours else: - res[issue.id][field] = abs(float(duration)) + res[issue.id][field] = duration return res diff --git a/addons/resource/resource.py b/addons/resource/resource.py index fb3d8c0980e..7578bf2f3f1 100644 --- a/addons/resource/resource.py +++ b/addons/resource/resource.py @@ -28,6 +28,7 @@ from tools.translate import _ from itertools import groupby from operator import itemgetter +import pytz class resource_calendar(osv.osv): _name = "resource.calendar" @@ -199,7 +200,7 @@ class resource_calendar(osv.osv): 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)] return res - 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, context=None): """ Calculates the Total Working hours based on given start_date to end_date, If resource id is supplied that it will consider the source leaves also in calculating the hours. @@ -216,41 +217,57 @@ class resource_calendar(osv.osv): return 0.0 dt_leave = self._get_leaves(cr, uid, id, resource) hours = 0.0 - - current_hour = dt_from.hour - - while (dt_from <= dt_to): + + orig_dt_from = dt_from + + users_obj = self.pool.get('res.users') + user = users_obj.browse(cr, uid, uid, context=context) + utc = pytz.timezone('UTC') + + if user.context_tz: + context_tz = pytz.timezone(user.context_tz) + else: + context_tz = utc + + # gap between UTC ans user timezone + tz_gap = (utc.localize(dt_from) - context_tz.localize(dt_from)).seconds / 3600 + + while dt_from <= dt_to: 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)) - der = cr.fetchall() - for (hour_from,hour_to) in der: - if hours != 0.0:#For first time of the loop only,hours will be 0 - current_hour = hour_from + slots = cr.fetchall() + + for (hour_from, hour_to) in slots: leave_flag = False - if (hour_to>=current_hour): - 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: + 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: + if dt_from.hour >= hour_to: + continue + elif dt_from.hour >= hour_from: + hour_from = dt_from.hour + dt_from.minute/60 + dt_from.second/3600 + d1 = datetime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(hour_from)), int((hour_from % 1) * 60)) + + if dt_from.day == dt_to.day and hour_from <= (dt_to.hour + tz_gap) < hour_to: + + hours += (utc.localize(dt_to) - context_tz.localize(d1)).seconds break - else: - d1 = dt_from + elif dt_from == orig_dt_from: d2 = datetime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(hour_to)), int((hour_to%1) * 60)) - - if hours != 0.0:#For first time of the loop only,hours will be 0 - d1 = datetime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(current_hour)), int((current_hour%1) * 60)) - - if dt_from.day == dt_to.day: - if hour_from <= dt_to.hour <= hour_to: - d2 = dt_to - dt_from = d2 - hours += (d2-d1).seconds - dt_from = datetime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(current_hour)), int((current_hour%1) * 60)) + timedelta(days=1) - current_hour = 0.0 - - return (hours/3600) + hours += (context_tz.localize(d2) - utc.localize(d1)).seconds + else: + d2 = datetime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(hour_to)), int((hour_to%1) * 60)) + hours += (d2 - d1).seconds + + dt_from += timedelta(days=1) + dt_from = datetime(dt_from.year, dt_from.month, dt_from.day) + + return hours / 3600 resource_calendar() diff --git a/addons/stock/report/product_stock.py b/addons/stock/report/product_stock.py index b7dd254234c..59c60676895 100644 --- a/addons/stock/report/product_stock.py +++ b/addons/stock/report/product_stock.py @@ -56,11 +56,11 @@ class report_stock(report_int): dt_from = now dt_to = now - names = dict(pooler.get_pool(cr.dbname).get('product.product').name_get(cr, uid, product_ids)) + names = dict(pooler.get_pool(cr.dbname).get('product.product').name_get(cr, uid, product_ids, context=context),) for name in names: names[name] = names[name].encode('utf8') products = {} - prods = pooler.get_pool(cr.dbname).get('stock.location')._product_all_get(cr, uid, location_id, product_ids) + prods = pooler.get_pool(cr.dbname).get('stock.location')._product_all_get(cr, uid, location_id, product_ids, context=context) for p in prods: products[p] = [(now,prods[p])] @@ -102,7 +102,7 @@ class report_stock(report_int): qty = 0 io = StringIO.StringIO() - gt = stock_graph.stock_graph(io) + gt = stock_graph.stock_graph(io, context['lang'], cr) for prod_id in products: gt.add(prod_id, names.get(prod_id, 'Unknown'), products[prod_id]) gt.draw() diff --git a/addons/stock/report/stock_graph.py b/addons/stock/report/stock_graph.py index 5ee58bb9d2c..2b1e18f1160 100644 --- a/addons/stock/report/stock_graph.py +++ b/addons/stock/report/stock_graph.py @@ -22,19 +22,23 @@ from pychart import * import pychart.legend import time from report.misc import choice_colors +from tools.translate import _ +import inspect # # Draw a graph for stocks # class stock_graph(object): - def __init__(self, io): + def __init__(self, io, lang, cr): self._datas = {} self._canvas = canvas.init(fname=io, format='pdf') self._canvas.set_author("OpenERP") - self._canvas.set_title("Stock Level Forecast") + self._canvas.set_title(_("Stock Level Forecast")) self._names = {} self.val_min = '' self.val_max = '' + self._lang = lang + self._cr = cr def add(self, product_id, product_name, datas): if hasattr(product_name, 'replace'): @@ -90,12 +94,16 @@ class stock_graph(object): plot = line_plot.T(label=self._names[product_id], data=datas2, line_style=st) plots.append(plot) + # Cheating to make them available in _(...) calls + context = {'lang': self._lang} + cr = self._cr + interval = max((val_max-val_min)/15, 86400) x_axis = axis.X(format=lambda x:'/a60{}'+time.strftime('%Y-%m-%d',time.gmtime(x)), tic_interval=interval, label=None) # For add the report header on the top of the report. - tb = text_box.T(loc=(300, 500), text="/hL/15/bStock Level Forecast", line_style=None) + tb = text_box.T(loc=(300, 500), text="/hL/15/b%s" % _("Stock Level Forecast"), line_style=None) tb.draw() - ar = area.T(size = (620,435), x_range=(val_min,val_max+1), y_axis = axis.Y(format="%d", label="Virtual Stock (Unit)"), x_axis=x_axis) + ar = area.T(size = (620,435), x_range=(val_min,val_max+1), y_axis = axis.Y(format="%d", label=_("Virtual Stock (Unit)")), x_axis=x_axis) for plot in plots: ar.add_plot(plot) ar.draw(self._canvas)