Skip to content

Commit 65e7190

Browse files
committed
[ADD]Added pos_order_line_customer_history module
1 parent 5d9ad8f commit 65e7190

File tree

19 files changed

+4404
-0
lines changed

19 files changed

+4404
-0
lines changed

package-lock.json

Lines changed: 2824 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"devDependencies": {
3+
"eslint-plugin-import": "^2.31.0"
4+
}
5+
}
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
================================
2+
Point of Sale - Customer history
3+
================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:1ec25ac0bb1183de1b159c820384c4b101047a7d75c087363f42622366d5ae4f
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github
20+
:target: https://github.com/OCA/pos/tree/17.0/pos_order_line_customer_history
21+
:alt: OCA/pos
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_order_line_customer_history
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=17.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
POS Order Line Customer History
32+
===============================
33+
34+
This module adds a feature in the Point of Sale (POS) interface to allow
35+
users to view the sales history of a selected customer and reuse past
36+
order lines in new orders.
37+
38+
Features
39+
--------
40+
41+
- Adds a **"History" button** above the customer details on the POS
42+
screen.
43+
- When clicked, opens a new view showing past ``pos.order.line`` records
44+
for the selected customer.
45+
- If no customer is selected, a popup is displayed with the message:
46+
"You must select a customer first"
47+
48+
History View
49+
~~~~~~~~~~~~
50+
51+
- Displays a list of past order lines for the selected customer.
52+
- Ordered by most recent first.
53+
- Shown fields:
54+
55+
- **Date**
56+
- **Product**
57+
- **Quantity**
58+
- **Discount**
59+
- **Price Unit**
60+
- **Total**
61+
62+
Functionalities
63+
~~~~~~~~~~~~~~~
64+
65+
- **Sortable Data**: Users can sort the list by selecting from a
66+
dropdown with the following options:
67+
68+
- Date ASC
69+
- Date DESC
70+
- Product ASC
71+
- Product DESC
72+
- Price Unit ASC
73+
- Price Unit DESC
74+
- Qty ASC
75+
- Qty DESC
76+
- Total ASC
77+
- Total DESC
78+
79+
- **Search Bar**:
80+
81+
- Filter by **product name** or **barcode**
82+
- Filter by **date**
83+
84+
- **Line Selection**:
85+
86+
- Select one or more lines from the list.
87+
- Add selected products and their quantities to the current POS order.
88+
- Note: **Discounts and prices are not copied**, only **product and
89+
quantity** are reused.
90+
91+
Usage
92+
-----
93+
94+
1. Select a customer in the POS interface.
95+
2. Click the "History" button to view their order history.
96+
3. Use the search and sort features to find relevant products.
97+
4. Select lines and add them to the current order as needed.
98+
99+
Technical Information
100+
---------------------
101+
102+
- Compatible with Odoo 17.0
103+
- Developed following OCA module standards.
104+
105+
**Table of contents**
106+
107+
.. contents::
108+
:local:
109+
110+
Bug Tracker
111+
===========
112+
113+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/issues>`_.
114+
In case of trouble, please check there if your issue has already been reported.
115+
If you spotted it first, help us to smash it by providing a detailed and welcomed
116+
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_order_line_customer_history%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
117+
118+
Do not contact contributors directly about support or help with technical issues.
119+
120+
Credits
121+
=======
122+
123+
Authors
124+
-------
125+
126+
* Serpent Consulting Services Pvt. Ltd.
127+
128+
Contributors
129+
------------
130+
131+
- `SerpentCS <https://www.serpentcs.com>`__:
132+
133+
- Parvez Qureshi <[email protected]>
134+
135+
Maintainers
136+
-----------
137+
138+
This module is maintained by the OCA.
139+
140+
.. image:: https://odoo-community.org/logo.png
141+
:alt: Odoo Community Association
142+
:target: https://odoo-community.org
143+
144+
OCA, or the Odoo Community Association, is a nonprofit organization whose
145+
mission is to support the collaborative development of Odoo features and
146+
promote its widespread use.
147+
148+
.. |maintainer-Serpent Consulting Services Pvt. Ltd.| image:: https://github.com/Serpent Consulting Services Pvt. Ltd..png?size=40px
149+
:target: https://github.com/Serpent Consulting Services Pvt. Ltd.
150+
:alt: Serpent Consulting Services Pvt. Ltd.
151+
152+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
153+
154+
|maintainer-Serpent Consulting Services Pvt. Ltd.|
155+
156+
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/17.0/pos_order_line_customer_history>`_ project on GitHub.
157+
158+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "Point of Sale - Customer history",
3+
"summary": "Adds product in the customer history screen of POS",
4+
"version": "17.0.1.0.0",
5+
"category": "Point of sale",
6+
"website": "https://github.com/OCA/pos",
7+
"author": "Serpent Consulting Services Pvt. Ltd., Odoo Community Association (OCA)",
8+
"maintainers": ["Serpent Consulting Services Pvt. Ltd."],
9+
"license": "AGPL-3",
10+
"installable": True,
11+
"depends": ["point_of_sale"],
12+
"assets": {
13+
"point_of_sale._assets_pos": [
14+
"pos_order_line_customer_history/static/src/Buttons/customer_history.xml",
15+
"pos_order_line_customer_history/static/src/Screens/CustomerHistoryScreen.xml",
16+
"pos_order_line_customer_history/static/src/Screens/CustomerHistoryScreen.scss",
17+
"pos_order_line_customer_history/static/src/Screens/CustomerHistoryScreen.esm.js",
18+
"pos_order_line_customer_history/static/src/Buttons/customer_history.esm.js",
19+
"pos_order_line_customer_history/static/src/models/pos_store.esm.js",
20+
"pos_order_line_customer_history/static/src/navbar/back_button.esm.js",
21+
]
22+
},
23+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import pos_order
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from collections import defaultdict
2+
from datetime import datetime
3+
4+
import pytz
5+
6+
from odoo import api, fields, models
7+
from odoo.osv.expression import AND
8+
9+
10+
class PosOrder(models.Model):
11+
_inherit = "pos.order"
12+
13+
@api.model
14+
def search_paid_orderline_ids(self, config_id, domain, limit, offset, orderby="id"):
15+
default_domain = [
16+
("order_id.state", "!=", "draft"),
17+
("order_id.state", "!=", "cancel"),
18+
]
19+
real_domain = AND([domain, default_domain])
20+
orderlines = self.env["pos.order.line"].search(
21+
real_domain, limit=limit, offset=offset, order=orderby
22+
)
23+
orderLines_info = defaultdict(lambda: datetime.min)
24+
for orderline in orderlines:
25+
if orderLines_info[orderline.id] < orderline.write_date:
26+
orderLines_info[orderline.id] = orderline.write_date
27+
totalCount = self.env["pos.order.line"].search_count(real_domain)
28+
return {
29+
"orderLinesInfo": list(orderLines_info.items()),
30+
"totalCount": totalCount,
31+
}
32+
33+
34+
class PosOrderLine(models.Model):
35+
_inherit = "pos.order.line"
36+
37+
date_order = fields.Datetime(related="order_id.date_order", store=True)
38+
39+
def _export_for_ui(self, orderline):
40+
result = super()._export_for_ui(orderline)
41+
timezone = pytz.timezone(self._context.get("tz") or self.env.user.tz or "UTC")
42+
result["date_order"] = (str(orderline.date_order.astimezone(timezone)),)
43+
return result
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [SerpentCS](https://www.serpentcs.com):
2+
- Parvez Qureshi \<<[email protected]>\>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# POS Order Line Customer History
2+
3+
This module adds a feature in the Point of Sale (POS) interface to allow users to view the sales history of a selected customer and reuse past order lines in new orders.
4+
5+
## Features
6+
7+
- Adds a **"History" button** above the customer details on the POS screen.
8+
- When clicked, opens a new view showing past `pos.order.line` records for the selected customer.
9+
- If no customer is selected, a popup is displayed with the message:
10+
> "You must select a customer first"
11+
12+
### History View
13+
14+
- Displays a list of past order lines for the selected customer.
15+
- Ordered by most recent first.
16+
- Shown fields:
17+
- **Date**
18+
- **Product**
19+
- **Quantity**
20+
- **Discount**
21+
- **Price Unit**
22+
- **Total**
23+
24+
### Functionalities
25+
26+
- **Sortable Data**: Users can sort the list by selecting from a dropdown with the following options:
27+
- Date ASC
28+
- Date DESC
29+
- Product ASC
30+
- Product DESC
31+
- Price Unit ASC
32+
- Price Unit DESC
33+
- Qty ASC
34+
- Qty DESC
35+
- Total ASC
36+
- Total DESC
37+
38+
- **Search Bar**:
39+
- Filter by **product name** or **barcode**
40+
- Filter by **date**
41+
42+
- **Line Selection**:
43+
- Select one or more lines from the list.
44+
- Add selected products and their quantities to the current POS order.
45+
- Note: **Discounts and prices are not copied**, only **product and quantity** are reused.
46+
47+
## Usage
48+
49+
1. Select a customer in the POS interface.
50+
2. Click the "History" button to view their order history.
51+
3. Use the search and sort features to find relevant products.
52+
4. Select lines and add them to the current order as needed.
53+
54+
## Technical Information
55+
56+
- Compatible with Odoo 17.0
57+
- Developed following OCA module standards.

0 commit comments

Comments
 (0)