From 9dec9c2863bb41a997510b7eedab1945412a6cb0 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Fri, 27 Aug 2010 10:38:09 +0300 Subject: [PATCH 01/12] Document: fix trivial errors. Seems that some patches have been mis-applied and some bugs re-appeared. Conflicts: document/nodes.py bzr revid: p_christ@hol.gr-20100827073809-vjhkiwagurpnn3id --- addons/document/nodes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/document/nodes.py b/addons/document/nodes.py index cf590dafdad..c78e0ece09f 100644 --- a/addons/document/nodes.py +++ b/addons/document/nodes.py @@ -644,7 +644,7 @@ class node_dir(node_database): if (not self.parent) and ndir_node: if not dbro.parent_id: raise IOError(errno.EPERM, "Cannot move the root directory!") - self.parent = self.context.get_dir_node(cr, dbro.parent_id.id) + self.parent = self.context.get_dir_node(cr, dbro.parent_id) assert self.parent if self.parent != ndir_node: @@ -1187,7 +1187,7 @@ class node_file(node_class): return '' def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): - if ndir_node.context != self.context: + if ndir_node and ndir_node.context != self.context: raise NotImplementedError("Cannot move files between contexts") if (not self.check_perms(8)) and ndir_node.check_perms(2): @@ -1205,11 +1205,11 @@ class node_file(node_class): if (not self.parent): # there *must* be a parent node for this one - self.parent = self.context.get_dir_node(cr, dbro.parent_id.id) + self.parent = self.context.get_dir_node(cr, dbro.parent_id) assert self.parent ret = {} - if self.parent != ndir_node: + if ndir_node and self.parent != ndir_node: if not (isinstance(self.parent, node_dir) and isinstance(ndir_node, node_dir)): logger.debug('Cannot move file %r from %r to %r', self, self.parent, ndir_node) raise NotImplementedError('Cannot move files between dynamic folders') From 2c1349111b1e823f2173e3023aa808c3472c9aa9 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Fri, 27 Aug 2010 10:38:58 +0300 Subject: [PATCH 02/12] Document: fixes from the old branch A context={} arg, get_file_node() improvement. Conflicts: document/nodes.py bzr revid: p_christ@hol.gr-20100827073858-x364kctd048dzmva --- addons/document/document_directory.py | 2 +- addons/document/nodes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index 8fdbac0a5db..3486359f183 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -110,7 +110,7 @@ class document_directory(osv.osv): ('no_selfparent', 'check(parent_id <> id)', 'Directory cannot be parent of itself!'), ('dir_parented', 'check(parent_id IS NOT NULL OR storage_id IS NOT NULL)', 'Directory must have a parent or a storage') ] - def name_get(self, cr, uid, ids, context={}): + def name_get(self, cr, uid, ids, context=None): res = [] if not self.search(cr,uid,[('id','in',ids)]): ids = [] diff --git a/addons/document/nodes.py b/addons/document/nodes.py index c78e0ece09f..b849396498d 100644 --- a/addons/document/nodes.py +++ b/addons/document/nodes.py @@ -121,7 +121,7 @@ class node_context(object): if fbro.parent_id: parent = self.get_dir_node(cr, fbro.parent_id) - return node_file(fbro.name,parent,self,fbro) + return node_file(fbro.name, parent, self, fbro) class node_descriptor(object): From 283ea41e47e4481a8a0ddac7d70e098d984cabc5 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Fri, 27 Aug 2010 10:39:17 +0300 Subject: [PATCH 03/12] doc ftp: enable ftp even before the module is fully installed. This is marginally correct, but the document_ftp module would cause its own tests to fail (because it's not installed yet) and thus won't allow access to the db. Then, a 'tests.fatal' setting means that the module will never install successfully! Ideally, the tests should be performed *after* the db is inited and module is fully loaded. But the yaml mechanism performs them too early for us. bzr revid: p_christ@hol.gr-20100827073917-g6jwwskgpnnwl855 --- addons/document_ftp/ftpserver/abstracted_fs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/document_ftp/ftpserver/abstracted_fs.py b/addons/document_ftp/ftpserver/abstracted_fs.py index 00f308ff022..cd942c1c09d 100644 --- a/addons/document_ftp/ftpserver/abstracted_fs.py +++ b/addons/document_ftp/ftpserver/abstracted_fs.py @@ -74,7 +74,7 @@ class abstracted_fs(object): if not cr.fetchone(): continue - cr.execute("SELECT id FROM ir_module_module WHERE name = 'document_ftp' AND state IN ('installed', 'to upgrade') ") + cr.execute("SELECT id FROM ir_module_module WHERE name = 'document_ftp' AND state IN ('installed', 'to-install', 'to upgrade') ") res = cr.fetchone() if res and len(res): self.db_name_list.append(db_name) @@ -287,7 +287,7 @@ class abstracted_fs(object): raise IOError(errno.EPERM, 'Cannot perform operation at root dir') dbname = p_parts[0] if dbname not in self.db_list(): - raise IOError(errno.ENOENT,'Invalid database path') + raise IOError(errno.ENOENT,'Invalid database path: %s' % dbname) try: db = pooler.get_db(dbname) except Exception: From 7098bbcae1027208a5e997ead75c441deba7dcd0 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Fri, 27 Aug 2010 10:39:50 +0300 Subject: [PATCH 04/12] doc ftp: Fix bdf1f16b77c60, typo at keyword string. bzr revid: p_christ@hol.gr-20100827073950-j95wl8ojuav8s1ej --- addons/document_ftp/ftpserver/abstracted_fs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/document_ftp/ftpserver/abstracted_fs.py b/addons/document_ftp/ftpserver/abstracted_fs.py index cd942c1c09d..f69a0bbbaad 100644 --- a/addons/document_ftp/ftpserver/abstracted_fs.py +++ b/addons/document_ftp/ftpserver/abstracted_fs.py @@ -74,7 +74,7 @@ class abstracted_fs(object): if not cr.fetchone(): continue - cr.execute("SELECT id FROM ir_module_module WHERE name = 'document_ftp' AND state IN ('installed', 'to-install', 'to upgrade') ") + cr.execute("SELECT id FROM ir_module_module WHERE name = 'document_ftp' AND state IN ('installed', 'to install', 'to upgrade') ") res = cr.fetchone() if res and len(res): self.db_name_list.append(db_name) From 6b70730393870cea1ce497fbe123495794532dfd Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Fri, 27 Aug 2010 10:39:52 +0300 Subject: [PATCH 05/12] Doc ftp: improve yaml tests, assert messages bzr revid: p_christ@hol.gr-20100827073952-j8eg9p1dndviwknn --- .../document_ftp/test/document_ftp_test2.yml | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/addons/document_ftp/test/document_ftp_test2.yml b/addons/document_ftp/test/document_ftp_test2.yml index e9ac2d84582..5a4df87fbe4 100644 --- a/addons/document_ftp/test/document_ftp_test2.yml +++ b/addons/document_ftp/test/document_ftp_test2.yml @@ -120,13 +120,23 @@ I delete the test2.txt from the server (RPC). - !delete { model: ir.attachment, id:, search: "[('name','=','test2.txt')]" } +- + I also commit, because ftp would run in a different transaction. +- + !python {model: ir.attachment}: | + cr.commit() - I check through FTP that test2.txt does not appear. - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te + import ftplib ftp = te.get_ftp_folder(cr, uid, self, 'Documents') - assert ftp.nlst("test2.txt") == [] + try: + nlst_result = ftp.nlst("test2.txt") + except ftplib.error_perm: # 550 error: 'path not exists' + nlst_result = [] + assert "test2.txt" not in nlst_result, "Files: %r" % nlst_result - I create a "test-name.txt" file - @@ -152,7 +162,7 @@ ftp = te.get_ftp_folder(cr, uid, self, 'Documents') try: res = ftp.nlst("test-name.txt") - assert res == [] + assert res == [], "File has not been renamed!" except error_perm, e: pass assert ftp.nlst("test-renamed.txt") == ['test-renamed.txt'] @@ -178,7 +188,7 @@ !python {model: ir.attachment}: | from document_ftp import test_easyftp as te ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2') - assert ftp.nlst("test3.txt") == ['test3.txt'] + assert ftp.nlst("test3.txt") == ['test3.txt'], "File test3.txt is not there!" - I create a new folder, 'Test-Folder3', through FTP I try to move test3.txt to 'Test-Folder3' @@ -211,10 +221,10 @@ from document_ftp import test_easyftp as te ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2') # TODO speed - assert len(ftp.nlst()) > 200 + assert len(ftp.nlst()) >= 200, "We haven't managed to store 200 files!" - I read the 200 files, check speed # TODO - I move the 200 files to 'Test-Folder2' - # TODO \ No newline at end of file + # TODO From 8a107a7e52e2b6fe423dd491f1c4c5fac44b99a9 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Fri, 27 Aug 2010 10:39:55 +0300 Subject: [PATCH 06/12] Document: fix unlink, where storage_id is not at first parent. The convention is that storage_id may exist at any level up the parent folders, so we have to recursively search for it. bzr revid: p_christ@hol.gr-20100827073955-eyja6mhhy7rt5peh --- addons/document/document.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/document/document.py b/addons/document/document.py index 46cf6d189c1..084d4bcd88d 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -240,7 +240,7 @@ class document_file(osv.osv): return bro.address_id.partner_id.id return False - def unlink(self, cr, uid, ids, context={}): + def unlink(self, cr, uid, ids, context=None): stor = self.pool.get('document.storage') unres = [] # We have to do the unlink in 2 stages: prepare a list of actual @@ -250,7 +250,15 @@ class document_file(osv.osv): for f in self.browse(cr, uid, ids, context): # TODO: update the node cache - r = stor.prepare_unlink(cr, uid, f.parent_id.storage_id, f) + par = f.parent_id + storage_id = None + while par: + if par.storage_id: + storage_id = par.storage_id + break + par = par.parent_id + assert storage_id, "Strange, found file #%s w/o storage!" % f.id + r = stor.prepare_unlink(cr, uid, storage_id, f) if r: unres.append(r) res = super(document_file, self).unlink(cr, uid, ids, context) From 892106b6f7265780a82420ce81886e66c76aaa70 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Sat, 28 Aug 2010 17:18:23 +0300 Subject: [PATCH 07/12] calendar: Don't assume the orm model is caldav-aware So, don't unconditionally call attributes like recurrent_id. bzr revid: p_christ@hol.gr-20100828141823-3nop8gmqfyt0h267 --- addons/caldav/calendar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py index 10c283213bd..9a4e948cbe1 100644 --- a/addons/caldav/calendar.py +++ b/addons/caldav/calendar.py @@ -598,7 +598,7 @@ class Calendar(CalDAV, osv.osv): data_ids = mod_obj.search(cr, uid, line_domain, order="id", context=context) for data in mod_obj.browse(cr, uid, data_ids, context): ctx = parent and parent.context or None - if data.recurrent_uid: + if hasattr(data, 'recurrent_uid') and data.recurrent_uid: # Skip for event which is child of other event continue node = res_node_calendar('%s.ics' %data.id, parent, ctx, data, line.object_id.model, data.id) From 1e2b779bf27afa46fa2d4c500e28ce2f3eb9b430 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Sat, 28 Aug 2010 17:18:40 +0300 Subject: [PATCH 08/12] mrp: minor fix in menus Remove a harmless duplicate, add the parent="", which would only work after a server patch. Nevertheless, state that this menu should be at root. bzr revid: p_christ@hol.gr-20100828141840-pm7trenbetwmzqm7 --- addons/mrp/mrp_view.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 4504de8a2cf..058cc99a7b6 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -2,9 +2,10 @@ - - + + @@ -910,7 +911,6 @@ src_model="product.product"/> - Date: Sat, 28 Aug 2010 17:18:47 +0300 Subject: [PATCH 09/12] idea: make yaml tests more robust Let the users have a more unique name (it happened that in my testing db I already had some "user1"), don't alter the "uid", let the users have the right group. bzr revid: p_christ@hol.gr-20100828141847-3pjg5fiplsm2rg4m --- addons/idea/test/test_idea.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/addons/idea/test/test_idea.yml b/addons/idea/test/test_idea.yml index 9646222cab4..a7099478932 100644 --- a/addons/idea/test/test_idea.yml +++ b/addons/idea/test/test_idea.yml @@ -35,28 +35,29 @@ !record {model: res.users, id: res_users_user0}: company_id: base.main_company context_lang: en_US - login: user1 - name: user1 + login: idea_user1 + name: Idea test user1 password: user1 + groups_id: [ base.group_tool_user, ] - | And I will also create user2. - !record {model: res.users, id: res_users_user1}: company_id: base.main_company context_lang: en_US - login: user2 - name: user2 + login: idea_user2 + name: Idea test user2 password: user2 - + groups_id: [ base.group_tool_user, ] - | In order to post vote I connect as user1 and open the idea page I click on "Submit Vote" wizard button and vote the idea as "Normal" - !python {model: idea.post.vote}: | - uid = ref('res_users_user0') - new_id = self.create(cr, uid, {'vote': 50}, {"active_ids": [ref("idea_idea_0")]}) - self.do_vote(cr, uid, [new_id], {"active_ids": [ref("idea_idea_0")]}) + uid2 = ref('res_users_user0') + new_id = self.create(cr, uid2, {'vote': 50}, {"active_ids": [ref("idea_idea_0")]}) + self.do_vote(cr, uid2, [new_id], {"active_ids": [ref("idea_idea_0")]}) - | To add other vote I connect as user2 and open the idea page. @@ -67,9 +68,9 @@ - !python {model: idea.post.vote}: | - uid = ref('res_users_user1') - new_id = self.create(cr, uid, {'vote': 100, 'note': 'We can learn many things from technical presentation'}, {"active_ids": [ref("idea_idea_0")]}) - self.do_vote(cr, uid, [new_id], {'active_ids': [ref('idea_idea_0')]}) + uid2 = ref('res_users_user1') + new_id = self.create(cr, uid2, {'vote': 100, 'note': 'We can learn many things from technical presentation'}, {"active_ids": [ref("idea_idea_0")]}) + self.do_vote(cr, uid2, [new_id], {'active_ids': [ref('idea_idea_0')]}) - | I can see that the Average score changed in "Average score" field with value 75 From 601804a87ba2af5da9a8d5f2f7d6e12ee19039c7 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Sat, 28 Aug 2010 17:18:49 +0300 Subject: [PATCH 10/12] crm, product: Tolerate missing shortcut for res_users.create() Those 2 addons try to attach a shortcur to every new user created. However, this data may be missing (eg. during the install of "product, idea" to a clean db). We shouldn't block the creation of users. bzr revid: p_christ@hol.gr-20100828141849-wzibtjq02cscg98v --- addons/crm/crm_meeting.py | 18 +++++++++++++----- addons/product/product.py | 22 +++++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py index d8acbff7555..5fc98053046 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -25,6 +25,7 @@ from datetime import datetime, timedelta from osv import fields, osv from tools.translate import _ import time +import logging class crm_lead(crm_case, osv.osv): """ CRM Leads """ @@ -178,13 +179,20 @@ class res_users(osv.osv): _name = 'res.users' _inherit = 'res.users' - def create(self, cr, uid, data, context={}): + def create(self, cr, uid, data, context=None): + if context is None: + context = {} user_id = super(res_users, self).create(cr, uid, data, context) data_obj = self.pool.get('ir.model.data') - data_id = data_obj._get_id(cr, uid, 'crm', 'ir_ui_view_sc_calendar0') - view_id = data_obj.browse(cr, uid, data_id, context=context).res_id - copy_id = self.pool.get('ir.ui.view_sc').copy(cr, uid, view_id, default = { - 'user_id': user_id}, context=context) + try: + data_id = data_obj._get_id(cr, uid, 'crm', 'ir_ui_view_sc_calendar0') + view_id = data_obj.browse(cr, uid, data_id, context=context).res_id + copy_id = self.pool.get('ir.ui.view_sc').copy(cr, uid, view_id, default = { + 'user_id': user_id}, context=context) + except ValueError: + # Tolerate a missing shortcut. See product/product.py for similar code. + logging.getLogger('orm').warning('Skipped Products shortcut for user "%s"', data.get('name',' Date: Sat, 28 Aug 2010 17:18:52 +0300 Subject: [PATCH 11/12] Doc ftp: Fix yaml test to follow expected behaviour The document.directory has the "resource_find_all" flag, which now defaults to True and means that a new doc in a resource folder will have the *root* Documents as a parent. Fix the test to expect that behaviour. bzr revid: p_christ@hol.gr-20100828141852-pyvd24rh1rptqf5f --- addons/document_ftp/test/document_ftp_test4.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/document_ftp/test/document_ftp_test4.yml b/addons/document_ftp/test/document_ftp_test4.yml index 9c3baed0844..eeed4b17dda 100644 --- a/addons/document_ftp/test/document_ftp_test4.yml +++ b/addons/document_ftp/test/document_ftp_test4.yml @@ -110,7 +110,7 @@ I check at the server that the file is attached to Partner1 - !assert {model: ir.attachment, id: , search: "[('name','=','pat1-dynamic.txt')]" }: - - parent_id.name == 'Partners of Test' + - parent_id.name == 'Documents' - res_model == 'res.partner' - res_id != False - From 54bff6fd4c7817cc1a0e4f97bd66575cbb342294 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 31 Aug 2010 01:38:47 +0300 Subject: [PATCH 12/12] account: fix yaml tests Logic at move creation must be more apparent. If move validation fails, the exception shall be propagated. Conflicts: account/test/account_customer_invoice.yml account/test/account_validate_account_move.yml bzr revid: p_christ@hol.gr-20100830223847-1afkt4kbilf5a2t8 --- addons/account/test/account_customer_invoice.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/test/account_customer_invoice.yml b/addons/account/test/account_customer_invoice.yml index f8798d7d9e3..0eaa3a688c6 100644 --- a/addons/account/test/account_customer_invoice.yml +++ b/addons/account/test/account_customer_invoice.yml @@ -37,7 +37,7 @@ - !python {model: account.invoice}: | acc_id=self.browse(cr, uid, ref("account_invoice_customer0")) - assert acc_id.move_id, "Move not created" + assert (not acc_id.move_id), "Move falsely created at pro-forma" - I create invoice by clicking on Create button - @@ -53,7 +53,7 @@ - !python {model: account.invoice}: | acc_id=self.browse(cr, uid, ref("account_invoice_customer0")) - assert acc_id.move_id, "Move created" + assert acc_id.move_id, "Move not created for open invoice" - I create a record for partial payment of 1000 EUR. -