← 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:
  xrg (xrg)
Related bugs:
  #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

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

Solved the following bug:-
https://bugs.launchpad.net/openobject-server/+bug/670264
https://bugs.launchpad.net/openobject-server/+bug/692891
-- 
https://code.launchpad.net/~openerp-dev/openobject-server/ysa-server-framework/+merge/44944
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	2010-12-31 06:31:25 +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/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	2010-12-31 06:31:25 +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']]
@@ -149,6 +149,7 @@
         'customer': lambda *a: 1,
         'category_id': _default_category,
         'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'res.partner', context=c),
+        'lang': lambda self, cr, uid, context: context.get('lang',False) or tools.config.get('lang', False)
     }
     def copy(self, cr, uid, id, default={}, context={}):
         name = self.read(cr, uid, [id], ['name'])[0]['name']

=== 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	2010-12-31 06:31:25 +0000
@@ -24,10 +24,62 @@
 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):
+        avil_ids = self.search(cr, uid, [('code','=', tools.config.get('lang'))])
+        if not avil_ids:
+            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'])),
+        }
+
+        try:
+            self.create(cr, uid, lang_info)
+        finally:
+            tools.resetlocale()
+        return True
+
     def _get_default_date_format(self,cursor,user,context={}):
         return '%m/%d/%Y'
 
@@ -69,7 +121,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 +147,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 +191,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/osv/fields.py'
--- bin/osv/fields.py	2010-12-28 16:07:28 +0000
+++ bin/osv/fields.py	2010-12-31 06:31:25 +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).search(cr, uid, [('id','=',value.id)], context=context)
+            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	2010-12-31 06:31:25 +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	2010-12-31 06:31:25 +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