diff --git a/addons/account_budget/account_budget.py b/addons/account_budget/account_budget.py index 78e85716bbd..16e58ad6df2 100644 --- a/addons/account_budget/account_budget.py +++ b/addons/account_budget/account_budget.py @@ -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 " diff --git a/addons/account_budget/report/crossovered_budget_report.py b/addons/account_budget/report/crossovered_budget_report.py index 70cbdecb713..ac71b8b95b8 100644 --- a/addons/account_budget/report/crossovered_budget_report.py +++ b/addons/account_budget/report/crossovered_budget_report.py @@ -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 diff --git a/addons/pad/pad.py b/addons/pad/pad.py index ab6f3d6b18c..cec784eb277 100644 --- a/addons/pad/pad.py +++ b/addons/pad/pad.py @@ -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]) diff --git a/addons/point_of_sale/report/pos_order_report.py b/addons/point_of_sale/report/pos_order_report.py index 501a829a46e..f51c7f70cb8 100644 --- a/addons/point_of_sale/report/pos_order_report.py +++ b/addons/point_of_sale/report/pos_order_report.py @@ -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, diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index 7b6e1bb9165..c8c7b77c441 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -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: diff --git a/openerp/addons/base/tests/__init__.py b/openerp/addons/base/tests/__init__.py index 0306839b5d3..18e627ac12e 100644 --- a/openerp/addons/base/tests/__init__.py +++ b/openerp/addons/base/tests/__init__.py @@ -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, diff --git a/openerp/addons/base/tests/test_ir_model.py b/openerp/addons/base/tests/test_ir_model.py new file mode 100644 index 00000000000..c18c74e067d --- /dev/null +++ b/openerp/addons/base/tests/test_ir_model.py @@ -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() diff --git a/openerp/tools/mail.py b/openerp/tools/mail.py index 37aee85b7d9..68fd2d7025d 100644 --- a/openerp/tools/mail.py +++ b/openerp/tools/mail.py @@ -500,6 +500,7 @@ def html2plaintext(html, body_id=None, encoding='utf-8'): html = html.replace(' ' * 2, ' ') html = html.replace('>', '>') html = html.replace('<', '<') + html = html.replace('&', '&') # 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]] \ No newline at end of file + if '@' in addr[1]]