diff --git a/pos_formate/__init__.py b/pos_formate/__init__.py new file mode 100644 index 00000000000..878f71004eb --- /dev/null +++ b/pos_formate/__init__.py @@ -0,0 +1,4 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import models +from . import wizards diff --git a/pos_formate/__manifest__.py b/pos_formate/__manifest__.py new file mode 100644 index 00000000000..518a23592cb --- /dev/null +++ b/pos_formate/__manifest__.py @@ -0,0 +1,24 @@ +{ + 'name': "pos formate", + 'version': '1.0', + 'depends': ['point_of_sale'], + 'author': "gasa", + "license": "LGPL-3", + "sequence": 1, + 'data': [ + 'security/ir.model.access.csv', + 'wizards/pos_configure_receipt_views.xml', + 'views/res_config_settings_views.xml', + 'views/boxed_template.xml', + 'views/lined_template.xml', + 'views/light_template.xml', + ], + 'installable': True, + 'application': True, + 'assets': { + 'web.assets_backend': [ + 'pos_formate/static/src/order_receipt_patch.js', + 'pos_formate/static/src/order_receipt_patch.xml', + ], + }, +} diff --git a/pos_formate/models/__init__.py b/pos_formate/models/__init__.py new file mode 100644 index 00000000000..9a64ab25d27 --- /dev/null +++ b/pos_formate/models/__init__.py @@ -0,0 +1,3 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import res_config_settings diff --git a/pos_formate/models/pos_config.py b/pos_formate/models/pos_config.py new file mode 100644 index 00000000000..490fa9dc2cf --- /dev/null +++ b/pos_formate/models/pos_config.py @@ -0,0 +1,11 @@ +from odoo import models, fields + + +class PosConfig(models.Model): + _inherit = 'pos.config' + + receipt_layout = fields.Selection([ + ('light', 'Light'), + ('boxed', 'Boxed'), + ('lined', 'Lined'), + ], string="Receipt Layout", default='light') diff --git a/pos_formate/models/res_config_settings.py b/pos_formate/models/res_config_settings.py new file mode 100644 index 00000000000..2dbe6be6904 --- /dev/null +++ b/pos_formate/models/res_config_settings.py @@ -0,0 +1,28 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models, fields + + +class ResConfigSettings(models.TransientModel): + _inherit = 'res.config.settings' + + pos_receipt_layout = fields.Selection( + selection=[ + ('light', 'Light'), + ('boxed', 'Boxed'), + ('lined', 'Lined'), + ], + string="POS Receipt Layout", + default='light', + config_parameter='pos.receipt.layout' + ) + + def action_open_receipt_configuration(self): + """Open the wizard popup for receipt configuration""" + return { + 'type': 'ir.actions.act_window', + 'name': 'Configure Receipt', + 'res_model': 'pos.configure.receipt', + 'view_mode': 'form', + 'target': 'new', + } diff --git a/pos_formate/security/ir.model.access.csv b/pos_formate/security/ir.model.access.csv new file mode 100644 index 00000000000..a2868d96d18 --- /dev/null +++ b/pos_formate/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_pos_configure_receipt,pos.configure.receipt,model_pos_configure_receipt,base.group_system,1,1,1,1 diff --git a/pos_formate/static/src/order_receipt_patch.js b/pos_formate/static/src/order_receipt_patch.js new file mode 100644 index 00000000000..55aefa1cb18 --- /dev/null +++ b/pos_formate/static/src/order_receipt_patch.js @@ -0,0 +1,53 @@ +import { patch } from "@web/core/utils/patch"; +import { usePos } from "@point_of_sale/app/store/pos_hook"; +import { OrderReceipt } from "@point_of_sale/app/screens/receipt_screen/receipt/order_receipt"; +import { ReceiptHeader } from "@point_of_sale/app/screens/receipt_screen/receipt/receipt_header"; + +patch(ReceiptHeader.prototype, { + get props() { + return { + ...super.props, + data: { + ...this.props.data, + company_logo: this.props.data.company?.company_logo, + }, + }; + }, +}); + +patch(OrderReceipt.prototype, { + setup() { + super.setup(); + this.pos = usePos(); + }, + + template: "pos_formate.order_receipt_patch", + + get props() { + const { receipt_header, receipt_footer, company_logo, receipt_layout } = + this.pos.config; + return { + ...super.props, + orderQuantity: this.orderQuantity, + order: this.order, + data: { + ...this.props.data, + header: receipt_header || this.props.data.header, + footer: receipt_footer || this.props.data.footer, + company_logo, + layout: receipt_layout || "boxed", + }, + }; + }, + + get orderQuantity() { + return this.props.data.orderlines.reduce( + (sum, l) => sum + parseFloat(l.qty), + 0 + ); + }, + + get order() { + return this.pos.get_order(); + }, +}); diff --git a/pos_formate/static/src/order_receipt_patch.xml b/pos_formate/static/src/order_receipt_patch.xml new file mode 100644 index 00000000000..68aa98d2d32 --- /dev/null +++ b/pos_formate/static/src/order_receipt_patch.xml @@ -0,0 +1,335 @@ + + + + \ No newline at end of file diff --git a/pos_formate/views/boxed_template.xml b/pos_formate/views/boxed_template.xml new file mode 100644 index 00000000000..6a8f442ba5b --- /dev/null +++ b/pos_formate/views/boxed_template.xml @@ -0,0 +1,77 @@ + + + + \ No newline at end of file diff --git a/pos_formate/views/light_template.xml b/pos_formate/views/light_template.xml new file mode 100644 index 00000000000..5e0a237e251 --- /dev/null +++ b/pos_formate/views/light_template.xml @@ -0,0 +1,62 @@ + + + + \ No newline at end of file diff --git a/pos_formate/views/lined_template.xml b/pos_formate/views/lined_template.xml new file mode 100644 index 00000000000..393db480355 --- /dev/null +++ b/pos_formate/views/lined_template.xml @@ -0,0 +1,106 @@ + + + + \ No newline at end of file diff --git a/pos_formate/views/res_config_settings_views.xml b/pos_formate/views/res_config_settings_views.xml new file mode 100644 index 00000000000..47a7bcde0c0 --- /dev/null +++ b/pos_formate/views/res_config_settings_views.xml @@ -0,0 +1,20 @@ + + + res.config.settings.view.form + res.config.settings + + + + + + +
+