jueves, 26 de noviembre de 2015

Odoo POS Pop Ups

Odoo POS Pop Ups

In odoo retailers will be mostly concentrating on POS because that minimizes their effort to more extreme,….
Now on developer side it is tough work to customize that pos.. since it is collaboration of js, jquery with python…  Some times head ache.. :P :) ..
No problem now we will see how to create a pop up in odoo POS,,,,
For this you need some basic knowledge in
1) js, jquery
3)odoo qweb widgets
Now we are going to create a popup asking name to enter in pos….
create a module in odoo.. with init and openerp file…
Now normally on creation of wizard we used to create a form for pop right.. like that create one as below..
create file with following code:
from openerp import api, fields, models
from openerp.osv import osv
class pos_model(models.Model):
_name = ‘pos.popup
def okay_refresh(self,cr,uid,ids,context=None):
view.xml file has this:
<?xml version=”1.0″ encoding=”utf-8″?>
<record model=”ir.actions.act_window” id=”create_pop_up”>
<field name=”name”>Pop up</field>
<field name=”res_model”>pos.popup</field>
<field name=”view_mode”>form</field>
<record id=”create_pop_form” model=”ir.ui.view”>
<field name=”name”>Pop up</field>
<field name=”model”>pos.popup</field>
<field name=”type”>form</field>
<field name=”arch” type=”xml”>
<form string=”Pop up” version=”7.0″>
<br />
<h2>Enter the name:</h2>
<br /><br />
<label for=”name” style=”clear:left;text-align:right;padding-right:10px;float:left;padding-left:5em “/>
<field name=”name” nolable=”1″ style=”float:left;padding-left:5em “/><br /><br />
<br />
<br />
<div style=”align:center;float:left;padding-left:12em “>
<button name=”ok_refresh” type=”object” string=”Okay”/>
Now its turn for POS module change..
TO add button to POS.. create static–>src–>xml–>pop_up.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<template id=”payment_screen”>
<t t-extend=”PosWidget”>
<t t-jquery=”div.pos-branding” t-operation=”inner”>
<button class=”popup-misc” style=”position:absolute;left:300px; top:7px;width: 100px; height: 37px; font-size:15px;”>Name popup</button>
Now create a file static–>src–>js–>pos_pop.js
in that paste it
openerp.module_name = function(instance){
var module = instance.point_of_sale; 
var QWeb = instance.web.qweb;
build_widgets: function(){
var self = this;
type: ‘ir.actions.act_window’,
res_model: “pos.popup”,
views: [[false, ‘form’]],
target: ‘new’,
context: {},
create a file template.xml in that paste the following code
<template id=”assets_frontend” inherit_id=”web.assets_common”>
<xpath expr=”.” position=”inside”>
<script type=”text/javascript” src=”/module_name/static/src/js/pos_pop.js”></script>
This will add your js to odoo frond end..
Finally add all the xml files in

0 comentarios:

Publicar un comentario