Browse Source

Adding beesdoo_pos module (version 9.0)

pull/128/head
Manuel Claeys Bouuaert 5 years ago
committed by Rémy Taymans
parent
commit
a525d0a017
  1. 2
      beesdoo_pos/__init__.py
  2. 35
      beesdoo_pos/__openerp__.py
  3. 14
      beesdoo_pos/data/cron.xml
  4. 22
      beesdoo_pos/data/email.xml
  5. 151
      beesdoo_pos/i18n/fr_BE.po
  6. 1
      beesdoo_pos/models/__init__.py
  7. 98
      beesdoo_pos/models/beesdoo_pos.py
  8. 5
      beesdoo_pos/security/ir.model.access.csv
  9. 34
      beesdoo_pos/static/src/css/beesdoo.css
  10. 95
      beesdoo_pos/static/src/js/beesdoo.js
  11. 80
      beesdoo_pos/static/src/xml/templates.xml
  12. 38
      beesdoo_pos/views/beesdoo_pos.xml

2
beesdoo_pos/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
import models

35
beesdoo_pos/__openerp__.py

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
{
'name': "Beescoop Point of sale",
'summary': """
Module that extends the pos for the beescoop
""",
'description': """
Long description of module's purpose
""",
'author': "Beescoop - Cellule IT",
'website': "https://github.com/beescoop/Obeesdoo",
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
# for the full list
'category': 'Point Of Sale',
'version': '9.0.1.1.0',
# any module necessary for this one to work correctly
'depends': ['beesdoo_base', 'beesdoo_product'],
# always loaded
'data': [
'security/ir.model.access.csv',
'views/beesdoo_pos.xml',
'data/email.xml',
'data/cron.xml',
],
'qweb': ['static/src/xml/templates.xml'],
# only loaded in demonstration mode
}

14
beesdoo_pos/data/cron.xml

@ -0,0 +1,14 @@
<odoo>
<data noupdate="1">
<record id="ir_cron_sent_pos_ticket" model="ir.cron">
<field name="name">send ticket</field>
<field name="interval_number">1</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="model">pos.order</field>
<field name="function">_send_order_cron</field>
<field name="args">()</field>
</record>
</data>
</odoo>

22
beesdoo_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>

151
beesdoo_pos/i18n/fr_BE.po

@ -0,0 +1,151 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * beesdoo_pos
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-11-13 15:23+0000\n"
"PO-Revision-Date: 2016-11-13 15:23+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: beesdoo_pos
#: model:mail.template,body_html:beesdoo_pos.email_send_ticket
msgid "\n"
"Votre Ticket ${object.pos_reference}\n"
" "
msgstr "<p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;\"></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;\">\n"
"\n"
"</p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;\">\n"
"\n"
"</p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;color: rgb(33, 33, 33)\"><font style=\"font-size: 12px;\">Bonjour,&nbsp;</font></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;color: rgb(33, 33, 33)\"><font style=\"font-size: 12px;\">Vous trouverez ci-joint votre ticket de caisse en version électronique.</font></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;color: rgb(33, 33, 33)\"><font style=\"font-size: 12px;\">Pour rappel, à partir d'octobre, le Labo market&nbsp;est ouvert les lundis, mardis, mercredis de 17h30 à 20h et les samedis de 10h30 à 16h.</font></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;color: rgb(33, 33, 33)\"><font style=\"font-size: 12px;\">Pour vous inscrire à des permanences BEES, rendez-vous sur&nbsp;<a href=\"http://shift.bees-coop.be/\" target=\"_blank\" style=\"cursor:pointer;text-decoration:none;color:rgb(51, 122, 183);background-color:transparent;\">http://shift.bees-coop.be/</a>&nbsp;.</font></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;color: rgb(33, 33, 33)\"><font style=\"font-size: 12px;\">Au plaisir de vous revoir au Labo market.</font></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;color: rgb(33, 33, 33)\"></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;color: rgb(33, 33, 33)\"></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;\"></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;\"></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;color: rgb(33, 33, 33)\"><font style=\"font-size: 12px;\">BEES&nbsp;&nbsp;coop,</font></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;color: rgb(33, 33, 33)\"><img src=\"/web/image/9457\" class=\"pull-left\" style=\"float:left;vertical-align:middle;border-image-repeat:initial;border-image-outset:initial;border-image-width:initial;border-image-slice:initial;border-image-source:initial;border-left-color:initial;border-bottom-color:initial;border-right-color:initial;border-top-color:initial;border-left-style:initial;border-bottom-style:initial;border-right-style:initial;border-top-style:initial;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;border-top-width:0px;width: 25%;\"></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;color: rgb(33, 33, 33)\"><font style=\"font-size: 12px;\"></font></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;color: rgb(33, 33, 33)\"><font style=\"font-size: 12px;\"></font></p><p style=\"margin:0px 0px 10px 0px;font-size:13px;font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;\"></p>"
#. module: beesdoo_pos
#: model:mail.template,subject:beesdoo_pos.email_send_ticket
msgid "${object.pos_reference}"
msgstr "${object.pos_reference}"
#. module: beesdoo_pos
#: model:ir.model,name:beesdoo_pos.model_account_bank_statement_cashbox
msgid "Account Bank Statement Cashbox Details"
msgstr "Détails"
#. module: beesdoo_pos
#. openerp-web
#: code:addons/beesdoo_pos/static/src/xml/templates.xml:17
#: code:addons/beesdoo_pos/static/src/xml/templates.xml:35
#, python-format
msgid "Balance:"
msgstr "Balance:"
#. module: beesdoo_pos
#: model:ir.ui.view,arch_db:beesdoo_pos.beescoop_pos_inherit
msgid "Bill Value"
msgstr "Bill Value"
#. module: beesdoo_pos
#: model:ir.model.fields,field_description:beesdoo_pos.field_pos_config_bill_value
msgid "Bill value"
msgstr "Bill value"
#. module: beesdoo_pos
#: code:addons/beesdoo_pos/models/beesdoo_pos.py:38
#, python-format
msgid "Cannot send the ticket, no email address found on the client"
msgstr "Cannot send the ticket, no email address found on the client"
#. module: beesdoo_pos
#: model:ir.model.fields,field_description:beesdoo_pos.field_bill_value_create_uid
msgid "Created by"
msgstr "Créé par"
#. module: beesdoo_pos
#: model:ir.model.fields,field_description:beesdoo_pos.field_bill_value_create_date
msgid "Created on"
msgstr "Créé le"
#. module: beesdoo_pos
#: model:ir.model.fields,field_description:beesdoo_pos.field_bill_value_display_name
msgid "Display Name"
msgstr "Nom affiché"
#. module: beesdoo_pos
#: code:addons/beesdoo_pos/models/beesdoo_pos.py:36
#, python-format
msgid "Error: no order found"
msgstr "Error: no order found"
#. module: beesdoo_pos
#: model:ir.model.fields,field_description:beesdoo_pos.field_bill_value_id
msgid "ID"
msgstr "ID"
#. module: beesdoo_pos
#: model:ir.model.fields,field_description:beesdoo_pos.field_bill_value___last_update
msgid "Last Modified on"
msgstr "Dernière modification le"
#. module: beesdoo_pos
#: model:ir.model.fields,field_description:beesdoo_pos.field_bill_value_write_uid
msgid "Last Updated by"
msgstr "Mis à jour par"
#. module: beesdoo_pos
#: model:ir.model.fields,field_description:beesdoo_pos.field_bill_value_write_date
msgid "Last Updated on"
msgstr "Mis à jour le"
#. module: beesdoo_pos
#: model:ir.model.fields,field_description:beesdoo_pos.field_bill_value_name
msgid "Name"
msgstr "Nom"
#. module: beesdoo_pos
#: model:ir.model,name:beesdoo_pos.model_res_partner
msgid "Partner"
msgstr "Partenaire"
#. module: beesdoo_pos
#: model:ir.model,name:beesdoo_pos.model_pos_order
msgid "Point of Sale"
msgstr "Point de vente"
#. module: beesdoo_pos
#: model:ir.model.fields,field_description:beesdoo_pos.field_bill_value_pos
msgid "Pos"
msgstr "Pos"
#. module: beesdoo_pos
#. openerp-web
#: code:addons/beesdoo_pos/static/src/xml/templates.xml:6
#, python-format
msgid "Send Receipt By Mail"
msgstr "Send Receipt By Mail"
#. module: beesdoo_pos
#: model:mail.template,report_name:beesdoo_pos.email_send_ticket
msgid "Ticket ${object.pos_reference}"
msgstr "Ticket ${object.pos_reference}"
#. module: beesdoo_pos
#: code:addons/beesdoo_pos/models/beesdoo_pos.py:41
#, python-format
msgid "Ticket sent"
msgstr "Ticket sent"
#. module: beesdoo_pos
#: model:ir.model,name:beesdoo_pos.model_bill_value
msgid "bill_value"
msgstr "bill_value"
#. module: beesdoo_pos
#: model:ir.model,name:beesdoo_pos.model_pos_config
msgid "pos.config"
msgstr "pos.config"

1
beesdoo_pos/models/__init__.py

@ -0,0 +1 @@
import beesdoo_pos

98
beesdoo_pos/models/beesdoo_pos.py

@ -0,0 +1,98 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api, _
import logging
_logger = logging.getLogger(__name__)
class BeesPOS(models.Model):
_inherit = 'pos.config'
bill_value = fields.One2many('bill_value', 'pos', copy=True)
class BillValue(models.Model):
_name = 'bill_value'
_order = 'name asc'
name = fields.Float(string='Name')
pos = fields.Many2one('pos.config')
class BeesAccountBankStatement(models.Model):
_inherit = 'account.bank.statement.cashbox'
def _get_default_line(self):
if not self.env.context.get('active_id'):
return []
pos_session_rec = self.env['pos.session'].browse(self.env.context['active_id'])
return [(0, 0, {'coin_value' : bill_value_rec.name, 'subtotal':0.0}) 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'
print_status = fields.Selection([('no_print', 'Do not Print'),
('to_print', 'To print'),
('printed', 'Printed')],
default="no_print", string="Print Status")
@api.model
def send_order(self, receipt_name):
order = self.search([('pos_reference', '=', receipt_name)])
if not order:
return _('Error: no order found')
if not order.partner_id.email:
return _('Cannot send the ticket, no email address found on the client')
order.print_status = 'to_print'
return _("Ticket will be sent")
@api.model
def _send_order_cron(self):
mail_template = self.env.ref("beesdoo_pos.email_send_ticket")
_logger.info("Start to send ticket")
for order in self.search([('print_status', '=', 'to_print')]):
if not order.partner_id.email:
continue
mail_template.send_mail(order.id, force_send=True)
order.print_status = 'printed'
#Make sure we commit the change to not send ticket twice
self.env.cr.commit()
class BeescoopPosPartner(models.Model):
_inherit = 'res.partner'
def _get_eater(self):
eaters = [False, False, False]
for i, eater in enumerate(self.child_eater_ids):
eaters[i] = eater.name
return tuple(eaters)
@api.multi
def get_eater(self):
eater1, eater2, eater3 = self._get_eater()
return eater1, eater2, eater3
from openerp.addons.point_of_sale.report import pos_receipt
class order_tva_included(pos_receipt.order):
def __init__(self, cr, uid, name, context):
super(order_tva_included, self).__init__(cr, uid, name, context=context)
self.env = api.Environment(cr, uid, context)
def netamount(self, order_line_id):
order_line = self.env['pos.order.line'].browse(order_line_id)
if order_line.order_id.config_id.iface_tax_included:
return order_line.price_subtotal_incl
else:
return order_line.price_subtotal
class report_order_receipt(models.AbstractModel):
_inherit = 'report.point_of_sale.report_receipt'
_template = 'point_of_sale.report_receipt'
_wrapped_report_class = order_tva_included

5
beesdoo_pos/security/ir.model.access.csv

@ -0,0 +1,5 @@
"id","name","model_id/id","group_id/id","perm_read","perm_write","perm_create","perm_unlink"
"bill_value_read_all","Read All","beesdoo_pos.model_bill_value","","True","False","False","False"
"bill_value_accountant_all","All Comptable","beesdoo_pos.model_bill_value","account.group_account_user","True","True","True","True"
"bill_value_pos_manager_all","All POS manager","beesdoo_pos.model_bill_value","point_of_sale.group_pos_manager","True","True","True","True"
"account_bank_statement_cashbox POS user","account.bank.statement.cashbox POS User","account.model_account_bank_statement_cashbox","point_of_sale.group_pos_user","True","True","True","False"

34
beesdoo_pos/static/src/css/beesdoo.css

@ -0,0 +1,34 @@
.message-send {
margin: 16px;
text-align: center;
}
.customer-information {
margin: 16px 24px 16px 24px;
font-weight: bold;
font-size: 16px;
}
.customer-name {
font-size: 18px;
}
.pos .actionpad .button.set-customer {
height: 108px;
}
.pos .actionpad .button .fa-user {
left: 5px;
top: 38px;
}
.customer-information-pay {
font-weight: normal;
font-size: 12px;
text-align: left;
}
.pos .actionpad .button.pay {
height: 108px;
}

95
beesdoo_pos/static/src/js/beesdoo.js

@ -0,0 +1,95 @@
odoo.define('beescoop.pos', function (require) {
"use strict";
var module = require("point_of_sale.screens");
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({
send : function() {
var self = this;
var loaded = new $.Deferred();
var order = this.pos.get_order().name;
var records = new Model('pos.order').call('send_order', [order], {}, { shadow: false, timeout: 10000});
records.then(function(result){
var el = self.$('.message-send')
el.empty();
el.append('<h2>' + result + '</h2>');
},function(err){
loaded.reject(err);
});
},
renderElement: function() {
var self = this;
this._super();
this.$('.button.send').click(function(){
if (!self._locked) {
self.send();
}
});
},
show: function(){
this._super();
var self = this;
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_eater',
[ customer_id ], undefined, { shadow: true, timeout: 1000});
res.then(function(result) {
set_customer_info.call(self, '.customer-delegate1', result[0], 'Eater 1: ');
set_customer_info.call(self, '.customer-delegate2', result[1], 'Eater 2: ');
set_customer_info.call(self, '.customer-delegate3', result[2], 'Eater 3: ');
}, 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_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-delegate1', result[0], 'Eater 1: ');
set_customer_info.call(self, '.customer-delegate2', result[1], 'Eater 2: ');
set_customer_info.call(self, '.customer-delegate3', result[2], 'Eater 3: ');
}, function(err) {
loaded.reject(err);
});
},
renderElement : function() {
this._super();
this.render_customer_info();
},
customer_changed : function() {
this._super();
this.render_customer_info();
},
});
});

80
beesdoo_pos/static/src/xml/templates.xml

@ -0,0 +1,80 @@
<?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>
<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'>
<span class='customer-delegate1' />
<br />
<span class='customer-delegate2' />
<br />
<span class='customer-delegate3' />
</div>
</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 />
<span class='customer-delegate1' />
<br />
<span class='customer-delegate2' />
<br />
<span class='customer-delegate3' />
<br />
</div>
</t>
</t>
</t>
<t t-extend="ClientListScreenWidget">
<t t-jquery='.new-customer' t-operation='replace'>
</t>
<t t-jquery=".client-list" t-operation="replace">
<table class='client-list'>
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody class='client-list-contents'>
</tbody>
</table>
</t>
</t>
<t t-extend="ClientLine">
<t t-jquery=".client-line" t-operation="replace">
<tr class='client-line' t-att-data-id='partner.id'>
<td><t t-esc='partner.name' /></td>
</tr>
</t>
</t>
<t t-extend="ClientDetails">
<t t-jquery=".client-details-left" t-operation="replace">
<div class='client-details-left'></div>
</t>
<t t-jquery=".edit-buttons" t-operation="replace">
<div class='edit-buttons'></div>
</t>
</t>
</templates>

38
beesdoo_pos/views/beesdoo_pos.xml

@ -0,0 +1,38 @@
<openerp>
<data>
<record model="ir.ui.view" id="beescoop_pos_inherit">
<field name="name">bees.pos.config.form.view</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_form" />
<field name="arch" type="xml">
<field name="iface_tax_included" position="after">
<separator string="Bill Value" colspan="2" />
<field name="bill_value" nolabel="1" colspan="2">
<tree editable="bottom">
<field name="name" />
</tree>
</field>
</field>
</field>
</record>
<record id="view_account_bnk_stmt_cashbox" model="ir.ui.view">
<field name="name">account.bnk_stmt_cashbox.form</field>
<field name="model">account.bank.statement.cashbox</field>
<field name="inherit_id" ref="account.view_account_bnk_stmt_cashbox" />
<field name="arch" type="xml">
<field name="coin_value" position="attributes">
<attribute name="readonly">1</attribute>
</field>
</field>
</record>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript"
src="/beesdoo_pos/static/src/js/beesdoo.js"></script>
<link rel='stylesheet' href="/beesdoo_pos/static/src/css/beesdoo.css" />
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save