Publicidad

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
2)python
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 model.py file with following code:
from openerp import api, fields, models
from openerp.osv import osv
class pos_model(models.Model):
_name = ‘pos.popup
name=fields.Char(‘Name’,size=30,required=True)
def okay_refresh(self,cr,uid,ids,context=None):
return{
‘type’:’ir.actions.client’,
‘tag’:’reload’,
}
view.xml file has this:
<?xml version=”1.0″ encoding=”utf-8″?>
<openerp>
<data>
<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>
<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”/>
</div>
</form>
</field>
</record>
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>
</t>
</t>
</template>
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;
module.PosWidget.include({
build_widgets: function(){
var self = this;
this._super();
this.$el.find(‘.popup-misc’).click(function(){
self.do_action({
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
<openerp>
<data>
<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>
</xpath>
</template>
</data>
</openerp>
This will add your js to odoo frond end..
Finally add all the xml files in _openerp__.py

1 comentario:

  1. MUchas gracias, la documentacion para el modulo pos es escasa, este modulo funciona en odoo version 8?

    ResponderBorrar