[IMP] point_of_sale: load pos user roles

Conflicts:
	addons/point_of_sale/point_of_sale.py
	addons/point_of_sale/static/src/js/models.js
This commit is contained in:
Frederic van der Essen
2014-11-26 12:11:49 +01:00
committed by Frédéric van der Essen
parent a7616b809c
commit 633c8563a7
2 changed files with 43 additions and 5 deletions
+20
View File
@@ -92,6 +92,8 @@ class pos_config(osv.osv):
'pricelist_id': fields.many2one('product.pricelist','Pricelist', required=True),
'company_id': fields.many2one('res.company', 'Company', required=True),
'barcode_nomenclature_id': fields.many2one('barcode.nomenclature','Barcode Nomenclature', help='A barcode nomenclature', required="True"),
'group_pos_manager_id': fields.many2one('res.groups','Point of Sale Manager Group', help='This field is there to pass the id of the pos manager group to the point of sale client'),
'group_pos_user_id': fields.many2one('res.groups','Point of Sale User Group', help='This field is there to pass the id of the pos user group to the point of sale client'),
}
def _check_cash_control(self, cr, uid, ids, context=None):
@@ -166,14 +168,30 @@ class pos_config(osv.osv):
def _get_default_company(self, cr, uid, context=None):
company_id = self.pool.get('res.users')._get_company(cr, uid, context=context)
print company_id
return company_id
<<<<<<< HEAD
def _get_default_nomenclature(self, cr, uid, context=None):
nom_obj = self.pool.get('barcode.nomenclature')
res = nom_obj.search(cr, uid, [], limit=1, context=context)
if res and res[0]:
return nom_obj.browse(cr, uid, res[0], context=context).id
return False
=======
def _get_group_pos_manager(self, cr, uid, context=None):
group = self.pool.get('ir.model.data').get_object_reference(cr,uid,'point_of_sale','group_pos_manager')
if group:
return group[1]
else:
return False
def _get_group_pos_user(self, cr, uid, context=None):
group = self.pool.get('ir.model.data').get_object_reference(cr,uid,'point_of_sale','group_pos_user')
if group:
return group[1]
else:
return False
_defaults = {
'uuid' : _generate_uuid,
@@ -186,6 +204,8 @@ class pos_config(osv.osv):
'stock_location_id': _get_default_location,
'company_id': _get_default_company,
'barcode_nomenclature_id': _get_default_nomenclature,
'group_pos_manager_id': _get_group_pos_manager,
'group_pos_user_id': _get_group_pos_user,
}
def onchange_picking_type_id(self, cr, uid, ids, picking_type_id, context=None):
+23 -5
View File
@@ -164,11 +164,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
}
self.units_by_id = units_by_id;
}
},{
model: 'res.users',
fields: ['name','pos_security_pin','barcode'],
domain: null,
loaded: function(self,users){ self.users = users; },
},{
model: 'res.partner',
fields: ['name','street','city','state_id','country_id','vat','phone','zip','mobile','email','barcode','write_date'],
@@ -231,6 +226,29 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
self.pos_session.sequence_number = Math.max(self.pos_session.sequence_number, orders[i].data.sequence_number+1);
}
},
},{
model: 'res.users',
fields: ['name','pos_security_pin','groups_id','barcode'],
domain: null,
loaded: function(self,users){
var pos_users = [];
for (var i = 0; i < users.length; i++) {
var user = users[i];
for (var j = 0; j < user.groups_id.length; j++) {
var group_id = user.groups_id[j];
if (group_id === self.config.group_pos_manager_id[0]) {
user.role = 'manager';
break;
} else if (group_id === self.config.group_pos_user_id[0]) {
user.role = 'cashier';
}
}
if (user.role) {
pos_users.push(user);
}
}
self.users = pos_users;
},
},{
model: 'stock.location',
fields: [],