← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-server/ysa-server-framework into lp:openobject-server

 

Ysa(Open ERP) has proposed merging lp:~openerp-dev/openobject-server/ysa-server-framework into lp:openobject-server.

Requested reviews:
  Olivier Dony (OpenERP) (odo)
  xrg (xrg)
Related bugs:
  #631547 Errors creating drop down lists - stops customisation
  https://bugs.launchpad.net/bugs/631547
  #632927 User password should not be displayed/sent
  https://bugs.launchpad.net/bugs/632927
  #670264 Default value for lang of partners according to installation language
  https://bugs.launchpad.net/bugs/670264
  #672886 crash system report in testing and reports
  https://bugs.launchpad.net/bugs/672886
  #675681 Configuration window : spacing issue between text and progress bar
  https://bugs.launchpad.net/bugs/675681
  #686561 Demo and Admin users share the same address by default, preventing different emails to be set
  https://bugs.launchpad.net/bugs/686561
  #692891 Can delete a pricelist still linked to a partner
  https://bugs.launchpad.net/bugs/692891
  #695338 Assert tag contains an expr wtih wrong field of res.currency object.
  https://bugs.launchpad.net/bugs/695338
  #695678 [trunk] Unable to edit the path for web icon or web icon hover.
  https://bugs.launchpad.net/bugs/695678

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/ysa-server-framework/+merge/45029

Solved the following bug:-
https://bugs.launchpad.net/openobject-server/+bug/670264
https://bugs.launchpad.net/openobject-server/+bug/692891
https://bugs.launchpad.net/openobject-server/+bug/695678

https://bugs.launchpad.net/openobject-server/+bug/631547


improve change user password wizard.
-- 
https://code.launchpad.net/~openerp-dev/openobject-server/ysa-server-framework/+merge/45029
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-server/ysa-server-framework.
=== modified file 'bin/addons/base/base_data.xml'
--- bin/addons/base/base_data.xml	2010-12-29 19:03:47 +0000
+++ bin/addons/base/base_data.xml	2011-01-03 13:33:30 +0000
@@ -28,6 +28,8 @@
             <field name="translatable">True</field>
         </record>
 
+        <function name="install_lang" model="res.lang"/>
+
         <record id="ad" model="res.country">
             <field name="name">Andorra, Principality of</field>
             <field name="code">ad</field>

=== modified file 'bin/addons/base/base_update.xml'
--- bin/addons/base/base_update.xml	2010-12-30 04:18:32 +0000
+++ bin/addons/base/base_update.xml	2011-01-03 13:33:30 +0000
@@ -70,34 +70,6 @@
     ======================
     -->
 
-        <record id="view_change_user_password_form" model="ir.ui.view">
-            <field name="name">change.user.password</field>
-            <field name="model">change.user.password</field>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <form string="Change Password">
-                    <field name="current_password" password="True" readonly="0" colspan="4"/>
-                    <field name="new_password" password="True" readonly="0" colspan="4"/>
-                    <field name="confirm_password" password="True" readonly="0" colspan="4"/>
-                    <label colspan="1" string=""/>
-                    <label colspan="3" string="You must logout and login again after changing your password."/>
-                    <separator colspan="4" />
-                    <label align="0.0" colspan="2" string=""/>
-                    <button colspan="1" icon="gtk-cancel" special="cancel" string="Cancel"/>
-                    <button colspan="1" icon="gtk-ok" name="change_password" string="Change" type="object"/>
-                </form>
-            </field>
-        </record>
-
-        <record id="action_view_change_password_form" model="ir.actions.act_window">
-            <field name="name">Change Password</field>
-            <field name="type">ir.actions.act_window</field>
-            <field name="res_model">change.user.password</field>
-            <field name="view_type">form</field>
-            <field name="view_mode">form</field>
-            <field name="target">new</field>
-        </record>
-
         <record id="view_users_form_simple_modif" model="ir.ui.view">
             <field name="name">res.users.form.modif</field>
             <field name="model">res.users</field>
@@ -119,8 +91,6 @@
                             <field name="context_lang" completion="1" readonly="0"/>
                             <field name="context_tz" completion="1" readonly="0"/>
                             <field name="menu_tips" colspan="2" readonly="0"/>
-                            <label string="" colspan="1"/>
-                            <button name="%(action_view_change_password_form)d" string="Change Password" type="action" icon="gtk-execute"/>
                             <separator string="Email &amp; Signature" colspan="4"/>
                             <group colspan="4"><field name="user_email" widget="email" readonly="0"/></group>
                             <field colspan="4" name="signature" readonly="0" nolabel="1"/>

=== modified file 'bin/addons/base/ir/ir_model.py'
--- bin/addons/base/ir/ir_model.py	2010-12-29 12:44:27 +0000
+++ bin/addons/base/ir/ir_model.py	2011-01-03 13:33:30 +0000
@@ -185,6 +185,26 @@
         'selectable': lambda *a: 1,
     }
     _order = "name"
+
+    def _check_selection(self, cr, uid, ids, context=None):
+        obj = self.browse(cr, uid, ids[0], context=context)
+        try:
+            temp = eval(obj.selection)
+        except Exception:
+            raise except_orm(_('Error'), _("Given key and value in not allowed!"))
+
+        if (not isinstance(temp,list)) or (isinstance(temp,list) and not temp):
+            return False
+        elif temp:
+            for tpl in temp:
+                 if not isinstance(tpl,tuple) or (isinstance(tpl,tuple) and len(tpl) != 2):
+                    return False
+        return True
+
+    _constraints = [
+        (_check_selection, 'Wrong format specified for a field of type selection, it should be [(key,value)]', ['selection'])
+    ]
+
     def _size_gt_zero_msg(self, cr, user, ids, context=None):
         return _('Size of the field can never be less than 1 !')
 

=== modified file 'bin/addons/base/ir/ir_ui_menu.py'
--- bin/addons/base/ir/ir_ui_menu.py	2010-12-29 09:47:54 +0000
+++ bin/addons/base/ir/ir_ui_menu.py	2011-01-03 13:33:30 +0000
@@ -257,8 +257,10 @@
     def read_image(self, path):
         path_info = path.split(',')
         icon_path = addons.get_module_resource(path_info[0],path_info[1])
-        icon = tools.file_open(icon_path,'rb').read()
-        return base64.encodestring(icon)
+        if icon_path:
+            icon = tools.file_open(icon_path,'rb').read()
+            icon_image = base64.encodestring(icon)
+        return icon_image
 
     def _get_image_icon(self, cr, uid, ids, name, args, context=None):
         res = {}

=== modified file 'bin/addons/base/res/partner/partner.py'
--- bin/addons/base/res/partner/partner.py	2010-12-22 18:39:26 +0000
+++ bin/addons/base/res/partner/partner.py	2011-01-03 13:33:30 +0000
@@ -138,7 +138,7 @@
         'email': fields.related('address', 'email', type='char', size=240, string='E-mail'),
         'company_id': fields.many2one('res.company', 'Company', select=1),
     }
-    
+
     def _default_category(self, cr, uid, context={}):
         if 'category_id' in context and context['category_id']:
             return [context['category_id']]

=== modified file 'bin/addons/base/res/res_lang.py'
--- bin/addons/base/res/res_lang.py	2010-12-09 15:04:42 +0000
+++ bin/addons/base/res/res_lang.py	2011-01-03 13:33:30 +0000
@@ -24,10 +24,63 @@
 import tools
 from tools.safe_eval import safe_eval as eval
 from tools.translate import _
+import locale
+import logging
+
 class lang(osv.osv):
     _name = "res.lang"
     _description = "Languages"
 
+    def install_lang(self, cr, uid, **args):
+        lang_ids = self.search(cr, uid, [('code','=', tools.config.get('lang'))])
+        if not lang_ids:
+            lang_id = self.load_lang(cr, uid, tools.config.get('lang'))
+        return True
+
+    def load_lang(self, cr, uid, lang, lang_name=None):
+        # create the language with locale information
+        fail = True
+        logger = logging.getLogger('i18n')
+        iso_lang = tools.get_iso_codes(lang)
+        for ln in tools.get_locales(lang):
+            try:
+                locale.setlocale(locale.LC_ALL, str(ln))
+                fail = False
+                break
+            except locale.Error:
+                continue
+        if fail:
+            lc = locale.getdefaultlocale()[0]
+            msg = 'Unable to get information for locale %s. Information from the default locale (%s) have been used.'
+            logger.warning(msg, lang, lc)
+
+        if not lang_name:
+            lang_name = tools.get_languages().get(lang, lang)
+
+
+        def fix_xa0(s):
+            if s == '\xa0':
+                return '\xc2\xa0'
+            return s
+
+        lang_info = {
+            'code': lang,
+            'iso_code': iso_lang,
+            'name': lang_name,
+            'translatable': 1,
+            'date_format' : str(locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y')),
+            'time_format' : str(locale.nl_langinfo(locale.T_FMT)),
+            'decimal_point' : fix_xa0(str(locale.localeconv()['decimal_point'])),
+            'thousands_sep' : fix_xa0(str(locale.localeconv()['thousands_sep'])),
+        }
+        lang_id = False
+        try:
+            lang_id = self.create(cr, uid, lang_info)
+            self.pool.get('ir.values').set(cr, uid, 'default', False, 'lang', ['res.partner'], lang)
+        finally:
+            tools.resetlocale()
+        return lang_id
+
     def _get_default_date_format(self,cursor,user,context={}):
         return '%m/%d/%Y'
 
@@ -69,7 +122,7 @@
         thousands_sep = lang_obj.thousands_sep or conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
         decimal_point = lang_obj.decimal_point
         grouping = lang_obj.grouping
-        return (grouping, thousands_sep, decimal_point)        
+        return (grouping, thousands_sep, decimal_point)
 
     def write(self, cr, uid, ids, vals, context=None):
         for lang_id in ids :
@@ -95,19 +148,19 @@
 
     def _group(self, cr, uid, ids, s, monetary=False, grouping=False, thousands_sep=''):
         grouping = eval(grouping)
-        
+
         if not grouping:
             return (s, 0)
 
         result = ""
         seps = 0
         spaces = ""
-        
+
         if s[-1] == ' ':
             sp = s.find(' ')
             spaces = s[sp:]
             s = s[:sp]
-            
+
         while s and grouping:
             # if grouping is -1, we are done
             if grouping[0] == -1:
@@ -139,7 +192,7 @@
         if percent[0] != '%':
             raise ValueError("format() must be given exactly one %char format specifier")
 
-        lang_grouping, thousands_sep, decimal_point = self._lang_data_get(cr, uid, ids[0], monetary)        
+        lang_grouping, thousands_sep, decimal_point = self._lang_data_get(cr, uid, ids[0], monetary)
 
         formatted = percent % value
         # floats and decimal ints need special action!

=== modified file 'bin/addons/base/res/res_user.py'
--- bin/addons/base/res/res_user.py	2010-12-29 20:12:50 +0000
+++ bin/addons/base/res/res_user.py	2011-01-03 13:33:30 +0000
@@ -476,6 +476,13 @@
         finally:
             cr.close()
 
+    def change_password(self, cr, uid, ids, old_passwd, new_passwd):
+        if self.browse(cr, uid, uid).password != old_passwd:
+            raise  osv.except_osv(_('AccessDenied'), 'The old password does not match !')
+        else:
+            self.write(cr, uid, uid, {'password': new_passwd})
+        return True
+
 users()
 
 class config_users(osv.osv_memory):
@@ -574,39 +581,4 @@
 
 res_config_view()
 
-class change_user_password(osv.osv_memory):
-    _name = 'change.user.password'
-    _columns = {
-        'current_password':fields.char('Current Password', size=64, required=True, help="Enter your current password."),
-        'new_password': fields.char('New Password', size=64, required=True, help="Enter the new password."),
-        'confirm_password': fields.char('Confirm Password', size=64, required=True, help="Enter the new password again for confirmation."),
-    }
-    _defaults={
-        'current_password' : '',
-        'new_password' : '',
-        'confirm_password' : '',
-    }
-
-    def change_password(self, cr, uid, ids, context=None):
-        for form_id in ids:
-            password_rec = self.browse(cr, uid, form_id, context)
-            if password_rec.new_password != password_rec.confirm_password:
-                raise osv.except_osv(_('Error !'), _('The new and confirmation passwords do not match, please double-check them.'))
-
-            # Validate current password without reading it from database,
-            # as it could be stored differently (LDAP, encrypted/hashed, etc.)
-            is_correct_password = False
-            try:
-                user_obj = self.pool.get('res.users')
-                is_correct_password = user_obj.check(cr.dbname, uid, password_rec.current_password)
-            except Exception:
-                pass
-            if not is_correct_password:
-                raise osv.except_osv(_('Error !'), _('The current password does not match, please double-check it.'))
-            user_obj.write(cr, uid, [uid], {'password': password_rec.new_password}, context=context)
-        return {}
-
-change_user_password()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== modified file 'bin/osv/fields.py'
--- bin/osv/fields.py	2010-12-28 16:07:28 +0000
+++ bin/osv/fields.py	2011-01-03 13:33:30 +0000
@@ -553,7 +553,7 @@
                       DeprecationWarning, stacklevel=2)
         obj = obj.pool.get(self._obj)
 
-        # static domains are lists, and are evaluated both here and on client-side, while string 
+        # static domains are lists, and are evaluated both here and on client-side, while string
         # domains supposed by dynamic and evaluated on client-side only (thus ignored here)
         # FIXME: make this distinction explicit in API!
         domain = isinstance(self._domain, list) and self._domain or []
@@ -1049,7 +1049,8 @@
         brs = properties.browse(cr, uid, nids, context=context)
         for prop in brs:
             value = properties.get_by_record(cr, uid, prop, context=context)
-            res[prop.res_id.id][prop.fields_id.name] = value or False
+            avil_id = obj.pool.get(value._name).exists(cr, uid, value.id)
+            res[prop.res_id.id][prop.fields_id.name] = (avil_id and value) and value or False
             if value and (prop.type == 'many2one'):
                 replaces.setdefault(value._name, {})
                 replaces[value._name][value.id] = True

=== modified file 'bin/service/web_services.py'
--- bin/service/web_services.py	2010-12-14 16:30:03 +0000
+++ bin/service/web_services.py	2011-01-03 13:33:30 +0000
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 ##############################################################################
-#    
+#
 #    OpenERP, Open Source Management Solution
 #    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
 #
@@ -15,7 +15,7 @@
 #    GNU Affero General Public License for more details.
 #
 #    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 
@@ -50,8 +50,8 @@
         self._pg_psw_env_var_is_set = False # on win32, pg_dump need the PGPASSWORD env var
 
     def dispatch(self, method, auth, params):
-        if method in [ 'create', 'get_progress', 'drop', 'dump', 
-            'restore', 'rename', 
+        if method in [ 'create', 'get_progress', 'drop', 'dump',
+            'restore', 'rename',
             'change_admin_password', 'migrate_databases' ]:
             passwd = params[0]
             params = params[1:]
@@ -64,7 +64,7 @@
             raise KeyError("Method not found: %s" % method)
         fn = getattr(self, 'exp_'+method)
         return fn(*params)
-    
+
     def new_dispatch(self,method,auth,params):
         pass
     def _create_empty_database(self, name):
@@ -93,6 +93,7 @@
                     serv.actions[id]['progress'] = 0
                     cr = sql_db.db_connect(db_name).cursor()
                     tools.init_db(cr)
+                    tools.config['lang'] = lang
                     cr.commit()
                     cr.close()
                     cr = None
@@ -392,7 +393,7 @@
             security.check_super(passwd)
         else:
             raise Exception("Method not found: %s" % method)
-        
+
         fn = getattr(self, 'exp_'+method)
         return fn(*params)
 
@@ -568,7 +569,7 @@
 
     def exp_check_connectivity(self):
         return bool(sql_db.db_connect('template1'))
-        
+
     def exp_get_os_time(self):
         return os.times()
 
@@ -598,7 +599,7 @@
         res = fn(db, uid, *params)
         return res
 
-    
+
     def new_dispatch(self,method,auth,params):
         pass
 
@@ -634,7 +635,7 @@
         fn = getattr(self, 'exp_'+method)
         res = fn(db, uid, *params)
         return res
-    
+
     def new_dispatch(self,method,auth,params):
         pass
 
@@ -697,7 +698,7 @@
         res = fn(db, uid, *params)
         return res
 
-    
+
     def new_dispatch(self,method,auth,params):
         pass
 
@@ -728,7 +729,7 @@
                 self._reports[id]['format'] = format
                 self._reports[id]['state'] = True
             except Exception, exception:
-                
+
                 tb = sys.exc_info()
                 tb_s = "".join(traceback.format_exception(*tb))
                 logger = netsvc.Logger()

=== modified file 'bin/tools/translate.py'
--- bin/tools/translate.py	2010-12-29 18:58:33 +0000
+++ bin/tools/translate.py	2011-01-03 13:33:30 +0000
@@ -347,7 +347,7 @@
 
         if name is None:
             if not fuzzy:
-                self.warn('Missing "#:" formated comment at line %d for the following source:\n\t%s', 
+                self.warn('Missing "#:" formated comment at line %d for the following source:\n\t%s',
                         self.cur_line(), source[:30])
             return self.next()
         return type, name, res_id, source, trad
@@ -541,9 +541,9 @@
 
     query = 'SELECT name, model, res_id, module'    \
             '  FROM ir_model_data'
-            
-    query_models = """SELECT m.id, m.model, imd.module 
-            FROM ir_model AS m, ir_model_data AS imd 
+
+    query_models = """SELECT m.id, m.model, imd.module
+            FROM ir_model AS m, ir_model_data AS imd
             WHERE m.id = imd.res_id AND imd.model = 'ir.model' """
 
     if 'all_installed' in modules:
@@ -861,42 +861,7 @@
 
         if not ids:
             # lets create the language with locale information
-            fail = True
-            for ln in get_locales(lang):
-                try:
-                    locale.setlocale(locale.LC_ALL, str(ln))
-                    fail = False
-                    break
-                except locale.Error:
-                    continue
-            if fail:
-                lc = locale.getdefaultlocale()[0]
-                msg = 'Unable to get information for locale %s. Information from the default locale (%s) have been used.'
-                logger.warning(msg, lang, lc)
-
-            if not lang_name:
-                lang_name = tools.get_languages().get(lang, lang)
-
-            def fix_xa0(s):
-                if s == '\xa0':
-                    return '\xc2\xa0'
-                return s
-
-            lang_info = {
-                'code': lang,
-                'iso_code': iso_lang,
-                'name': lang_name,
-                'translatable': 1,
-                'date_format' : str(locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y')),
-                'time_format' : str(locale.nl_langinfo(locale.T_FMT)),
-                'decimal_point' : fix_xa0(str(locale.localeconv()['decimal_point'])),
-                'thousands_sep' : fix_xa0(str(locale.localeconv()['thousands_sep'])),
-            }
-
-            try:
-                lang_obj.create(cr, uid, lang_info)
-            finally:
-                resetlocale()
+            lang_obj.load_lang(cr, 1, lang=lang, lang_name=lang_name)
 
 
         # now, the serious things: we read the language file


Follow ups