[MERGE] Forward-port of latest 7.0 bugfixes, up to rev. 9684 rev-id: dle@openerp...
authorDenis Ledoux <dle@openerp.com>
Mon, 9 Dec 2013 15:57:21 +0000 (16:57 +0100)
committerDenis Ledoux <dle@openerp.com>
Mon, 9 Dec 2013 15:57:21 +0000 (16:57 +0100)
bzr revid: chs@openerp.com-20131202105848-33gcz1715w370rve
bzr revid: dle@openerp.com-20131204150643-is3y0b9n8enh3yql
bzr revid: chs@openerp.com-20131206152726-pirikn7v8pev90ic
bzr revid: dle@openerp.com-20131206162437-b9niay99mirk44qm
bzr revid: tde@openerp.com-20131209102019-kjeg0rx2au1d5e5v
bzr revid: dle@openerp.com-20131209155721-589zihxx8jmvlpvp

1  2 
addons/account/account.py
addons/account/account_move_line.py
addons/mail/mail_thread.py
addons/point_of_sale/static/src/js/devices.js
openerp/addons/base/ir/ir_attachment.py
openerp/addons/base/res/res_config.py
openerp/addons/base/res/res_users_view.xml
openerp/osv/fields.py
openerp/osv/orm.py
openerp/tools/convert.py

@@@ -27,8 -27,8 +27,8 @@@ import tim
  
  import openerp
  from openerp import SUPERUSER_ID
 -from openerp import pooler, tools
 +from openerp import tools
- from openerp.osv import fields, osv
+ from openerp.osv import fields, osv, expression
  from openerp.tools.translate import _
  from openerp.tools.float_utils import float_round
  
Simple merge
@@@ -247,19 -188,12 +247,16 @@@ class mail_thread(osv.AbstractModel)
                  new = set(command[2])
  
          # remove partners that are no longer followers
-         fol_ids = fol_obj.search(cr, SUPERUSER_ID,
-             [('res_model', '=', self._name), ('res_id', '=', id), ('partner_id', 'not in', list(new))])
-         fol_obj.unlink(cr, SUPERUSER_ID, fol_ids)
+         self.message_unsubscribe(cr, uid, [id], list(old-new))
  
          # add new followers
-         for partner_id in new - old:
-             fol_obj.create(cr, SUPERUSER_ID, {'res_model': self._name, 'res_id': id, 'partner_id': partner_id})
+         self.message_subscribe(cr, uid, [id], list(new-old))
  
      def _search_followers(self, cr, uid, obj, name, args, context):
 +        """Search function for message_follower_ids
 +
 +        Do not use with operator 'not in'. Use instead message_is_followers
 +        """
          fol_obj = self.pool.get('mail.followers')
          res = []
          for field, operator, value in args:
@@@ -550,48 -430,44 +550,49 @@@ function openerp_pos_devices(instance,m
          // starts catching keyboard events and tries to interpret codebar 
          // calling the callbacks when needed.
          connect: function(){
 +
              var self = this;
 -            var codeNumbers = [];
 -            var timeStamp = 0;
 -            var lastTimeStamp = 0;
 +            var code = "";
 +            var timeStamp  = 0;
 +            var onlynumbers = true;
 +            var timeout = null;
  
 -            // The barcode readers acts as a keyboard, we catch all keyup events and try to find a 
 -            // barcode sequence in the typed keys, then act accordingly.
              this.handler = function(e){
 +
                  if(e.which === 13){ //ignore returns
+                     e.preventDefault();
                      return;
                  }
 -                //We only care about numbers
 -                if (e.which >= 48 && e.which < 58){
 -
 -                    // The barcode reader sends keystrokes with a specific interval.
 -                    // We look if the typed keys fit in the interval. 
 -                    if (codeNumbers.length === 0) {
 -                        timeStamp = new Date().getTime();
 -                    } else {
 -                        if (lastTimeStamp + 30 < new Date().getTime()) {
 -                            // not a barcode reader
 -                            codeNumbers = [];
 -                            timeStamp = new Date().getTime();
 -                        }
 -                    }
 -                    codeNumbers.push(e.which - 48);
 -                    lastTimeStamp = new Date().getTime();
 -                    if (codeNumbers.length === 13) {
 -                        //We have found what seems to be a valid codebar
 -                        self.on_ean(codeNumbers.join(''));
 -                        codeNumbers = [];
 -                    }
 -                } else {
 -                    // NaN
 -                    codeNumbers = [];
 +
 +                if(timeStamp + 50 < new Date().getTime()){
 +                    code = "";
 +                    onlynumbers = true;
                  }
 +
 +                timeStamp = new Date().getTime();
 +                clearTimeout(timeout);
 +
 +                if( e.which < 48 || e.which >= 58 ){ // not a number
 +                    onlynumbers = false;
 +                }
 +
 +                code += String.fromCharCode(e.which);
 +
 +                // we wait for a while after the last input to be sure that we are not mistakingly
 +                // returning a code which is a prefix of a bigger one :
 +                // Internal Ref 5449 vs EAN13 5449000...
 +
 +                timeout = setTimeout(function(){
 +                    if(code.length === 13 && onlynumbers){
 +                        self.scan('ean13',code);
 +                    }else if(code.length >= 3 && self.pos.db.get_product_by_reference(code)){
 +                        self.scan('reference',code);
 +                    }
 +                    code = "";
 +                    onlynumbers = true;
 +                },100);
              };
 +
              $('body').on('keypress', this.handler);
          },
  
@@@ -242,6 -242,8 +242,8 @@@ class ir_attachment(osv.osv)
          # performed in batch as much as possible.
          ima = self.pool.get('ir.model.access')
          for model, targets in model_attachments.iteritems():
 -            if not self.pool.get(model):
++            if model not in self.pool:
+                 continue
              if not ima.check(cr, uid, model, 'read', False):
                  # remove all corresponding attachment ids
                  for attach_id in itertools.chain(*targets.values()):
@@@ -533,8 -531,11 +533,12 @@@ class res_config_settings(osv.osv_memor
          return res
  
      def execute(self, cr, uid, ids, context=None):
+         if uid != SUPERUSER_ID and not self.pool['res.users'].has_group(cr, uid, 'base.group_erp_manager'):
+             raise openerp.exceptions.AccessError(_("Only administrators can change the settings"))
 -        ir_values = self.pool.get('ir.values')
 -        ir_module = self.pool.get('ir.module.module')
 +        ir_values = self.pool['ir.values']
 +        ir_module = self.pool['ir.module.module']
++
          classified = self._get_classified_fields(cr, uid, context)
  
          config = self.browse(cr, uid, ids[0], context)
              <field eval="18" name="priority"/>
              <field name="arch" type="xml">
                  <form string="Users" version="7.0">
-                     <field name="image" widget='image' class="oe_right oe_avatar" options='{"preview_image": "image_small"}'/>
+                     <field name="image" readonly="0" widget='image' class="oe_right oe_avatar" options='{"preview_image": "image_small"}'/>
                      <h1>
                          <field name="name" readonly="1" class="oe_inline"/>
 -                        (<field name="login" readonly="1" class="oe_inline"/>)
                      </h1>
                      <button name="preference_change_password" type="object" string="Change password" class="oe_link"/>
                      <group name="preferences" col="4">
Simple merge
Simple merge
@@@ -941,18 -918,16 +941,18 @@@ def convert_csv_import(cr, module, fnam
      uid = 1
      datas = []
      for line in reader:
 -        if (not line) or not reduce(lambda x,y: x or y, line) :
 +        if not (line and any(line)):
              continue
          try:
 -            datas.append(map(lambda x: misc.ustr(x), line))
 +            datas.append(map(misc.ustr, line))
          except:
              _logger.error("Cannot import the line: %s", line)
 -    result, rows, warning_msg, dummy = pool.get(model).import_data(cr, uid, fields, datas,mode, module, noupdate, filename=fname_partial)
 +
 +    registry = openerp.registry(cr.dbname)
 +    result, rows, warning_msg, dummy = registry[model].import_data(cr, uid, fields, datas,mode, module, noupdate, filename=fname_partial)
      if result < 0:
          # Report failed import and abort module install
-         raise Exception(_('Module loading failed: file %s/%s could not be processed:\n %s') % (module, fname, warning_msg))
+         raise Exception(_('Module loading %s failed: file %s could not be processed:\n %s') % (module, fname, warning_msg))
      if config.get('import_partial'):
          data = pickle.load(file(config.get('import_partial')))
          data[fname_partial] = 0