[MERGE] trunk into point_of_sale, WIP

bzr revid: fva@openerp.com-20120711160325-vmzhxwl74j2u7v8g
This commit is contained in:
Frédéric van der Essen 2012-07-11 18:03:25 +02:00
parent f8d32d3304
commit f5e0ad32f2
6 changed files with 84 additions and 72 deletions

View File

@ -498,7 +498,7 @@
<field name="type_control_ids" widget="many2many_tags"/>
<field name="account_control_ids" widget="many2many_tags"/>
</group>
</page>
</group>
<page string="Entry Controls">
<separator colspan="4" string="Accounts Type Allowed (empty for no control)"/>
<field colspan="4" name="type_control_ids" nolabel="1"/>
@ -519,7 +519,6 @@
</tree>
</field>
</page>
</group>
</page>
</notebook>
</form>

View File

@ -16,7 +16,7 @@
<field name="model">pos.order</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Point of Sale Orders" layout="manual">
<form string="Point of Sale Orders" version="7.0">
<div class="oe_form_topbar">
<button name="%(action_pos_payment)d" string="Payment" icon="gtk-apply" type="action" states="draft" context="{'pos_session_id' : session_id}"/>
<button name="action_invoice" string="Invoice" icon="gtk-apply" type="object" states="paid" attrs="{'readonly': [('partner_id','=',False)]}"/>
@ -27,7 +27,7 @@
<field name="state" nolabel="1" widget="statusbar" statusbar_visible="draft,paid,done" statusbar_colors='{"cancel":"red"}'/>
</div>
</div>
<sheet layout="auto">
<sheet>
<group col="4" colspan="4">
<field name="name"/>
<field name="date_order"/>
@ -650,15 +650,17 @@
<field name="model">pos.category</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Product PoS Categories">
<group colspan="4" col="6">
<field name="name"/>
<field name="parent_id"/>
<field name="sequence"/>
</group>
<group colspan="2" col="1">
<field name="category_image" widget='image' nolabel="1"/>
</group>
<form string="Product PoS Categories" version="7.0">
<sheet>
<field name="category_image" widget='image' class="oe_avatar oe_right"/>
<div class="oe_left">
<group>
<field name="name"/>
<field name="parent_id"/>
<field name="sequence"/>
</group>
</div>
</sheet>
</form>
</field>
</record>
@ -761,22 +763,24 @@
<field name="model">pos.config</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Point of Sale Configuration" layout="manual">
<div class="oe_form_topbar">
<form string="Point of Sale Configuration" version="7.0">
<header>
<button string="Set to Active" name="set_active" type="object" states="inactive,deprecated"/>
<button string="Set to Inactive" name="set_inactive" type="object" states="active" />
<button string="Set to Deprecated" name="set_deprecate" type="object" states="active,inactive" />
<div class="oe_right">
<field name="state" widget="statusbar" statusbar_visible="active,inactive,deprecated" statusbar_colors='{"deprecated" : "red"}' nolabel="1"/>
</div>
</div>
</header>
<sheet layout="auto">
<sheet>
<group>
<field name="name"/>
<field name="shop_id" widget="selection" />
<field name="journal_id" widget="selection" />
<field name="sequence_id" readonly="1"/>
<field name="group_by" />
</group>
<separator string="Available Payment Methods" colspan="4"/>
<field name="journal_ids" colspan="4" nolabel="1">
<tree string="Journals">
@ -787,16 +791,21 @@
<field name="closing_control" />
</tree>
</field>
<separator string="Material Interfaces" colspan="4"/>
<field name="iface_self_checkout" />
<field name="iface_websql" />
<field name="iface_led" />
<field name="iface_cashdrawer" />
<field name="iface_payment_terminal" />
<field name="iface_electronic_scale" />
<field name="iface_barscan" />
<field name="iface_vkeyboard" />
<field name="iface_print_via_proxy" />
<group string="Material Interfaces" >
<group>
<field name="iface_self_checkout" />
<field name="iface_websql" />
<field name="iface_led" />
<field name="iface_cashdrawer" />
<field name="iface_payment_terminal" />
</group>
<group>
<field name="iface_electronic_scale" />
<field name="iface_barscan" />
<field name="iface_vkeyboard" />
<field name="iface_print_via_proxy" />
</group>
</group>
</sheet>
</form>
@ -869,8 +878,8 @@
<field name="model">pos.session</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Point of Sale Session" layout="manual">
<div class="oe_form_topbar">
<form string="Point of Sale Session" version="7.0">
<header>
<button name="open" type="workflow" string="Validate &amp; Open Session" states="opening_control" />
<button name="cashbox_control" type="workflow" string="End of Session" states="opened" />
<button name="close" type="workflow" string="Validate &amp; Close" states="closing_control,opened" />
@ -878,14 +887,14 @@
<div class="oe_right">
<field name="state" widget="statusbar" statusbar_visible="opening_control,opened,closing_control,closed" nolabel="1"/>
</div>
</div>
<sheet layout="auto">
</header>
<sheet>
<group colspan="4" col="4">
<group>
<field name="config_id"/>
<field name="has_opening_control" invisible="1" />
<field name="has_closing_control" invisible="1" />
<group colspan="2" col="2">
<group>
<button name="%(action_pos_box_in)d" string="Put Money In" type="action" states="opened"/>
<button name="%(action_pos_box_out)d" string="Take Money Out" type="action" states="opened"/>
<button name="open_frontend_cb" type="object" string="Open Point Of Sale" states="opened" />

View File

@ -50,10 +50,10 @@
<filter icon="terp-dolar"
string="Not Invoiced"
domain="[('state','=',('paid'))]"/>
<separator orientation="vertical"/>
<field name="partner_id"/>
<field name="date"/>
<field name="user_id" widget="selection">
<separator orientation="vertical"/>
<field name="partner_id"/>
<field name="date"/>
<field name="user_id" widget="selection" />
<filter icon="terp-personal"
string="My Sales"
help="My Sales"

View File

@ -8,9 +8,9 @@
<field name="type">form</field>
<field name="inherit_id" ref="base.view_users_form_simple_modif" />
<field name="arch" type="xml">
<group name="preferences" position="inside">
<xpath expr="//group[@name='preferences']" position="inside">
<field name="pos_config" />
</group>
</xpath>
</field>
</record>

View File

@ -47,8 +47,8 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
});
var fetch = function(model, fields, domain){
return new instance.web.Model(model).query(fields).filter(domain).all()
var fetch = function(model, fields, domain, ctx){
return new instance.web.Model(model).query(fields).filter(domain).context(ctx).all()
};
// The PosModel contains the Point Of Sale's representation of the backend.
@ -112,7 +112,8 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
this.get('orders').bind('remove', function(){ self.on_removed_order(); });
// We fetch the backend data on the server asynchronously
// We fetch the backend data on the server asynchronously. this is done only when the pos user interface is launched,
// Any change on this data made on the server is thus not reflected on the point of sale until it is relaunched.
var user_def = fetch('res.users',['name','company_id'],[['id','=',this.session.uid]])
.pipe(function(users){
@ -144,14 +145,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
.pipe(function(result){
return self.set({'categories': result});
});
var prod_def = fetch(
'product.product',
['name', 'list_price', 'pos_categ_id', 'taxes_id','product_image_small', 'ean13', 'to_weight', 'uom_id', 'uos_id', 'uos_coeff', 'mes_type'],
[['pos_categ_id','!=', false]]
).then(function(result){
self.set({'product_list': result});
});
var uom_def = fetch( //unit of measure
'product.uom',
@ -174,25 +167,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
self.set({'user_list':result});
});
// associate the products with their categories
var prod_process_def = $.when(cat_def, prod_def)
.pipe(function(){
var product_list = self.get('product_list');
var categories = self.get('categories');
var cat_by_id = {};
for(var i = 0; i < categories.length; i++){
cat_by_id[categories[i].id] = categories[i];
}
//set the parent in the category
for(var i = 0; i < categories.length; i++){
categories[i].parent_category = cat_by_id[categories[i].parent_id[0]];
}
for(var i = 0; i < product_list.length; i++){
product_list[i].pos_category = cat_by_id[product_list[i].pos_categ_id[0]];
}
});
var tax_def = fetch('account.tax', ['amount','price_include','type'])
.then(function(result){
self.set({'taxes': result});
@ -236,6 +210,15 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
return shop_def = fetch('sale.shop',[], [['id','=',pos_config.shop_id[0]]])
}).pipe(function(shops){
self.set('shop',shops[0]);
return fetch(
'product.product',
//context {pricelist: shop.pricelist_id[0]}
['name', 'list_price','price','pos_categ_id', 'taxes_id','product_image_small', 'ean13', 'to_weight', 'uom_id', 'uos_id', 'uos_coeff', 'mes_type'],
[['pos_categ_id','!=', false]],
{pricelist: shop.pricelist_id[0]} // context for price
);
}).pipe( function(product_list){
self.set({'product_list': product_list});
});
var bank_def = fetch(
@ -277,12 +260,32 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
return session_data_def;
});
console.log('Yhaoooefe');
// associate the products with their categories
var prod_process_def = $.when(cat_def, session_def)
.pipe(function(){
var product_list = self.get('product_list');
var categories = self.get('categories');
var cat_by_id = {};
for(var i = 0; i < categories.length; i++){
cat_by_id[categories[i].id] = categories[i];
}
//set the parent in the category
for(var i = 0; i < categories.length; i++){
categories[i].parent_category = cat_by_id[categories[i].parent_id[0]];
}
for(var i = 0; i < product_list.length; i++){
product_list[i].pos_category = cat_by_id[product_list[i].pos_categ_id[0]];
}
});
// when all the data has loaded, we compute some stuff, and declare the Pos ready to be used.
$.when(cat_def, prod_def, user_def, users_def, uom_def, session_def, tax_def, prod_process_def, user_def, this.flush())
$.when(cat_def, user_def, users_def, uom_def, session_def, tax_def, prod_process_def, user_def, this.flush())
.then(function(){
self.build_categories();
self.set({'cashRegisters' : new module.CashRegisterCollection(self.get('bank_statements'))});
//self.log_loaded_data();
self.log_loaded_data();
console.log("YHAAAA");
self.ready.resolve();
},function(){
//we failed to load some backend data, or the backend was badly configured.
@ -324,6 +327,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
}
},
// saves the order locally and try to send it to the backend. 'record' is a bizzarely defined JSON version of the Order
push_order: function(record) {
var self = this;
return this.dao.add_operation(record).pipe(function(){

View File

@ -5,7 +5,7 @@
<field name="name">pos.session.opening.form.view</field>
<field name="model">pos.session.opening</field>
<field name="arch" type="xml">
<form string="PoS Session Opening" layout="auto">
<form string="PoS Session Opening" version="7.0">
<separator string="Select your Point of Sale" colspan="4" />
<field name="pos_config_id" on_change="on_change_config(pos_config_id)" widget="selection" domain="[('state','=','active')]"/>
<field name="pos_session_id" invisible="1"/>