diff --git a/addons/account/__init__.py b/addons/account/__init__.py
index 0608bb83c88..24129306e13 100644
--- a/addons/account/__init__.py
+++ b/addons/account/__init__.py
@@ -33,5 +33,6 @@ import report
import product
import sequence
import company
+import res_currency
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/account.py b/addons/account/account.py
index 86e8ddfaee5..8fc21799c08 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -708,6 +708,7 @@ class account_journal(osv.osv):
return self.name_get(cr, user, ids, context=context)
+
def onchange_type(self, cr, uid, ids, type, currency, context=None):
obj_data = self.pool.get('ir.model.data')
user_pool = self.pool.get('res.users')
@@ -730,7 +731,6 @@ class account_journal(osv.osv):
user = user_pool.browse(cr, uid, uid)
if type in ('cash', 'bank') and currency and user.company_id.currency_id.id != currency:
view_id = 'account_journal_bank_view_multi'
-
data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=',view_id)])
data = obj_data.browse(cr, uid, data_id[0], context=context)
diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py
index e96b8b1f0fb..a42d35c59ed 100644
--- a/addons/account/account_bank_statement.py
+++ b/addons/account/account_bank_statement.py
@@ -225,9 +225,11 @@ class account_bank_statement(osv.osv):
account_id = st.journal_id.default_debit_account_id.id
acc_cur = ((st_line.amount<=0) and st.journal_id.default_debit_account_id) or st_line.account_id
+ context.update({
+ 'res.currency.compute.account': acc_cur,
+ })
amount = res_currency_obj.compute(cr, uid, st.currency.id,
- company_currency_id, st_line.amount, context=context,
- account=acc_cur)
+ company_currency_id, st_line.amount, context=context)
val = {
'name': st_line.name,
@@ -245,20 +247,15 @@ class account_bank_statement(osv.osv):
'analytic_account_id': st_line.analytic_account_id and st_line.analytic_account_id.id or False
}
- amount = res_currency_obj.compute(cr, uid, st.currency.id,
- company_currency_id, st_line.amount, context=context,
- account=acc_cur)
if st.currency.id <> company_currency_id:
amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
- st.currency.id, amount, context=context,
- account=acc_cur)
+ st.currency.id, amount, context=context)
val['amount_currency'] = -amount_cur
if st_line.account_id and st_line.account_id.currency_id and st_line.account_id.currency_id.id <> company_currency_id:
val['currency_id'] = st_line.account_id.currency_id.id
amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
- st_line.account_id.currency_id.id, amount, context=context,
- account=acc_cur)
+ st_line.account_id.currency_id.id, amount, context=context)
val['amount_currency'] = -amount_cur
move_line_id = account_move_line_obj.create(cr, uid, val, context=context)
diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py
index 10ed021084a..2c4293f2ba4 100644
--- a/addons/account/account_move_line.py
+++ b/addons/account/account_move_line.py
@@ -289,7 +289,12 @@ class account_move_line(osv.osv):
acc = account
if s>0:
acc = acc1
- v = currency_obj.compute(cr, uid, account.company_id.currency_id.id, data['currency_id'], s, account=acc, account_invert=True)
+ compute_ctx = context.copy()
+ compute_ctx.update({
+ 'res.currency.compute.account': acc,
+ 'res.currency.compute.account_invert': True,
+ })
+ v = currency_obj.compute(cr, uid, account.company_id.currency_id.id, data['currency_id'], s, context=compute_ctx)
data['amount_currency'] = v
return data
@@ -556,8 +561,11 @@ class account_move_line(osv.osv):
if (amount>0) and journal:
x = journal_obj.browse(cr, uid, journal).default_credit_account_id
if x: acc = x
- context.update({'date': date})
- v = currency_obj.compute(cr, uid, currency_id, acc.company_id.currency_id.id, amount, account=acc, context=context)
+ context.update({
+ 'date': date,
+ 'res.currency.compute.account': acc,
+ })
+ v = currency_obj.compute(cr, uid, currency_id, acc.company_id.currency_id.id, amount, context=context)
result['value'] = {
'debit': v > 0 and v or 0.0,
'credit': v < 0 and -v or 0.0
@@ -955,7 +963,6 @@ class account_move_line(osv.osv):
if field in widths:
attrs.append('width="'+str(widths[field])+'"')
- attrs.append('string="'+field_it[2]+'"')
attrs.append("invisible=\"context.get('visible_id') not in %s\"" % (fields.get(field)))
xml += '''\n''' % (field,' '.join(attrs))
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index 2b12b6f91c5..be7cee99a0b 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -411,7 +411,7 @@
-
+
diff --git a/addons/account/invoice.py b/addons/account/invoice.py
index b6d8fcb9de0..e6e07b8eb68 100644
--- a/addons/account/invoice.py
+++ b/addons/account/invoice.py
@@ -1313,7 +1313,6 @@ class account_invoice_line(osv.osv):
if context is None:
context = {}
company_id = context.get('company_id',False)
- tax_obj = self.pool.get('account.tax')
if not partner_id:
raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") )
if not product:
diff --git a/addons/account/res_currency.py b/addons/account/res_currency.py
new file mode 100644
index 00000000000..6ec404edcf4
--- /dev/null
+++ b/addons/account/res_currency.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (C) 2010 OpenERP s.a. ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from osv import osv
+
+"""Inherit res.currency to handle accounting date values when converting currencies"""
+class res_currency_account(osv.osv):
+ _inherit = "res.currency"
+
+ def _get_conversion_rate(self, cr, uid, from_currency, to_currency, context=None):
+ if context is None:
+ context = {}
+ rate = super(res_currency_account, self)._get_conversion_rate(cr, uid, from_currency, to_currency, context=context)
+ account = context.get('res.currency.compute.account')
+ account_invert = context.get('res.currency.compute.account_invert')
+ if account and account.currency_mode == 'average' and account.currency_id:
+ query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
+ cr.execute('select sum(debit-credit),sum(amount_currency) from account_move_line l ' \
+ 'where l.currency_id=%s and l.account_id=%s and '+query, (account.currency_id.id,account.id,))
+ tot1,tot2 = cr.fetchone()
+ if tot2 and not account_invert:
+ rate = float(tot1)/float(tot2)
+ elif tot1 and account_invert:
+ rate = float(tot2)/float(tot1)
+ return rate
+
+res_currency_account()
\ No newline at end of file
diff --git a/addons/account_analytic_plans/report/crossovered_analytic.py b/addons/account_analytic_plans/report/crossovered_analytic.py
index 74f268db168..e2ad9e05b04 100644
--- a/addons/account_analytic_plans/report/crossovered_analytic.py
+++ b/addons/account_analytic_plans/report/crossovered_analytic.py
@@ -65,8 +65,6 @@ class crossovered_analytic(report_sxw.rml_parse):
def _ref_lines(self,form):
result = []
res = {}
- acc_id = []
- final = []
acc_pool = self.pool.get('account.analytic.account')
line_pool = self.pool.get('account.analytic.line')
@@ -128,7 +126,6 @@ class crossovered_analytic(report_sxw.rml_parse):
line_pool = self.pool.get('account.analytic.line')
acc_id = []
final = []
- child_ids = []
self.list_ids = []
self.final_list = self.find_children(ids)
diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py
index 570bfb1d8b7..e4b76cc8770 100644
--- a/addons/account_voucher/account_voucher.py
+++ b/addons/account_voucher/account_voucher.py
@@ -401,7 +401,7 @@ class account_voucher(osv.osv):
return default
- def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, context=None):
+ def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):
"""price
Returns a dict that contains new values and context
@@ -415,6 +415,9 @@ class account_voucher(osv.osv):
context = {}
if not journal_id:
return {}
+ context_multi_currency = context.copy()
+ if date:
+ context_multi_currency.update({'date': date})
line_pool = self.pool.get('account.voucher.line')
line_ids = ids and line_pool.search(cr, uid, [('voucher_id', '=', ids[0])]) or False
@@ -476,9 +479,9 @@ class account_voucher(osv.osv):
company_currency = journal.company_id.currency_id.id
if company_currency != currency_id and ttype == 'payment':
- total_debit = currency_pool.compute(cr, uid, currency_id, company_currency, total_debit)
+ total_debit = currency_pool.compute(cr, uid, currency_id, company_currency, total_debit, context=context_multi_currency)
elif company_currency != currency_id and ttype == 'receipt':
- total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit)
+ total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit, context=context_multi_currency)
for line in moves:
if line.credit and line.reconcile_partial_id and ttype == 'receipt':
@@ -500,18 +503,18 @@ class account_voucher(osv.osv):
'type': line.credit and 'dr' or 'cr',
'move_line_id':line.id,
'account_id':line.account_id.id,
- 'amount_original':currency_pool.compute(cr, uid, company_currency, currency_id, original_amount),
+ 'amount_original':currency_pool.compute(cr, uid, company_currency, currency_id, original_amount, context=context_multi_currency),
'date_original':line.date,
'date_due':line.date_maturity,
- 'amount_unreconciled':currency_pool.compute(cr, uid, company_currency, currency_id, line.amount_unreconciled)
+ 'amount_unreconciled':currency_pool.compute(cr, uid, company_currency, currency_id, line.amount_unreconciled, context=context_multi_currency)
}
if line.credit:
amount = min(line.amount_unreconciled, total_debit)
- rs['amount'] = currency_pool.compute(cr, uid, company_currency, currency_id, amount)
+ rs['amount'] = currency_pool.compute(cr, uid, company_currency, currency_id, amount, context=context_multi_currency)
total_debit -= amount
else:
amount = min(line.amount_unreconciled, total_credit)
- rs['amount'] = currency_pool.compute(cr, uid, company_currency, currency_id, amount)
+ rs['amount'] = currency_pool.compute(cr, uid, company_currency, currency_id, amount, context=context_multi_currency)
total_credit -= amount
default['value']['line_ids'].append(rs)
@@ -528,7 +531,7 @@ class account_voucher(osv.osv):
return default
- def onchange_date(self, cr, user, ids, date, context=None):
+ def onchange_date(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):
"""
@param date: latest value from user input for field date
@param args: other arguments
@@ -536,14 +539,13 @@ class account_voucher(osv.osv):
@return: Returns a dict which contains new values, and context
"""
period_pool = self.pool.get('account.period')
- pids = period_pool.search(cr, user, [('date_start', '<=', date), ('date_stop', '>=', date)])
- if not pids:
- return {}
- return {
- 'value':{
- 'period_id':pids[0]
- }
- }
+ res = self.onchange_partner_id(cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=context)
+ pids = period_pool.search(cr, uid, [('date_start', '<=', date), ('date_stop', '>=', date)])
+ if pids:
+ if not 'value' in res:
+ res['value'] = {}
+ res['value'].update({'period_id':pids[0]})
+ return res
def onchange_journal(self, cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context=None):
if not journal_id:
@@ -642,6 +644,9 @@ class account_voucher(osv.osv):
for inv in self.browse(cr, uid, ids, context=context):
if inv.move_id:
continue
+ context_multi_currency = context.copy()
+ context_multi_currency.update({'date': inv.date})
+
if inv.number:
name = inv.number
elif inv.journal_id.sequence_id:
@@ -671,9 +676,9 @@ class account_voucher(osv.osv):
# TODO: is there any other alternative then the voucher type ??
# -for sale, purchase we have but for the payment and receipt we do not have as based on the bank/cash journal we can not know its payment or receipt
if inv.type in ('purchase', 'payment'):
- credit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount)
+ credit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount, context=context_multi_currency)
elif inv.type in ('sale', 'receipt'):
- debit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount)
+ debit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount, context=context_multi_currency)
if debit < 0:
credit = -debit
debit = 0.0
@@ -701,14 +706,14 @@ class account_voucher(osv.osv):
rec_list_ids = []
line_total = debit - credit
if inv.type == 'sale':
- line_total = line_total - currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount)
+ line_total = line_total - currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount, context=context_multi_currency)
elif inv.type == 'purchase':
- line_total = line_total + currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount)
+ line_total = line_total + currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount, context=context_multi_currency)
for line in inv.line_ids:
if not line.amount:
continue
- amount = currency_pool.compute(cr, uid, current_currency, company_currency, line.untax_amount or line.amount)
+ amount = currency_pool.compute(cr, uid, current_currency, company_currency, line.untax_amount or line.amount, context=context_multi_currency)
move_line = {
'journal_id': inv.journal_id.id,
'period_id': inv.period_id.id,
@@ -770,7 +775,7 @@ class account_voucher(osv.osv):
'date': inv.date,
'credit': diff > 0 and diff or 0.0,
'debit': diff < 0 and -diff or 0.0,
- 'amount_currency': company_currency <> current_currency and currency_pool.compute(cr, uid, company_currency, current_currency, diff * -1) or 0.0,
+ 'amount_currency': company_currency <> current_currency and currency_pool.compute(cr, uid, company_currency, current_currency, diff * -1, context=context_multi_currency) or 0.0,
'currency_id': company_currency <> current_currency and current_currency or False,
}
@@ -1004,4 +1009,4 @@ class account_bank_statement_line(osv.osv):
account_bank_statement_line()
-# 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_voucher/account_voucher_view.xml b/addons/account_voucher/account_voucher_view.xml
index c41356f3973..5a2c4b88dd9 100644
--- a/addons/account_voucher/account_voucher_view.xml
+++ b/addons/account_voucher/account_voucher_view.xml
@@ -29,9 +29,10 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/base_calendar/test/base_calendar_test.yml b/addons/base_calendar/test/base_calendar_test.yml
index 8c5f7acaaa5..52888e02688 100644
--- a/addons/base_calendar/test/base_calendar_test.yml
+++ b/addons/base_calendar/test/base_calendar_test.yml
@@ -15,7 +15,7 @@
Now I will set recurrence for this event to occur monday and friday of week
-
!python {model: calendar.event}: |
- self.write(cr, uid, [ref("calendar_event_technicalpresentation0")], {'fr': 1, 'mo': 1, 'interval': 1, 'freq': 'weekly', 'rrule_type': 'custom'})
+ self.write(cr, uid, [ref("calendar_event_technicalpresentation0")], {'fr': 1, 'mo': 1, 'interval': 1, 'rrule_type': 'weekly'})
- |
In order to check that recurrent events are views successfully in calendar view,
I will open calendar view of events
diff --git a/addons/base_contact/base_contact_installer.py b/addons/base_contact/base_contact_installer.py
index 6d979da7a02..3936b336e9f 100644
--- a/addons/base_contact/base_contact_installer.py
+++ b/addons/base_contact/base_contact_installer.py
@@ -38,8 +38,6 @@ class base_contact_installer(osv.osv_memory):
obj = self.pool.get("base.contact.installer").browse(cr, uid, uid, context=context)
if obj.migrate:
cr.execute("""DROP TRIGGER IF EXISTS contactjob on res_partner_contact;
- DROP LANGUAGE IF EXISTS plpgsql CASCADE;
- CREATE LANGUAGE plpgsql ;
CREATE OR REPLACE FUNCTION add_to_job() RETURNS TRIGGER AS $contactjob$
DECLARE
new_name varchar;
@@ -57,7 +55,7 @@ class base_contact_installer(osv.osv_memory):
cr.execute("INSERT into res_partner_contact (name, title, email, first_name, website) (SELECT coalesce(name, 'Noname'), title, email, function , to_char(id, '99999999') from res_partner_address)")
cr.execute("DROP TRIGGER IF EXISTS contactjob on res_partner_contact")
- cr.execute("DROP LANGUAGE IF EXISTS plpgsql CASCADE;")
+
cr.execute("DROP FUNCTION IF EXISTS add_to_job()")
base_contact_installer()
diff --git a/addons/base_report_designer/base_report_designer.py b/addons/base_report_designer/base_report_designer.py
index 4bb86bba035..2371bc8e216 100644
--- a/addons/base_report_designer/base_report_designer.py
+++ b/addons/base_report_designer/base_report_designer.py
@@ -25,6 +25,7 @@ from StringIO import StringIO
import base64
import pooler
import addons
+import sys
class report_xml(osv.osv):
_inherit = 'ir.actions.report.xml'
@@ -59,6 +60,8 @@ class report_xml(osv.osv):
def report_get(self, cr, uid, report_id, context=None):
report = self.browse(cr, uid, report_id, context=context)
+ reload(sys)
+ sys.setdefaultencoding( "latin-1" )
return {
'file_type' : report.report_type,
'report_sxw_content': report.report_sxw_content and base64.encodestring(report.report_sxw_content) or False,
diff --git a/addons/base_report_designer/plugin/openerp_report_designer.zip b/addons/base_report_designer/plugin/openerp_report_designer.zip
index 3ee0260060f..50524b2e60d 100644
Binary files a/addons/base_report_designer/plugin/openerp_report_designer.zip and b/addons/base_report_designer/plugin/openerp_report_designer.zip differ
diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py
index e7269b7ed89..55d8fee4a24 100644
--- a/addons/caldav/calendar.py
+++ b/addons/caldav/calendar.py
@@ -579,8 +579,8 @@ class Calendar(CalDAV, osv.osv):
string="Type", size=64),
'line_ids': fields.one2many('basic.calendar.lines', 'calendar_id', 'Calendar Lines'),
'create_date': fields.datetime('Created Date', readonly=True),
- 'write_date': fields.datetime('Modifided Date', readonly=True),
- 'description': fields.text("description"),
+ 'write_date': fields.datetime('Write Date', readonly=True),
+ 'description': fields.text("Description"),
'calendar_color': fields.char('Color', size=20, help="For supporting clients, the color of the calendar entries"),
'calendar_order': fields.integer('Order', help="For supporting clients, the order of this folder among the calendars"),
'has_webcal': fields.boolean('WebCal', required=True, help="Also export a .ics entry next to the calendar folder, with WebCal content."),
@@ -818,6 +818,7 @@ class basic_calendar_fields(osv.osv):
_name = 'basic.calendar.fields'
_description = 'Calendar fields'
+ _order = 'name'
_columns = {
'field_id': fields.many2one('ir.model.fields', 'OpenObject Field'),
@@ -833,7 +834,7 @@ class basic_calendar_fields(osv.osv):
}
_defaults = {
- 'fn': lambda *a: 'field',
+ 'fn': 'field',
}
_sql_constraints = [
@@ -1164,11 +1165,16 @@ class Alarm(CalDAV, osv.osv_memory):
self.__attribute__ = get_attribute_mapping(cr, uid, self._calname, ctx)
for child in ical_data.getChildren():
if child.name.lower() == 'trigger':
- seconds = child.value.seconds
- days = child.value.days
- diff = (days * 86400) + seconds
- interval = 'days'
- related = 'before'
+ if isinstance(child.value, timedelta):
+ seconds = child.value.seconds
+ days = child.value.days
+ diff = (days * 86400) + seconds
+ interval = 'days'
+ related = 'before'
+ elif isinstance(child.value, datetime):
+ # TODO
+ # remember, spec says this datetime is in UTC
+ raise NotImplementedError("we cannot parse absolute triggers")
if not seconds:
duration = abs(days)
related = days > 0 and 'after' or 'before'
diff --git a/addons/caldav/wizard/calendar_event_import.py b/addons/caldav/wizard/calendar_event_import.py
index fc54d6e77df..6517fa42b31 100644
--- a/addons/caldav/wizard/calendar_event_import.py
+++ b/addons/caldav/wizard/calendar_event_import.py
@@ -82,8 +82,11 @@ class calendar_event_import(osv.osv_memory):
'msg': fields.text('', readonly=True),
}
+ def _get_msg(self, cr, uid, context):
+ return _('Import Sucessful')
+
_defaults = {
- 'msg':lambda *a:'Import Sucessful'
+ 'msg': _get_msg,
}
calendar_event_import()
diff --git a/addons/crm/board_crm_view.xml b/addons/crm/board_crm_view.xml
index 80e7fbfed0c..b8342709220 100644
--- a/addons/crm/board_crm_view.xml
+++ b/addons/crm/board_crm_view.xml
@@ -153,7 +153,7 @@
menu
-
+