Forward port of branch 7.0 up to 0ab88f5

This commit is contained in:
Martin Trigaux 2014-08-21 17:57:57 +02:00
commit 7bcefaf232
8 changed files with 57 additions and 9 deletions

View File

@ -118,10 +118,6 @@ class crossovered_budget_lines(osv.osv):
raise osv.except_osv(_('Error!'),_("The Budget '%s' has no accounts!") % ustr(line.general_budget_id.name))
date_to = line.date_to
date_from = line.date_from
if context.has_key('wizard_date_from'):
date_from = context['wizard_date_from']
if context.has_key('wizard_date_to'):
date_to = context['wizard_date_to']
if line.analytic_account_id.id:
cr.execute("SELECT SUM(amount) FROM account_analytic_line WHERE account_id=%s AND (date "
"between to_date(%s,'yyyy-mm-dd') AND to_date(%s,'yyyy-mm-dd')) AND "

View File

@ -88,7 +88,7 @@ class budget_report(report_sxw.rml_parse):
}
result.append(res)
line_ids = c_b_lines_obj.search(self.cr, self.uid, [('id', 'in', budget_ids), ('analytic_account_id','=',an_ids[i][0])])
line_ids = c_b_lines_obj.search(self.cr, self.uid, [('id', 'in', budget_ids), ('analytic_account_id','=',an_ids[i][0]), ('date_to', '>=', d_from), ('date_from', '<=', d_to)])
line_id = c_b_lines_obj.browse(self.cr, self.uid, line_ids)
tot_theo = tot_pln = tot_prac = tot_perc = 0.00

View File

@ -57,7 +57,7 @@ class pad_common(osv.osv_memory):
#get content of the real field
for record in model.browse(cr, uid, [context["object_id"]]):
if record[real_field]:
myPad.setText(path, html2plaintext(record[real_field]))
myPad.setText(path, (html2plaintext(record[real_field]).encode('utf-8')))
#Etherpad for html not functional
#myPad.setHTML(path, record[real_field])

View File

@ -67,7 +67,8 @@ class pos_order_report(osv.osv):
l.product_id as product_id
from pos_order_line as l
left join pos_order s on (s.id=l.order_id)
left join product_template pt on (pt.id=l.product_id)
left join product_product p on (p.id=l.product_id)
left join product_template pt on (pt.id=p.product_tmpl_id)
left join product_uom u on (u.id=pt.uom_id)
group by
s.date_order, s.partner_id,s.state,

View File

@ -361,6 +361,10 @@ class ir_model_fields(osv.osv):
if vals['model'] in self.pool:
if vals['model'].startswith('x_') and vals['name'] == 'x_name':
self.pool[vals['model']]._rec_name = 'x_name'
if self.pool.fields_by_model is not None:
cr.execute('SELECT * FROM ir_model_fields WHERE id=%s', (res,))
self.pool.fields_by_model.setdefault(vals['model'], []).append(cr.dictfetchone())
self.pool[vals['model']].__init__(self.pool, cr)
#Added context to _auto_init for special treatment to custom field for select_level
ctx = dict(context,
@ -437,7 +441,7 @@ class ir_model_fields(osv.osv):
column_rename = (obj, (obj._table, item.name, vals['name']))
final_name = vals['name']
if 'model_id' in vals and vals['model_id'] != item.model_id:
if 'model_id' in vals and vals['model_id'] != item.model_id.id:
raise except_orm(_("Error!"), _("Changing the model of a field is forbidden!"))
if 'ttype' in vals and vals['ttype'] != item.ttype:

View File

@ -2,6 +2,7 @@ import test_base
import test_expression
import test_ir_actions
import test_ir_attachment
import test_ir_model
import test_ir_values
import test_menu
import test_res_config
@ -14,6 +15,7 @@ checks = [
test_expression,
test_ir_actions,
test_ir_attachment,
test_ir_model,
test_ir_values,
test_menu,
test_res_config,

View File

@ -0,0 +1,44 @@
import unittest2
import openerp.tests.common as common
class test_ir_model(common.TransactionCase):
def test_00(self):
# Create some custom model and fields
cr, uid, context = self.cr, self.uid, {}
ir_model = self.registry('ir.model')
ir_model_fields = self.registry('ir.model.fields')
ir_model_access = self.registry('ir.model.access')
candy_model_id = ir_model.create(cr, uid, {
'name': 'Candies',
'model': 'x_candy',
'info': 'List of candies',
'state': 'manual',
}, context=context)
# security rule to avoid warning
ir_model_access.create(cr, uid, {
'name': 'Candies are for everybody',
'model_id': candy_model_id,
'perm_read': True,
'perm_write': True,
'perm_create': True,
'perm_unlink': True,
})
assert self.registry('x_candy'), "Custom model not present in registry"
ir_model_fields.create(cr, uid, {
'name': 'x_name',
'field_description': 'Name',
'model_id': candy_model_id,
'state': 'manual',
'ttype': 'char',
}, context=context)
assert 'x_name' in self.registry('x_candy')._all_columns, "Custom field not present in registry"
assert self.registry('x_candy')._rec_name == 'x_name', "The _rec_name on custom model was not updated"
if __name__ == '__main__':
unittest2.main()

View File

@ -500,6 +500,7 @@ def html2plaintext(html, body_id=None, encoding='utf-8'):
html = html.replace(' ' * 2, ' ')
html = html.replace('&gt;', '>')
html = html.replace('&lt;', '<')
html = html.replace('&amp;', '&')
# strip all lines
html = '\n'.join([x.strip() for x in html.splitlines()])
@ -665,4 +666,4 @@ def email_split(text):
# sometimes returns emails without at least '@'. The '@'
# is strictly required in RFC2822's `addr-spec`.
if addr[1]
if '@' in addr[1]]
if '@' in addr[1]]