Tuesday, May 21, 2013

Odoo OpenERP 7 POS Vs OpenBravo POS

Pragmatic has been actively developing a number of very useful features which are missing in the OpenERP 7 POS system. We also looked at other existing and popular POS system by OpenBravo. OpenBravo POS is a mature POS system and has very useful features. OpenERp 7 POS is comparatively new but is getting better. Below we have compared features of OpenBravo POS, OpenERP POS and features developed by Pragmatic within OpenERP POS.

Features of POS
Retail POS
    Bar code scanning
   Credit card hardware integration
    Refunds
    Returns
    Barcode generation
    Product categorisation
    Daily closing reports
    Graphical reports
    Inventory reports
    Purchase reports
    Sales reports
Restaurant-POS
    Table reservation    management
    Taking orders on tablets/mobile
    Multiple floors within a restaurant
    Automatic ticket printing for kitchen(KOT/BOT)
    Multiple table KOT
    Stock management.
Loyalty Management
    Product promotional     scheme management
    Redeemable point system
    Gift voucher management
Hardware Integration
    Printer
    Barcode scanner
    Cashdrawer
    Customer display


Friday, May 17, 2013

Odoo OpenERP 7 POS Technical Architecture

OpenERP 7 POS provides a good option for retailers to use the system for billing purpose. A great feature which it has is the ability to work in a offline mode. Its web based architecture makes it very easy to deploy on multiple POS PC machines. In this blog we present the technical architecture on how to configure the OpenERP 7 POS system along with integration of hardware.

We have configured the system to use it as a hardware proxy server which connects with all the hardware devices such as printer, scanner, cash drawer and customer display. Following describes the various components of the system.

OpenERP 7 Main Server:- 
OpenERP provides an application server on which business applications are built. This server has all the modules and server side code to run the OpenERP 7 server. It should generally be hosted on a server hardware and configuration depends on the traffic and number of users.
 
Pragmatic Hardware Proxy Server (PHPS):-
Pragmatic has build from ground up the hardware proxy servers which interacts with all the hardwares. PHPS runs on local POS PC system and connects to different types of hardwares. It provides facility to connect local Printer, Cashdrawer and VFD display-(On which Product,Quantity and Total Amount of order gets display). After generating order from POS touchscreen terminal when user hits on validate button it automatically generate printed receipt of sale order without issueing other instruction for print.
 
POS Touch Screen Terminal:-
POS Touch Screen is used for selecting products while creating order for customer. It is also used for managing quantity,discount, receiving payments and for printing receipts.  
 
Cash Drawer:-
Cash drawer connects to receipt printer port. When a print is fired, this port on receipt printer sends an electrical signal to cash drawer to openup the drawer automaticaly, once order is validated and receipt gets printed. 
 
VFD Customer Display:-
A vacuum fluorescent display (VFD) is used for displaying product on the screen. As soon as we select products it appears on VFD display. It also shows qauntity .total order amount as well as change after validation of order on VFD display. 
 
Barcode Reader:-
A barcode reader (or barcode scanner) is an electronic device for reading printed barcodes. Like a flat bed scanner, it consists of a light source, a lens and a light sensor translating optical impulses into electrical ones. After setting barcode labelling on the product when user scan product while making order that product is automatically added to shopping cart.  
 
Thermal Printer:-
Thermal Printer is used for printing the POS receipt.

Sunday, May 5, 2013

Rails 4

Rails just keeps on changing. Both Rails 3 and 4, as well as Ruby 1.9 and 2.0, bring hundreds of improvements, including new APIs and substantial performance enhancements. The fourth edition of this award-winning classic has been reorganized and refocused so it’s more useful than ever before for developers new to Ruby and Rails.

Rails 4 will only support Ruby 1.9.3+ versions.

Upgrading from Rails 3.2 to Rails 4.0 : 

If you want to upgrade your rails 3 application in rails 4, then you need to do changes in your rails application. If your application is currently on any version of Rails older than 3.2.x, you should upgrade to Rails 3.2 before attempting one to Rails 4.0 and do the changes in... 

Gemfile : 

Rails 4.0 removed the assets group from Gemfile. You'd need to remove that line from your Gemfile when upgrading. In Rails 4.0, several features have been extracted into gems. You just add the extracted gems to your Gemfile to bring the functionality back.     
  • Hash-based & Dynamic finder methods
  • Mass assignment protection in Active Record models.
  • ActiveRecord::SessionStore
  • Active Record Observers
  • Active Resource
  • Action Caching
  • Page Caching
  • Sprockets
  • Performance tests

Action Mailer : 
No changes  

Action Support: 
Rails 4.0 removes the j alias for ERB::Util#json_escape since j is already used for ActionView::Helpers::JavaScriptHelper#escape_javascript. 

Action Pack:
 Rails 4.0 introduces ActiveSupport::KeyGenerator and uses this as a base from which to generate and verify signed cookies. Existing signed cookies generated with Rails 3.x will be transparently upgraded if you leave your existing secret_token in place and add the new secret_key_base. 
 # config/initializers/secret_token.rb
Myapp::Application.config.secret_token = 'existing secret token'
Myapp::Application.config.secret_key_base = 'new secret key base' 


vendor/plugins:
Rails 4.0 no longer supports loading plugins from vendor/plugins. You must replace any plugins by extracting them to gems and adding them to your Gemfile. If you choose not to make them gems, you can move them into, say, lib/my_plugin/* and add an appropriate initializer in config/initializers/my_plugin.rb.
 


Active Record:
Rails 4.0 has removed the identity map from Active Record, If you have manually enabled it in your application, you will have to remove the following config that has no effect anymore: config.active_record.identity_map.


The delete method in collection associations can now receive Fixnum or String arguments as record ids, besides records, pretty much like the destroy method does. Previously it raised ActiveRecord::AssociationTypeMismatch for such arguments. From Rails 4.0 on delete automatically tries to find the records matching the given ids before deleting them


Rails 4.0 has removed attr_accessible and attr_protected feature in favor of Strong Parameters. You can use the Protected Attributes gem to a smoothly upgrade path.


Rails 4.0 requires that scopes use a callable object such as a Proc or lambda:
scope:active,where(active: true)
#becomes
scope:active,->{where active: true}
 


Active Model:
Rails 4.0 has changed how errors attach with the ActiveModel::Validations::ConfirmationValidator. Now when confirmation validations fail, the error will be attached to :#{attribute}_confirmation instead of attribute.


Active Resource:
Rails 4.0 extracted Active Resource to its own gem.
 

Sprockets-rails :
assets:precompile:primary has been removed. Use assets:precompile instead.
 

Sass-rails:
asset_url with two arguments is deprecated. For example: asseurl("rails.png", image) becomes asset-url("rails.png")


Executables:
The script directory has been removed in favor of a new bin directory. This is where your app’s executables will live, and running rake rails:update:bin will put bundle, rake, and rails binstubs into your app’s bin directory. This change can be useful in development, especially on a machine with multiple Ruby versions and gems. You can use bin/rails instead of bundle exec rails to ensure you run your executables in the correct environment.

Rails Action Mailer simple settings

1) we can set perform_deliveries as false . this is may be used in development mode. As sometimes we want to keep development time less . like when sending an email it might take some seconds and in development mode we actually never required to send emails to our friends that is why this option is useful.
2) we can override cc and bcc and reply-to and charset options in our mailer instance method. the default charset is UTF-8 e.g

def post_notification(recipients, post)
       @recipients = recipients
       @from = post.author.email_address_with_name
       @headers["bcc"] = SYSTEM_ADMINISTRATOR_EMAIL
       @headers["reply-to"] = "notifications@example.com"
       @subject = "[#{post.account.name} #{post.title}]"
       @body["post"] = post
       @charset = "iso-8859-1"

end 


  
Rails 4 mailer changes 

 in rails 4 for each object for sending an email we can change an SMTP settings. means we can do a dynamic smtp settings.by overriding the following method

def my_mailer(receiverobject, smtpobject)
   mail to: receiverobject.email, subject: "Welcome!",
     delivery_method_options: { user_name: smtpobject.smtp_user,
                             password: smtpobject.smtp_password }

end

this will ensure that your settings from environments/production.rb will be override.

we can get an array of email sents through Action Mailer . mostly used in progress bar like functionality like suppose in view we wanted to show a progress bar with the count of how many emails has been sent then we can get this through this ActionMailer::Base.deliveries method


Friday, May 3, 2013

Inheriting javascript from OpenERP 7 web client

OpenERP 7 web client allows adding of modules to the web client itself. The code of the web client in OpenERP 7 As Example:POS is primarily written in Javascript. Generally if people need to make any changes in the javascript code can make it directly in the core code. But this presents a potential problem when new releases comes out. This is not a good practice. 

What we describe in this blog is how to inherit the existing functionality of javascript in as Example: POS module of OpenERP 7 and extend that functionality to create new OpenERP module without change original javascript functionality . 

Step 1: Add New Folders static/src/js into your newly created module.

Step 2: Add new Javascript file into that folder.
e.g. Inheriting Point of Sale into restaurant_POS
Create New Module restaurant_POS like other Openerp module
Add static/src/js folders into that.
Add restaurant_POS.js file into that.
restaurant_POS.js file should contain

openerp.restaurant_POS = function(instance) {
//Some Code Here....
}

make sure that restaurant_POS is your module name. If your module name is different then code look like OpenERP.your_module_name = function(instance){ }

Inheriting JavaScript from PointOfSale Module:
If you want to add some extra functionality to any widget or model into PointOfSale module you can inherit its js code to your code. Remember that you can inherit only public variable not private.Variable only declared as module.var e.g module.POSWidget


Suppose you are inheriting POSWidget from point_of_sale which is in static/src/js/widgets.js file.

openerp.restaurant_POS = function(instance) {
var module = instance.point_of_sale;
//This will instantiate point_of_sale


module.POSWidget = module.POSWidget.extend({
// Now Extending functionality of POSWidget
// You can add your functions here also you can change functions
// inherited from POSWidget.

//Adding new function
mynewfunc : function(){
console.log(“This is new function”);
},


Step 3: Now to add view add new folder xml to static/src and add new file somenae_view.xml to that folder.

e.g Adding new widget Widget 

<templates id="template" xml:space="preserve">

<t t-name="Widget">
     <div id="screen_name" class="screen" >
         <header><h2>Select</h2></header>
         <div class="POS-step-container">
             <div class="POS-receipt-container">
                 
             </div>
         </div>
     </div>
</t>
</template>


Extending xml view from other module:
If you want to add new button,textfiled or anything to alredy created view then you can extend template.
e.g. Extending  POSWidget and add new button to action bar 

<template>
 <t t-extend="POSWidget">
<t t-jquery=".point-of-sale .placeholder-UsernameWidget" t-operation="after">
<button id="new button name" class="class name" style="background:linear-gradient(#B2B3D7, #7F82AC) repeat scroll 0 0 transparent">Button name</button>
</t>
</t>
</template>

t-operation options: 
after : adding component after the current
before : adding component before the current 

 
Step 4: Add .js filenames and .xml filename to __openERP__.py file.xml files to qweb and .js file to js as

{
 'qweb': [ 'static/src/xml/pos.xml' ,],

  'js': [ 'static/src/js/pos.js',   ],
}