Browse Source

[WIP] Ticket by mail

pull/6/head
Thibault Francois 9 years ago
parent
commit
4ae08b322a
  1. 22
      beescoop_pos/data/email.xml
  2. 26
      beescoop_pos/static/src/js/beescoop.js
  3. 10
      beescoop_pos/static/src/xml/templates.xml
  4. 2
      beesdoo_pos/__openerp__.py
  5. 15
      beesdoo_pos/models/beesdoo_pos.py
  6. 6
      beesdoo_pos/views/beesdoo_pos.xml

22
beescoop_pos/data/email.xml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!--Email template -->
<record id="email_send_ticket" model="mail.template">
<field name="name">Envoyer Reçu</field>
<field name="email_from">${(object.user_id.email and '%s &lt;%s&gt;' % (object.user_id.name, object.user_id.email) or '')|safe}</field>
<field name="subject">${object.pos_reference}</field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="model_id" ref="point_of_sale.model_pos_order"/>
<field name="auto_delete" eval="True"/>
<field name="report_template" ref="point_of_sale.action_report_pos_receipt"/>
<field name="report_name">Ticket ${object.pos_reference}</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="body_html"><![CDATA[
Votre Ticket ${object.pos_reference}
]]></field>
</record>
</data>
</odoo>

26
beescoop_pos/static/src/js/beescoop.js

@ -0,0 +1,26 @@
odoo.define('beescoop.pos', function (require) {
"use strict";
var module = require("point_of_sale.screens");
var Model = require('web.DataModel');
module.ReceiptScreenWidget = module.ReceiptScreenWidget.include({
send : function() {
var order = this.pos.get_order().name;
var records = new Model('pos.order').call('send_order', [order], {});
records.then(function(result){
console.log(result)
},function(err){
loaded.reject(err);
});
},
renderElement: function() {
var self = this;
this._super();
this.$('.button.send').click(function(){
if (!self._locked) {
self.send();
}
});
},
})
});

10
beescoop_pos/static/src/xml/templates.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template">
<t t-extend="ReceiptScreenWidget">
<t t-jquery='.pos-receipt-container' t-operation='before'>
<div class="button send">
<i class='fa fa-envelope'></i> Send Receipt By Mail
</div>
</t>
</t>
</templates>

2
beesdoo_pos/__openerp__.py

@ -26,7 +26,9 @@
'data': [
'security/ir.model.access.csv',
'views/beesdoo_pos.xml',
'data/email.xml',
],
'qweb': ['static/src/xml/templates.xml'],
# only loaded in demonstration mode
}

15
beesdoo_pos/models/beesdoo_pos.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from openerp import models, fields
from openerp import models, fields, api
class BeesPOS(models.Model):
_inherit = 'pos.config'
@ -24,3 +24,16 @@ class BeesAccountBankStatement(models.Model):
return [(0, 0, {'coin_value' : bill_value_rec.name}) for bill_value_rec in pos_session_rec.config_id.bill_value]
cashbox_lines_ids = fields.One2many(default=_get_default_line)
class BeescoopPosOrder(models.Model):
_inherit = 'pos.order'
@api.model
def send_order(self, receipt_name):
order = self.search([('pos_reference', '=', receipt_name)])
if not order.partner_id.email:
return False
mail_template = self.env.ref("beescoop_pos.email_send_ticket")
mail_template.send_mail(order.id)
return True

6
beesdoo_pos/views/beesdoo_pos.xml

@ -15,5 +15,11 @@
</field>
</field>
</record>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/beescoop_pos/static/src/js/beescoop.js"></script>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save