Add the ability to scan custom ean barcodes for products at the point of sale
There are products that have not EAN13 barcode, OpenERP allows to add a custom EAN13 barcode product, the proposal is to extend this method to the point of sale without having to re-label the product.
Blueprint information
- Status:
- Not started
- Approver:
- None
- Priority:
- Undefined
- Drafter:
- None
- Direction:
- Needs approval
- Assignee:
- None
- Definition:
- New
- Series goal:
- None
- Implementation:
- Unknown
- Milestone target:
- None
- Started by
- Completed by
Whiteboard
This is the proposal Merge at the devices.js file:
function openerp_
// this object interfaces with the local proxy to communicate to the various hardware devices
// connected to the Point of Sale. As the communication only goes from the POS to the proxy,
// methods are used both to signal an event, and to fetch information.
module.
init: function(options){
options = options || {};
url = options.url || 'http://
};
},
message : function(
var ret = new $.Deferred();
var callbacks = this.notificati
for(var i = 0; i < callbacks.length; i++){
}
});
return ret;
},
// this allows the client to be notified when a proxy call is made. The notification
// callback will be executed with the same arguments as the proxy call
}
},
//a product has been scanned and recognized with success
// ean is a parsed ean object
return this.message(
},
// a product has been scanned but not recognized
// ean is a parsed ean object
return this.message(
},
//the client is asking for help
return this.message(
},
//the client does not need help anymore
return this.message(
},
//the client is starting to weight
}
}
},
//returns the weight on the scale.
// is called at regular interval (up to 10x/sec) between a weighting_start()
// and a weighting_end()
var self = this;
}else{
}
},
// sets a custom weight, ignoring the proxy returned value.
},
// resets the custom weight and re-enable listening to the proxy for weight values
},
// the client has finished weighting products
}
},
// the pos asks the client to pay 'price' units
var ret = new $.Deferred();
return this.message(
},
}else{
}
},
// override what the proxy says and accept the payment
};
},
// override what the proxy says and reject the payment
};
},
// the client cancels his payment
return this.message(
},
// called when the client logs in or starts to scan product
return this.message(
},
// called when the clients has finished his interaction with the machine
return this.message(
},
// called when the POS turns to cashier mode
return this.message(
},
// called when the POS turns to client mode
return this.message(
},
// ask for the cashbox (the physical box where you store the cash) to be opened
return this.message(
},
/* ask the printer to print a receipt
* receipt is a JSON object with the following specs:
* receipt{
* - orderlines : list of orderlines :
* {
* quantity: (number) the number of items, or the weight,
* unit_name: (string) the name of the item's unit (kg, dozen, ...)
* price: (number) the price of one unit of the item before discount
* discount: (number) the discount on the product in % [0,100]
* product_name: (string) the name of the product
* price_with_tax: (number) the price paid for this orderline, tax included
* price_without_tax: (number) the price paid for this orderline, without taxes
* tax: (number) the price paid in taxes on this orderline
* product_
* product_
* }
* - paymentlines : list of paymentlines :
* {
* amount: (number) the amount paid
* journal: (string) the name of the journal on wich the payment has been made
* }
* - total_with_tax: (number) the total of the receipt tax included
* - total_without_tax: (number) the total of the receipt without taxes
* - total_tax: (number) the total amount of taxes paid
* - total_paid: (number) the total sum paid by the client
* - change: (number) the amount of change given back to the client
* - name: (string) a unique name for this order
* - client: (string) name of the client. or null if no client is logged
* - cashier: (string) the name of the cashier
* - date: { the date at wich the payment has been done
* year: (number) the year [2012, ...]
* month: (number) the month [0,11]
* date: (number) the day of the month [1,31]
* day: (number) the day of the week [0,6]
* hour: (number) the hour [0,23]
* minute: (number) the minute [0,59]
* }
*/
return this.message(
},
// asks the proxy to print an invoice in pdf form ( used to print invoices generated by the server )
return this.message(
},
});
// this module interfaces with the barcode reader. It assumes the barcode reader
// is set-up to act like a keyboard. Use connect() and disconnect() to activate
// and deactivate the barcode reader. Use set_action_
// what to do when it reads a barcode.
module.
actions:[
],
init: function(
},
var callbacks = {};
}
},
var callbacks = this.action_
}
},
// when an ean is scanned and parsed, the callback corresponding
// to its type is called with the parsed_ean as a parameter.
// (parsed_ean is the result of parse_ean(ean))
//
// callbacks is a Map of 'actions' : callback(
// that sets the callback for each action. if a callback for the
// specified action already exists, it is replaced.
//
// possible actions include :
// 'product' | 'cashier' | 'client' | 'discount'
}else{
var actions = arguments[0];
}
}
},
//remove all action callbacks
}
},
// returns the checksum of the ean, or -1 if the ean has not the correct length, ean must be a string
var code = ean.split('');
}
var oddsum = 0, evensum = 0, total = 0;
code = code.reverse(
for(var i = 0; i < code.length; i++){
}
}
total = oddsum * 3 + evensum;
return Number((10 - total % 10) % 10);
},
// returns true if the ean is a valid EAN codebar number by checking the control digit.
// ean must be a string
check_ean: function(ean){
+ if(ean.length !== 13){
+ ean = this.sanitize_
+ }
return this.ean_
},
// returns a valid zero padded ean13 from an ean prefix. the ean prefix must be a string.
ean = ean.substr(0,13);
for(var n = 0, count = (13 - ean.length); n < count; n++){
ean = ean + '0';
}
return ean.substr(0,12) + this.ean_
},
// attempts to interpret an ean (string encoding an ean)
// it will check its validity then return an object containing various
// information about the ean.
// most importantly :
// - ean : the ean
// - type : the type of the ean:
// 'price' | 'weight' | 'unit' | 'cashier' | 'client' | 'discount' | 'error'
//
// - prefix : the prefix that has ben used to determine the type
// - id : the part of the ean that identifies something
// - value : if the id encodes a numerical value, it will be put there
// - unit : if the encoded value has a unit, it will be put there.
// not to be confused with the 'unit' type, which represent an unit of a
// unique product
parse_ean: function(ean){
var parse_result = {
};
}
}
if (!this.
} else if( match_prefix(
} else if( match_prefix(
} else if( match_prefix(
} else if( match_prefix(
} else if( match_prefix(
} else {
- parse_result.id = ean;
+ parse_result.id = this.sanitize_
+ parse_result.
}
return parse_result;
},
on_ean: function(ean){
var parse_result = this.parse_
if (parse_result.type === 'error') { //most likely a checksum error, raise warning
}else if(parse_
}
}else{
}
}
},
// 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;
// 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.
if (e.keyCode >= 48 && e.keyCode < 58){
} else {
+ if (codeNumbers.length > 5){
+ self.on_
+ }
}
});
},
// stops catching keyboard events
disconnect: function(){
},
});
}