From 99ce17cfcaca141f13019746358eb8707fe64ffa Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 21 Aug 2014 11:17:29 +0200 Subject: [PATCH 1/5] [FIX] point_of_sale: report, product_id of line is product_product product_id column of pos_order_line is a product_product the left join of l.product_id was done on product_template, instead of product_product It worked as long as the ids product_product were the same as product_template. Meaning that, if you used variants, this report view was screwed. --- addons/point_of_sale/report/pos_order_report.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/report/pos_order_report.py b/addons/point_of_sale/report/pos_order_report.py index c27738ec230..9728660fa79 100644 --- a/addons/point_of_sale/report/pos_order_report.py +++ b/addons/point_of_sale/report/pos_order_report.py @@ -75,7 +75,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 to_char(s.date_order, 'dd-MM-YYYY'),to_char(s.date_order, 'YYYY'),to_char(s.date_order, 'MM'), From 20a99ae12949cbe473b21f750492d2a55e3ea091 Mon Sep 17 00:00:00 2001 From: fka-odoo Date: Wed, 6 Aug 2014 17:42:30 +0530 Subject: [PATCH 2/5] [IMP] account_budget: added date filter in print budget report Fixes #1743, opw 611307 --- addons/account_budget/account_budget.py | 4 ---- addons/account_budget/report/crossovered_budget_report.py | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/addons/account_budget/account_budget.py b/addons/account_budget/account_budget.py index c20871ed65e..ac79ca1799d 100644 --- a/addons/account_budget/account_budget.py +++ b/addons/account_budget/account_budget.py @@ -120,10 +120,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 4a3b632a8de..43411795c8a 100644 --- a/addons/account_budget/report/crossovered_budget_report.py +++ b/addons/account_budget/report/crossovered_budget_report.py @@ -89,7 +89,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 From 768b3592c2b5bf7b413b2ca9deb15aecf63443a9 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 21 Aug 2014 14:30:10 +0200 Subject: [PATCH 3/5] [FIX] base: wrong model change check Comparing an id and a browse record will always fail so the exception would have always been raised when changing a model (e.g. updating a module with custom fields). --- openerp/addons/base/ir/ir_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index 8796f892960..4fe4fc09df7 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -440,7 +440,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: From 8fe9f07cac96a1001761666a7f92ec955660cbfd Mon Sep 17 00:00:00 2001 From: Desai Binjal Date: Wed, 6 Aug 2014 17:46:46 +0530 Subject: [PATCH 4/5] [FIX] note: small bugs --- addons/pad/pad.py | 2 +- openerp/tools/mail.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/pad/pad.py b/addons/pad/pad.py index 0a72e2abde3..1379e06f184 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/openerp/tools/mail.py b/openerp/tools/mail.py index 425a7ff9c7d..fdcb44e040d 100644 --- a/openerp/tools/mail.py +++ b/openerp/tools/mail.py @@ -213,6 +213,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()]) @@ -375,4 +376,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]] From 0ab88f54f9b5e6c2396f7a612dc2df1f94ff0c09 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 21 Aug 2014 15:27:31 +0200 Subject: [PATCH 5/5] [FIX] ir_model: invalidate cache when adding new fields When a new ir.model.field is created, add the new field in the fields_by_model (cache of custom fields). This is required as the __init__ method would not retrieve the new field if fields_by_model is already set. Otherwise, the _columns would not contain the new fields and we could not access it without restarting the server (e.g. the installation of a module adds ir.model.fields and use it in the a view. --- openerp/addons/base/ir/ir_model.py | 4 ++ openerp/addons/base/tests/__init__.py | 2 + openerp/addons/base/tests/test_ir_model.py | 44 ++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 openerp/addons/base/tests/test_ir_model.py diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index 4fe4fc09df7..fb8e1db2fd5 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 self.pool.get(vals['model']): 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.get(vals['model']).__init__(self.pool, cr) #Added context to _auto_init for special treatment to custom field for select_level ctx = dict(context, diff --git a/openerp/addons/base/tests/__init__.py b/openerp/addons/base/tests/__init__.py index f4432f6e1eb..3c6029c49ea 100644 --- a/openerp/addons/base/tests/__init__.py +++ b/openerp/addons/base/tests/__init__.py @@ -1,6 +1,7 @@ import test_base import test_expression import test_ir_attachment +import test_ir_model import test_ir_values import test_menu import test_search @@ -10,6 +11,7 @@ checks = [ test_base, test_expression, test_ir_attachment, + test_ir_model, test_ir_values, test_menu, test_search, 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..409e93270ec --- /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()