Commit a747b1f9 by Thibault Grandjean

Merge branch 'dev_cooperatic' of https://gl.cooperatic.fr/cooperatic-foodcoops/odoo into docker

parents 3cd0ed8a 59273361
......@@ -27,6 +27,9 @@ class ShiftRegistration(models.Model):
to_add = 2 if absence_status == 'absent' else 1
for s in self.env['shift.registration']\
.search([('id', 'in', self.ids)]):
# Missing a makeup leads to have an additional makeup (the shift you initialy missed + the makeup you missed)
if s.is_makeup is True:
to_add += 1
new_makeups_to_do = s.partner_id.makeups_to_do + to_add
s.partner_id.update({'makeups_to_do': new_makeups_to_do})
return super(ShiftRegistration, self).write(vals)
\ No newline at end of file
......@@ -58,6 +58,9 @@ Products
.. figure:: https://raw.githubusercontent.com/legalsylvain/pos/12.0-ADD-pos_meal_voucher/pos_meal_voucher/static/description/pos_config_form.png
* configure if you want to allow or forbid to exceed the maximum allowed by ticket and for order (Give change on meal voucher)
Usage
=====
......@@ -86,6 +89,9 @@ It is a non blocking warning, because we don't want to prevent an order to be do
if products are not correctly set, or if a recent law changed the maximum amount that can
be used each day. (A recent case occured in France, during the Covid-19 pandemy)
If you want to make it impossible to finish an order if the amount of meal voucher is too big then uncheck the option "meal_voucher_change_accepted"
In this case if the cashier tries to validate the order the warning will redirect him to the paiement page.
Note
~~~~
......
......@@ -292,3 +292,64 @@ msgstr "En cliquant sur ce bouton, tous les produits de cette catégories auront
msgid "kg"
msgstr "kg"
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:159
#, python-format
msgid "Meal Voucher Amount incorrect"
msgstr "Titre restaurant incorrect"
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:160
#, python-format
msgid "Warning, the maximum amount of meal voucher accepted ( "
msgstr "Attention, le montant éligible au paiement par titre restaurant( "
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:160
#, python-format
msgid " ) is under the amount input ( "
msgstr " ) est inférieur à la valeur du/des ticket(s)( "
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:110
#, python-format
msgid "Warning, the input amount of meal voucher is above the maximum amount of "
msgstr "Le montant saisi est supérieur au montant maximum/au maximum éligible de "
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:
#, python-format
msgid "Meal Voucher already used"
msgstr "Ticket restaurant déjà scanné"
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:
#, python-format
msgid "The paper meal voucher "
msgstr "Le ticket restaurant "
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:
#, python-format
msgid " was already used"
msgstr " a déjà été scanné"
#: code:addons/pos_meal_voucher/static/src/js/screens.js:196
#, python-format
msgid "Meal Voucher ticket"
msgstr "Chèque restaurant"
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:197
#, python-format
msgid "To add a meal voucher ticket close this window and scan the ticket. If the ticket can't be read please enter the code"
msgstr "Pour ajouter un chèque restaurant merci de fermer cette fenêtre et scanner le chèque. Si le chèque est illisible veuillez rentrer le code à la main."
......@@ -16,3 +16,7 @@ class PosConfig(models.Model):
meal_voucher_display_product_screen = fields.Boolean(
string="Display icon before products on screen",
default=True)
meal_voucher_change_accepted = fields.Boolean(
string="Give change on meal voucher",
default=True)
......@@ -7,7 +7,7 @@ odoo.define("pos_meal_voucher.models", function (require) {
var models = require("point_of_sale.models");
var utils = require("web.utils");
var round_pr = utils.round_precision;
models.load_fields("product.product", ["meal_voucher_ok"]);
......@@ -16,6 +16,14 @@ odoo.define("pos_meal_voucher.models", function (require) {
var OrderSuper = models.Order.prototype;
var Order = models.Order.extend({
paper_meal_vouche_number_already_used: function(meal_voucher_number){
for(const paiementLine of this.get_paymentlines()){
if(paiementLine.statement_note == meal_voucher_number) return true
}
return false;
},
get_total_meal_voucher_eligible: function() {
return round_pr(this.orderlines.reduce((function(sum, orderLine) {
......@@ -35,6 +43,126 @@ odoo.define("pos_meal_voucher.models", function (require) {
}
}), 0), this.pos.currency.rounding);
},
/* point_of_sale/statis/src/js/models.js */
export_for_printing: function(){
var orderlines = [];
var self = this;
var paymentlines = [];
// Add fork&knife symbol on pos ticket for products with meal voucher allowed & when meal voucher is used
var meal_voucher_used = false;
this.paymentlines.each(function(paymentline){
var line = paymentline.export_for_printing();
paymentlines.push(line);
if (paymentline.is_meal_voucher()) {
meal_voucher_used = true;
}
});
this.orderlines.each(function(orderline){
var orderline_for_printing = orderline.export_for_printing()
if (
meal_voucher_used === true &&
orderline.product.meal_voucher_ok === true &&
orderline_for_printing.product_name.includes(String.fromCharCode(0xD83C, 0xDF74)) === false
) {
orderline_for_printing.product_name = String.fromCharCode(0xD83C, 0xDF74) + " " + orderline_for_printing.product_name;
} else if (meal_voucher_used === false && orderline_for_printing.product_name.includes(String.fromCharCode(0xD83C, 0xDF74)) === true) {
orderline_for_printing.product_name = orderline_for_printing.product_name.replace(String.fromCharCode(0xD83C, 0xDF74) + " ", "");
}
orderlines.push(orderline_for_printing);
});
var client = this.get('client');
var cashier = this.pos.cashier || this.pos.user;
var company = this.pos.company;
var shop = this.pos.shop;
var date = new Date();
function is_xml(subreceipt){
return subreceipt ? (subreceipt.split('\n')[0].indexOf('<!DOCTYPE QWEB') >= 0) : false;
}
function render_xml(subreceipt){
if (!is_xml(subreceipt)) {
return subreceipt;
} else {
subreceipt = subreceipt.split('\n').slice(1).join('\n');
var qweb = new QWeb2.Engine();
qweb.debug = core.debug;
qweb.default_dict = _.clone(QWeb.default_dict);
qweb.add_template('<templates><t t-name="subreceipt">'+subreceipt+'</t></templates>');
return qweb.render('subreceipt',{'pos':self.pos,'widget':self.pos.chrome,'order':self, 'receipt': receipt}) ;
}
}
var receipt = {
orderlines: orderlines,
paymentlines: paymentlines,
subtotal: this.get_subtotal(),
total_with_tax: this.get_total_with_tax(),
total_without_tax: this.get_total_without_tax(),
total_tax: this.get_total_tax(),
total_paid: this.get_total_paid(),
total_discount: this.get_total_discount(),
tax_details: this.get_tax_details(),
change: this.get_change(),
name : this.get_name(),
client: client ? client.name : null ,
invoice_id: null, //TODO
cashier: cashier ? cashier.name : null,
precision: {
price: 2,
money: 2,
quantity: 3,
},
date: {
year: date.getFullYear(),
month: date.getMonth(),
date: date.getDate(), // day of the month
day: date.getDay(), // day of the week
hour: date.getHours(),
minute: date.getMinutes() ,
isostring: date.toISOString(),
localestring: date.toLocaleString(),
},
company:{
email: company.email,
website: company.website,
company_registry: company.company_registry,
contact_address: company.partner_id[1],
vat: company.vat,
name: company.name,
phone: company.phone,
logo: this.pos.company_logo_base64,
},
shop:{
name: shop.name,
},
currency: this.pos.currency,
};
if (is_xml(this.pos.config.receipt_header)){
receipt.header = '';
receipt.header_xml = render_xml(this.pos.config.receipt_header);
} else {
receipt.header = this.pos.config.receipt_header || '';
}
if (is_xml(this.pos.config.receipt_footer)){
receipt.footer = '';
receipt.footer_xml = render_xml(this.pos.config.receipt_footer);
} else {
receipt.footer = this.pos.config.receipt_footer || '';
}
return receipt;
},
});
models.Order = Order;
......@@ -71,6 +199,14 @@ odoo.define("pos_meal_voucher.models", function (require) {
this.cashregister.journal.meal_voucher_type) !== -1
);
},
is_dematerialized_meal_voucher: function() {
return (
this.cashregister.journal.meal_voucher_type == "dematerialized") ;
},
is_paper_meal_voucher: function() {
return (
this.cashregister.journal.meal_voucher_type == "paper") ;
},
});
......
......@@ -78,5 +78,10 @@
</t>
</t>
</t>
<t t-extend="TextInputPopupWidget">
<t t-jquery="p.title" t-operation="after">
<p class="body"><t t-esc=" widget.options.body || '' "/></p>
</t>
</t>
</templates>
......@@ -14,6 +14,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<group string="Meal Vouchers">
<field name="max_meal_voucher_amount"/>
<field name="meal_voucher_display_product_screen"/>
<field name="meal_voucher_change_accepted"/>
</group>
</field>
</field>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment