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
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:
// 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);
},
# 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()):
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">
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