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. - 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) 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',' 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 cf590dafdad..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): @@ -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') diff --git a/addons/document_ftp/ftpserver/abstracted_fs.py b/addons/document_ftp/ftpserver/abstracted_fs.py index 00f308ff022..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 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: 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 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 - 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 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"/> -