-
-
Notifications
You must be signed in to change notification settings - Fork 670
[17.0][ADD] pos_order_line_customer_history #1369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
parvezqureshi
wants to merge
1
commit into
OCA:17.0
Choose a base branch
from
parvezqureshi:17.0-add-pos_order_line_customer_history
base: 17.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "devDependencies": { | ||
| "eslint-plugin-import": "^2.31.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| "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", | ||
| ] | ||
| }, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import pos_order |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [build-system] | ||
| requires = ["whool"] | ||
| build-backend = "whool.buildapi" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - [SerpentCS](https://www.serpentcs.com): | ||
| - Parvez Qureshi \<<[email protected]>\> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.