diff --git a/addons/account/account.py b/addons/account/account.py index 3537c4f4c55..b87caf547ab 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -840,16 +840,11 @@ class account_journal(osv.osv): def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): if not args: args = [] - if context is None: - context = {} - ids = [] - if context.get('journal_type', False): - args += [('type','=',context.get('journal_type'))] - if name: - ids = self.search(cr, user, [('code', 'ilike', name)]+ args, limit=limit, context=context) - if not ids: - ids = self.search(cr, user, [('name', 'ilike', name)]+ args, limit=limit, context=context)#fix it ilike should be replace with operator - + if operator in expression.NEGATIVE_TERM_OPERATORS: + domain = [('code', operator, name), ('name', operator, name)] + else: + domain = ['|', ('code', operator, name), ('name', operator, name)] + ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context) return self.name_get(cr, user, ids, context=context) @@ -938,13 +933,11 @@ class account_fiscalyear(osv.osv): def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): if args is None: args = [] - if context is None: - context = {} - ids = [] - if name: - ids = self.search(cr, user, [('code', 'ilike', name)]+ args, limit=limit) - if not ids: - ids = self.search(cr, user, [('name', operator, name)]+ args, limit=limit) + if operator in expression.NEGATIVE_TERM_OPERATORS: + domain = [('code', operator, name), ('name', operator, name)] + else: + domain = ['|', ('code', operator, name), ('name', operator, name)] + ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context) return self.name_get(cr, user, ids, context=context) @@ -1040,19 +1033,11 @@ class account_period(osv.osv): def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): if args is None: args = [] - if context is None: - context = {} - ids = [] - if name: - ids = self.search(cr, user, - [('code', 'ilike', name)] + args, - limit=limit, - context=context) - if not ids: - ids = self.search(cr, user, - [('name', operator, name)] + args, - limit=limit, - context=context) + if operator in expression.NEGATIVE_TERM_OPERATORS: + domain = [('code', operator, name), ('name', operator, name)] + else: + domain = ['|', ('code', operator, name), ('name', operator, name)] + ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context) return self.name_get(cr, user, ids, context=context) def write(self, cr, uid, ids, vals, context=None): @@ -1187,36 +1172,6 @@ class account_move(osv.osv): 'company_id': company_id, } - def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): - """ - Returns a list of tupples containing id, name, as internally it is called {def name_get} - result format: {[(id, name), (id, name), ...]} - - @param cr: A database cursor - @param user: ID of the user currently logged in - @param name: name to search - @param args: other arguments - @param operator: default operator is 'ilike', it can be changed - @param context: context arguments, like lang, time zone - @param limit: Returns first 'n' ids of complete result, default is 80. - - @return: Returns a list of tuples containing id and name - """ - - if not args: - args = [] - ids = [] - if name: - ids += self.search(cr, user, [('name','ilike',name)]+args, limit=limit, context=context) - - if not ids and name and type(name) == int: - ids += self.search(cr, user, [('id','=',name)]+args, limit=limit, context=context) - - if not ids: - ids += self.search(cr, user, args, limit=limit, context=context) - - return self.name_get(cr, user, ids, context=context) - def name_get(self, cursor, user, ids, context=None): if isinstance(ids, (int, long)): ids = [ids] @@ -1842,10 +1797,12 @@ class account_tax_code(osv.osv): def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): if not args: args = [] - if context is None: - context = {} - ids = self.search(cr, user, ['|',('name',operator,name),('code',operator,name)] + args, limit=limit, context=context) - return self.name_get(cr, user, ids, context) + if operator in expression.NEGATIVE_TERM_OPERATORS: + domain = [('code', operator, name), ('name', operator, name)] + else: + domain = ['|', ('code', operator, name), ('name', operator, name)] + ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context) + return self.name_get(cr, user, ids, context=context) def name_get(self, cr, uid, ids, context=None): if isinstance(ids, (int, long)): @@ -1974,15 +1931,11 @@ class account_tax(osv.osv): """ if not args: args = [] - if context is None: - context = {} - ids = [] - if name: - ids = self.search(cr, user, [('description', '=', name)] + args, limit=limit, context=context) - if not ids: - ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit, context=context) + if operator in expression.NEGATIVE_TERM_OPERATORS: + domain = [('description', operator, name), ('name', operator, name)] else: - ids = self.search(cr, user, args, limit=limit, context=context or {}) + domain = ['|', ('description', operator, name), ('name', operator, name)] + ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context) return self.name_get(cr, user, ids, context=context) def write(self, cr, uid, ids, vals, context=None): diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index effc2b03f61..f7e561c8e24 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -226,7 +226,7 @@ class account_invoice(osv.osv): }, } _columns = { - 'name': fields.char('Description', size=64, select=True, readonly=True, states={'draft':[('readonly',False)]}), + 'name': fields.char('Reference/Description', size=64, select=True, readonly=True, states={'draft':[('readonly',False)]}), 'origin': fields.char('Source Document', size=64, help="Reference of the document that produced this invoice.", readonly=True, states={'draft':[('readonly',False)]}), 'supplier_invoice_number': fields.char('Supplier Invoice Number', size=64, help="The reference of this invoice as provided by the supplier.", readonly=True, states={'draft':[('readonly',False)]}), 'type': fields.selection([ @@ -672,25 +672,14 @@ class account_invoice(osv.osv): self.create_workflow(cr, uid, ids) return True - # ---------------------------------------- - # Mail related methods - # ---------------------------------------- - - def _get_formview_action(self, cr, uid, id, context=None): + def get_formview_id(self, cr, uid, id, context=None): """ Update form view id of action to open the invoice """ - action = super(account_invoice, self)._get_formview_action(cr, uid, id, context=context) obj = self.browse(cr, uid, id, context=context) if obj.type == 'in_invoice': model, view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'invoice_supplier_form') - action.update({ - 'views': [(view_id, 'form')], - }) else: model, view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'invoice_form') - action.update({ - 'views': [(view_id, 'form')], - }) - return action + return view_id # Workflow stuff ################# diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index e58cf7721c7..b521f3ff48c 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -404,7 +404,7 @@ - + diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 48d6320fbc3..c29371e4c44 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1628,6 +1628,7 @@ +