Skip to content

Commit 28fd33f

Browse files
committed
[ADD] pos_formate: add pos formate module for select and edit receipt formate
In this task, Add new module pos format in which select receipt type (ex. lined, light, boxed) also add header, footer and logo and can see the preview of receipt. for this task use wizards, js file for report and add three template for preview.
1 parent fbf9ee9 commit 28fd33f

17 files changed

+944
-0
lines changed

pos_formate/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from . import models
4+
from . import wizards

pos_formate/__manifest__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
'name': "pos formate",
3+
'version': '1.0',
4+
'depends': ['point_of_sale'],
5+
'author': "gasa",
6+
"license": "LGPL-3",
7+
"sequence": 1,
8+
'data': [
9+
'security/ir.model.access.csv',
10+
'wizards/pos_configure_receipt_views.xml',
11+
'views/res_config_settings_views.xml',
12+
'views/boxed_template.xml',
13+
'views/lined_template.xml',
14+
'views/light_template.xml',
15+
],
16+
'installable': True,
17+
'application': True,
18+
'assets': {
19+
'point_of_sale._assets_pos': [
20+
'pos_formate/static/src/order_receipt_patch.js',
21+
'pos_formate/static/src/order_receipt_patch.xml',
22+
],
23+
},
24+
}

pos_formate/models/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from . import res_config_settings
4+
from . import pos_config

pos_formate/models/pos_config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from odoo import models, fields
2+
3+
4+
class PosConfig(models.Model):
5+
_inherit = 'pos.config'
6+
7+
receipt_layout = fields.Selection([
8+
('light', 'Light'),
9+
('boxed', 'Boxed'),
10+
('lined', 'Lined'),
11+
], string="Receipt Layout", default='light')
12+
13+
receipt_logo = fields.Binary("Receipt Logo")
14+
receipt_header = fields.Text("Receipt Header")
15+
receipt_footer = fields.Text("Receipt Footer")
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from odoo import models, fields
4+
5+
6+
class ResConfigSettings(models.TransientModel):
7+
_inherit = 'res.config.settings'
8+
9+
pos_receipt_layout = fields.Selection(
10+
selection=[
11+
('light', 'Light'),
12+
('boxed', 'Boxed'),
13+
('lined', 'Lined'),
14+
],
15+
string="POS Receipt Layout",
16+
default='light',
17+
config_parameter='pos.receipt.layout'
18+
)
19+
20+
def action_open_receipt_configuration(self):
21+
return {
22+
'type': 'ir.actions.act_window',
23+
'name': 'Configure Receipt',
24+
'res_model': 'pos.configure.receipt',
25+
'view_mode': 'form',
26+
'target': 'new',
27+
"context": {
28+
"default_pos_config_id": self.pos_config_id.id,
29+
},
30+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
access_pos_configure_receipt,pos.configure.receipt,model_pos_configure_receipt,base.group_system,1,1,1,1
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/** @odoo-module **/
2+
3+
import { OrderReceipt } from "@point_of_sale/app/screens/receipt_screen/receipt/order_receipt";
4+
import { patch } from "@web/core/utils/patch";
5+
import { usePos } from "@point_of_sale/app/store/pos_hook";
6+
7+
console.log("OrderReceipt Imported:", OrderReceipt);
8+
9+
patch(OrderReceipt, {
10+
template: "pos_formate.order_receipt_inherited",
11+
});
12+
13+
console.log("OrderReceipt Template Patch Applied");
14+
15+
patch(OrderReceipt.prototype, {
16+
setup() {
17+
super.setup();
18+
this.pos = usePos();
19+
console.log("POS Receipt Patch Loaded");
20+
},
21+
22+
get receiptLogo() {
23+
const logo = this.pos.config?.receipt_logo;
24+
console.log("Receipt Logo Data:", logo ? "Logo Found" : "No Logo");
25+
return logo ? `data:image/png;base64,${logo}` : false;
26+
},
27+
28+
get receiptLayout() {
29+
const layout = this.pos.config?.receipt_layout || "light";
30+
console.log("Receipt Layout:", layout);
31+
return layout;
32+
},
33+
34+
get orderQuantity() {
35+
return this.props.data.orderlines.reduce(
36+
(acc, line) => acc + parseFloat(line.qty),
37+
0
38+
);
39+
},
40+
41+
get order() {
42+
return this.pos.get_order();
43+
},
44+
});

0 commit comments

Comments
 (0)