Browse Source

[MERGE][TACHE 10] 0010 - Gestion de foyer de mangeurs

pull/6/head
Thibault Francois 9 years ago
parent
commit
977cfe0a0a
  1. 21
      beesdoo_pos/models/beesdoo_pos.py
  2. 24
      beesdoo_pos/static/src/css/beesdoo.css
  3. 63
      beesdoo_pos/static/src/js/beesdoo.js
  4. 24
      beesdoo_pos/static/src/xml/templates.xml

21
beesdoo_pos/models/beesdoo_pos.py

@ -39,3 +39,24 @@ class BeescoopPosOrder(models.Model):
mail_template = self.env.ref("beescoop_pos.email_send_ticket") mail_template = self.env.ref("beescoop_pos.email_send_ticket")
mail_template.send_mail(order.id) mail_template.send_mail(order.id)
return _("Ticket sent") return _("Ticket sent")
class BeescoopPosPartner(models.Model):
_inherit = 'res.partner'
def _get_eater(self):
eater1, eater2 = False, False
if self.child_eater_ids:
eater1 = self.child_eater_ids[0].name
if len(self.child_eater_ids) > 1:
eater2 = self.child_eater_ids[1].name
return eater1, eater2
@api.multi
def get_balance_and_eater(self):
self.ensure_one()
account_id = self.property_account_receivable_id.id
move_lines = self.env['account.move.line'].search([('account_id', '=', account_id), ('partner_id', '=', self.id)])
credit = sum([m.credit for m in move_lines])
debit = sum([m.debit for m in move_lines])
eater1, eater2 = self._get_eater()
return str(round(credit - debit, 2)), eater1, eater2

24
beesdoo_pos/static/src/css/beesdoo.css

@ -2,3 +2,27 @@
margin: 16px; margin: 16px;
text-align: center; text-align: center;
} }
.customer-information {
margin: 16px 24px 16px 24px;
font-weight: bold;
font-size: 16px;
}
.customer-name {
font-size: 18px;
}
.button.set-customer.decentered {
height: 108px;
}
.customer-information-pay {
font-weight: normal;
font-size: 12px;
text-align: left;
}
.pos .actionpad .button.pay {
height: 108px;
}

63
beesdoo_pos/static/src/js/beesdoo.js

@ -2,12 +2,23 @@ odoo.define('beescoop.pos', function (require) {
"use strict"; "use strict";
var module = require("point_of_sale.screens"); var module = require("point_of_sale.screens");
var Model = require('web.DataModel'); var Model = require('web.DataModel');
var set_customer_info = function(el_class, value, prefix) {
var el = this.$(el_class);
el.empty();
if (prefix && value) {
value = prefix + value
}
if (value) {
el.append(value);
}
}
module.ReceiptScreenWidget = module.ReceiptScreenWidget.include({ module.ReceiptScreenWidget = module.ReceiptScreenWidget.include({
send : function() { send : function() {
var self = this; var self = this;
var loaded = new $.Deferred();
var order = this.pos.get_order().name; var order = this.pos.get_order().name;
var records = new Model('pos.order').call('send_order', [order], {});
var records = new Model('pos.order').call('send_order', [order], {}, { shadow: false, timeout: 10000});
records.then(function(result){ records.then(function(result){
var el = self.$('.message-send') var el = self.$('.message-send')
el.empty(); el.empty();
@ -31,4 +42,54 @@ odoo.define('beescoop.pos', function (require) {
this.$('.message-send').empty(); this.$('.message-send').empty();
}, },
}) })
module.ActionpadWidget = module.ActionpadWidget.include({
renderElement : function() {
var self = this;
var loaded = new $.Deferred();
this._super();
if (!this.pos.get_client()) {
return
}
var customer_id = this.pos.get_client().id;
var res = new Model('res.partner').call('get_balance_and_eater',
[ customer_id ], undefined, { shadow: true, timeout: 1000});
res.then(function(result) {
set_customer_info.call(self, '.customer-balance', result[0])
set_customer_info.call(self, '.customer-delegate1', result[1], 'Eater 1: ');
set_customer_info.call(self, '.customer-delegate2', result[2], 'Eater 2: ');
}, function(err) {
loaded.reject(err);
});
},
});
module.PaymentScreenWidget.include({
render_customer_info : function() {
var self = this;
var loaded = new $.Deferred();
if (!this.pos.get_client()) {
return
}
var customer_id = this.pos.get_client().id;
var res = new Model('res.partner').call('get_balance_and_eater', [ customer_id ], undefined, { shadow: true, timeout: 1000});
res.then(function(result) {
set_customer_info.call(self, '.customer-name', self.pos.get_client().name);
set_customer_info.call(self, '.customer-balance', result[0]);
set_customer_info.call(self, '.customer-delegate1', result[1], 'Eater 1: ');
set_customer_info.call(self, '.customer-delegate2', result[2], 'Eater 2: ');
}, function(err) {
loaded.reject(err);
});
},
renderElement : function() {
this._super();
this.render_customer_info();
},
customer_changed : function() {
this._super();
this.render_customer_info();
},
});
}); });

24
beesdoo_pos/static/src/xml/templates.xml

@ -6,8 +6,32 @@
<i class='fa fa-envelope'></i> Send Receipt By Mail <i class='fa fa-envelope'></i> Send Receipt By Mail
</div> </div>
<div class="message-send"> <div class="message-send">
</div>
</t>
</t>
<t t-extend="ActionpadWidget">
<t t-jquery="t[t-if='widget.pos.get_client()']" t-operation="after">
<t t-if="widget.pos.get_client()">
<div class='customer-information-pay'>
Balance: <span class='customer-balance' />
<br /><span class='customer-delegate1' />
<br /><span class='customer-delegate2' />
</div> </div>
</t> </t>
</t> </t>
</t>
<t t-extend="PaymentScreenWidget">
<t t-jquery=".paymentmethods-container" t-operation="inner">
<t t-if="widget.pos.get_client()">
<div class="customer-information">
<span class='customer-name' /> <br />
Balance: <span class='customer-balance' /><br />
<span class='customer-delegate1' /> <br />
<span class='customer-delegate2' /> <br />
</div>
</t>
</t>
</t>
</templates> </templates>
Loading…
Cancel
Save