[MERGE] point_of_sale: from stw, also draft of client payment integration

bzr revid: fva@openerp.com-20120604162607-hvk3kmjwzhbfwo11
This commit is contained in:
Frédéric van der Essen 2012-06-04 18:26:07 +02:00
commit ac91821836
6 changed files with 991 additions and 951 deletions

View File

@ -61,7 +61,7 @@ class pos_config(osv.osv):
"to store the data in the browser, instead of localStore mechanism. "\
"It's more efficient but works on the Chrome browser only."
),
'iface_led' : fields.boolean('LED Interface'),
'iface_led' : fields.boolean('Help Notification'),
'iface_cashdrawer' : fields.boolean('Cashdrawer Interface'),
'iface_payment_terminal' : fields.boolean('Payment Terminal Interface'),
'iface_electronic_scale' : fields.boolean('Electronic Scale Interface'),
@ -389,8 +389,6 @@ class pos_session(osv.osv):
order_ids = [order.id for order in session.order_ids if order.state == 'paid']
move_id = self.pool.get('account.move').create(cr, uid, {'ref' : session.name, 'journal_id' : session.config_id.journal_id.id, }, context=context)
print "### move_id: %r" % (move_id,)
print "order_ids: %r" % (order_ids,)
self.pool.get('pos.order')._create_account_move_line(cr, uid, order_ids, session, move_id, context=context)
@ -565,9 +563,7 @@ class pos_order(osv.osv):
}
def create(self, cr, uid, values, context=None):
print "#CREATE: %r" % (values,)
values['name'] = self.pool.get('ir.sequence').get(cr, uid, 'pos.order')
#values['session_id'] = 40
return super(pos_order, self).create(cr, uid, values, context=context)
def test_paid(self, cr, uid, ids, context=None):
@ -1018,11 +1014,8 @@ class pos_order(osv.osv):
order.write({'state':'done', 'account_move': move_id})
print "grouped_data: %r" % (grouped_data,)
for group_key, group_data in grouped_data.iteritems():
for value in group_data:
print "value: %r" % (value,)
account_move_line_obj.create(cr, uid, value, context=context)
return True

File diff suppressed because one or more lines are too long

View File

@ -882,8 +882,8 @@
<field name="user_id" />
<field name="name" />
<newline/>
<field name="start_at" />
<field name="stop_at" />
<field name="start_at" attrs="{'insivible' : [('state', '=', 'opening_control')]}"/>
<field name="stop_at" attrs="{'insivible' : [('state', '=', 'opening_control')]}"/>
<separator string="Cash Control" colspan="4"/>
<field name="cash_register_id" invisible="1" />
<field name="opening_details_ids" colspan="4" nolabel="1" attrs="{'invisible' : [('state', 'not in', ('opening_control',))]}">
@ -918,8 +918,9 @@
<field name="cash_register_difference" />
</group>
</group>
<separator string="Summary by Payment Methods" colspan="4"/>
<field name="statement_ids" colspan="4" nolabel="1">
<separator string="Summary by Payment Methods" colspan="4" attrs="{'invisible' : [('state', '=', 'opening_control')]}"/>
<field name="statement_ids" colspan="4" nolabel="1" attrs="{'invisible' : [('state', '=', 'opening_control')]}">
<tree string="Statements">
<field name="name" />
<field name="journal_id" />

View File

@ -727,12 +727,15 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
},
addPaymentLine: function(cashRegister) {
var newPaymentline;
console.log('addPaymentLine:',cashRegister);
newPaymentline = new module.Paymentline(cashRegister);
/* TODO: Should be 0 for cash-like accounts */
//FIXME the following 'set' call calls this method once again via callback
// events. Are we sure that it's what we want ???
newPaymentline.set({
amount: this.getDueLeft()
});
return (this.get('paymentLines')).add(newPaymentline);
this.get('paymentLines').add(newPaymentline);
},
getName: function() {
return this.get('name');

View File

@ -406,13 +406,19 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.pos_widget.action_bar.set_help_visible(true,function(){self.pos_widget.screen_selector.show_popup('help');});
this.pos_widget.action_bar.set_logout_visible(false);
this.pos.proxy.payment_request(this.pos.get('selectedOrder').getTotal(),'card','info'); //TODO TOTAL
this.pos.proxy.payment_request(this.pos.get('selectedOrder').getDueLeft(),'card','info'); //TODO TOTAL
this.intervalID = setInterval(function(){
var payment = self.pos.proxy.is_payment_accepted();
if(payment === 'payment_accepted'){
clearInterval(this.intervalID);
var currentOrder = self.pos.get('selectedOrder');
//TODO get the correct cashregister
var cashregister = this.pos.get('cashRegisters').models[0];
currentOrder.addPaymentLine(cashregister);
self.pos.push_order(currentOrder.exportAsJSON()).then(function() {
currentOrder.destroy();
self.pos.proxy.transaction_end();
@ -775,6 +781,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.renderElement();
},
addPaymentLine: function(newPaymentLine) {
console.log('addPaymentLine:',newPaymentLine);
var x = new module.PaymentlineWidget(null, {
payment_line: newPaymentLine
});

View File

@ -9,13 +9,13 @@
<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"/>
<group colspan="4">
<group colspan="4">
<button special="cancel" icon="gtk-cancel" string="Cancel" />
<button name="open_existing_session_cb" type="object" string="Open Session" icon="gtk-ok"
attrs="{'invisible' : [('pos_session_id', '=', False)]}"
/>
<button name="open_session_cb" type="object" string="New Session" icon="gtk-ok"
attrs="{'invisible' : [('pos_session_id', '&lt;&gt;', False)]}"
attrs="{'invisible' : [('pos_session_id', '!=', False)]}"
/>
</group>
</form>