Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,824 changes: 2,824 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"eslint-plugin-import": "^2.31.0"
}
}
163 changes: 163 additions & 0 deletions pos_order_line_customer_history/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
================================
Point of Sale - Customer history
================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1ec25ac0bb1183de1b159c820384c4b101047a7d75c087363f42622366d5ae4f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github
:target: https://github.com/OCA/pos/tree/17.0/pos_order_line_customer_history
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_order_line_customer_history
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

POS Order Line Customer History
===============================

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.

Features
--------

- Adds a **"History" button** above the customer details on the POS
screen.
- When clicked, opens a new view showing past ``pos.order.line`` records
for the selected customer.
- If no customer is selected, a popup is displayed with the message:
"You must select a customer first"

History View
~~~~~~~~~~~~

- Displays a list of past order lines for the selected customer.
- Ordered by most recent first.
- Shown fields:

- **Date**
- **Product**
- **Quantity**
- **Discount**
- **Price Unit**
- **Total**

Functionalities
~~~~~~~~~~~~~~~

- **Sortable Data**: Users can sort the list by selecting from a
dropdown with the following options:

- Date ASC
- Date DESC
- Product ASC
- Product DESC
- Price Unit ASC
- Price Unit DESC
- Qty ASC
- Qty DESC
- Total ASC
- Total DESC

- **Search Bar**:

- Filter by **product name** or **barcode**
- Filter by **date**

- **Line Selection**:

- Select one or more lines from the list.
- Add selected products and their quantities to the current POS order.
- Note: **Discounts and prices are not copied**, only **product and
quantity** are reused.

Usage
-----

1. Select a customer in the POS interface.
2. Click the "History" button to view their order history.
3. Use the search and sort features to find relevant products.
4. Select lines and add them to the current order as needed.

Technical Information
---------------------

- Compatible with Odoo 17.0
- Developed following OCA module standards.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`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**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Serpent Consulting Services Pvt. Ltd.

Contributors
------------

- `SerpentCS <https://www.serpentcs.com>`__:

- Parvez Qureshi <[email protected]>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-Serpent Consulting Services Pvt. Ltd.| image:: https://github.com/Serpent Consulting Services Pvt. Ltd..png?size=40px
:target: https://github.com/Serpent Consulting Services Pvt. Ltd.
:alt: Serpent Consulting Services Pvt. Ltd.

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-Serpent Consulting Services Pvt. Ltd.|

This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/17.0/pos_order_line_customer_history>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions pos_order_line_customer_history/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
24 changes: 24 additions & 0 deletions pos_order_line_customer_history/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Point of Sale - Customer history",
"summary": "Adds product in the customer history screen of POS",
"version": "17.0.1.0.0",
"category": "Point of sale",
"website": "https://github.com/OCA/pos",
"author": "Serpent Consulting Services Pvt. Ltd., Odoo Community Association (OCA)",
"maintainers": ["Serpent Consulting Services Pvt. Ltd."],
"license": "AGPL-3",
"installable": True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"installable": True,
"installable": True,
"development_status": "alpha",

"development_status": "Alpha",
"depends": ["point_of_sale"],
"assets": {
"point_of_sale._assets_pos": [
"pos_order_line_customer_history/static/src/Buttons/customer_history.xml",
"pos_order_line_customer_history/static/src/Screens/CustomerHistoryScreen.xml",
"pos_order_line_customer_history/static/src/Screens/CustomerHistoryScreen.scss",
"pos_order_line_customer_history/static/src/Screens/CustomerHistoryScreen.esm.js",
"pos_order_line_customer_history/static/src/Buttons/customer_history.esm.js",
"pos_order_line_customer_history/static/src/models/pos_store.esm.js",
"pos_order_line_customer_history/static/src/navbar/back_button.esm.js",
]
},
}
1 change: 1 addition & 0 deletions pos_order_line_customer_history/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import pos_order
43 changes: 43 additions & 0 deletions pos_order_line_customer_history/models/pos_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from collections import defaultdict
from datetime import datetime

import pytz

from odoo import api, fields, models
from odoo.osv.expression import AND


class PosOrder(models.Model):
_inherit = "pos.order"

@api.model
def search_paid_orderline_ids(self, config_id, domain, limit, offset, orderby="id"):
default_domain = [
("order_id.state", "!=", "draft"),
("order_id.state", "!=", "cancel"),
]
real_domain = AND([domain, default_domain])
orderlines = self.env["pos.order.line"].search(
real_domain, limit=limit, offset=offset, order=orderby
)
orderLines_info = defaultdict(lambda: datetime.min)
for orderline in orderlines:
if orderLines_info[orderline.id] < orderline.write_date:
orderLines_info[orderline.id] = orderline.write_date
totalCount = self.env["pos.order.line"].search_count(real_domain)
return {
"orderLinesInfo": list(orderLines_info.items()),
"totalCount": totalCount,
}


class PosOrderLine(models.Model):
_inherit = "pos.order.line"

date_order = fields.Datetime(related="order_id.date_order", store=True)

def _export_for_ui(self, orderline):
result = super()._export_for_ui(orderline)
timezone = pytz.timezone(self._context.get("tz") or self.env.user.tz or "UTC")
result["date_order"] = (str(orderline.date_order.astimezone(timezone)),)
return result
3 changes: 3 additions & 0 deletions pos_order_line_customer_history/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions pos_order_line_customer_history/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [SerpentCS](https://www.serpentcs.com):
- Parvez Qureshi \<<[email protected]>\>
57 changes: 57 additions & 0 deletions pos_order_line_customer_history/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# POS Order Line Customer History

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.

## Features

- Adds a **"History" button** above the customer details on the POS screen.
- When clicked, opens a new view showing past `pos.order.line` records for the selected customer.
- If no customer is selected, a popup is displayed with the message:
> "You must select a customer first"

### History View

- Displays a list of past order lines for the selected customer.
- Ordered by most recent first.
- Shown fields:
- **Date**
- **Product**
- **Quantity**
- **Discount**
- **Price Unit**
- **Total**

### Functionalities

- **Sortable Data**: Users can sort the list by selecting from a dropdown with the following options:
- Date ASC
- Date DESC
- Product ASC
- Product DESC
- Price Unit ASC
- Price Unit DESC
- Qty ASC
- Qty DESC
- Total ASC
- Total DESC

- **Search Bar**:
- Filter by **product name** or **barcode**
- Filter by **date**

- **Line Selection**:
- Select one or more lines from the list.
- Add selected products and their quantities to the current POS order.
- Note: **Discounts and prices are not copied**, only **product and quantity** are reused.

## Usage

1. Select a customer in the POS interface.
2. Click the "History" button to view their order history.
3. Use the search and sort features to find relevant products.
4. Select lines and add them to the current order as needed.

## Technical Information

- Compatible with Odoo 17.0
- Developed following OCA module standards.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading