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',   ],
}

Friday, April 26, 2013

Ruby on Rails Fedena School Management System

To get started with fedena school erp management system i done the following steps 

1. First need to ruby 1.8.7 because the rails version was used as 2.3.5
2. Just to save your time from running an app. i got some errors because of version of 2.3.5. so i Changed it to version 2.3.11. and then downgrade my system gems to 1.3.5. then run the rake db:migrate . and after that feed a tables with rake db:seed.
3. Then run the rails server . 

Now i am attaching the screenshots of the application so that we will get a basic idea of the application.

My first screenshot will be of manageusers
Where i can find the users with just type a letter in text box.

My second screenshot will be of users dashboard.
As you can see from where you can manage attendance, human resource,admissions etc.

My third screenshot will be of creation of Course with batches.

My fourth screenshot will be of admission. 
Where an user can take an admission. 

My fifth screenshot will be of attendance  

My sixth screenshot will be of settings 

And my last but not least screenshot is of eventcalendar. 

Also it has lots of features. some are free and some are paid. 
I personellay like the way its organised the view pages with ajax stype. and an layout used. also the coding is really good because in any of the controller there is no unwanted line of code. 

Wednesday, April 17, 2013

Odoo OpenERP 7 Hotel Management

Hotel Management module incorporates addresses key functionalities in hospitality industry. It includes following functions :

1.Room Reservations 
2.Transportation Management  
3.Restaurant Management   
4.Laundry Management   
5.Banquet Hall Booking    
  
Room Reservations (at Reception)  
This enables user to book room through walk-in enquiries/ and through web booking form.
 

Web Based Booking Form:
This enables user to book room through internet.Booking form is featured with Paypal and authorised .net integration




Transport Management
Management can maintain a fleet record for internal as well as third party service providers. Invoicing can be maintained with the instruction maintained at the time of room booking

Restaurant Management
Restaurant Management module not only maintain table orders but also efficiently maintain inventory at different locations. It is linked to KOT preparation as well. User can link restaurant bills with are occupied room no. so that payment can be received from the customer at the time of checkout. 


Laundry Management
Efficiently maintain billing and inventory movement for laundry requests. It maintains separate workflow for internal and Room wise laundry requests


Banquet Hall Booking
User can generate multiple quotation for each of the lead generated by marketing department with unlimited permutation combination of service / product offerings for various events.



Housekeeping Work Management
User can maintain / schedule various housekeeping works for each of the house keeper. similarly, We can maintain a track of repair / replacement request generated so far with expense made for it.


Friday, April 12, 2013

Common wealth bank payment

To make a credit card payment in Australia there is one bank named as common wealth bank. which accepts credit cards payments..
To accepts a payment i do the following steps
# Send requests to the gateway's test servers
# #first set everything in test mode. later just need to change this environment to production.but for that we need to talk with bank service center to get the details of current live account and its credentials mapped with this account
  
cardexpdate=Date.civil(params["credit_card"]["expiring_date(1i)"].to_i,params["credit_card"]["expiring_date(2i)"].to_i) amount_in_cents = amount_in_cents 

uri = URI.parse("https://migs.mastercard.com.au/vpcdps?vpc_Version=1&vpc_Command=pay&vpc_AccessCode=tttttttttt&vpc_MerchTxnRef=#{params[:credit_card][:user_id]}&vpc_Merchant=Ttttttttttttt&vpc_OrderInfo=#{params[:credit_card][:user_id]}&vpc_Amount=#{amount_in_cents.to_i}&vpc_CardNum=#{no}&vpc_cardExp=#{cardexpdate.strftime('%y%m')}&vpc_locale=en")  

  http = Net::HTTP.new(uri.host, uri.port)
#http.use_ssl = true
#http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(uri.request_uri)
response = http.request(request)
responsearray=response.body.split("&")
responsearray.each do |res|
if res.split("=")[0] == "vpc_Message"
if res.split("=")[1] =="Approved"
              self.state = 'online_validated'
                    self.save
              #invoice.validating
   elsif res.split("=")[1] =="Declined"
       self.state = 'Declined'
                   self.save
      elsif res.split("=")[1] =="Unspecified+Failure"
self.state = "Unspecified+Failure"
                          self.save
              elsif res.split("=")[1] =="Referred"
                               self.state = "Referred"
                                self.save
            elsif res.split("=")[1] =="Timed+Out"
self.state = "Timed+Out"
                  self.save
            elsif res.split("=")[1] =="Expired+Card"
            self.state = "Expired+Card"
                    self.save
          elsif res.split("=")[1] =="Insufficient+Funds"
self.state = "Insufficient+Funds"
                    self.save
else
self.state = res.split("=")[1]
                    self.save
end
end
end