-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[ADD] last_purchased_products: sort selection by recent customer history #1083
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
base: 19.0
Are you sure you want to change the base?
Conversation
67e219c to
3a32fc9
Compare
6ae505d to
857830b
Compare
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.
Hello,
I think that your module will not install.
Can you please check if it is working fine or not?
Thanks
| "views/product_views.xml" | ||
| ], | ||
| "assets": { | ||
| 'web.assets_backend': [ |
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.
Please follow the same quote through the module.
857830b to
28c1e01
Compare
Before, the product selection dropdown did not display the time of the previous order and products were not sorted based on how recently they were invoiced for the selected customer. Additionally, the last invoice time and specific quantity calculations were missing from the catalog view. This module enhances the product selection mechanism to assist users in identifying frequently purchased items. Specific improvements include: - Displaying the `last_order` time next to the product name in the dropdown. - Sorting products by `last_invoice_date` specific to the selected customer (partner). - Showing `final_qty` and `last_invoice_time` in the product catalog kanban view. If no customer is selected in the context, the standard selection behavior and sorting apply. Technical Details: - Model `product.product`: Added `last_order` Datetime field, `last_invoice_date` Datetime Field, `last_invoice_time` field. - Model `product.template`: Added `last_order` Datetime field, `last_invoice_date` Datetime Field. - Method `name_search`: Overridden to order products as `last_invoice_date`. - Method `_compute_display_name`: Overridden to show `last_order` as to string time at right side of product name in selection dropdown. - Method `_compute_last_order`: to compute `last_order` of shown products in selection dropdown in context of selected customer(`partner_id`). - Method `_compute_last_invoice_date`: to compute `last_invoice_date` to order recently invoiced first shown products in selection dropdown in context of selected customer(`partner_id`). - Method `compute_agotime`: to compute given Datetime to string format. - View `sale_order_views`: Updated `product_template_id` and catalog button to pass the selected `partner_id` in the context as `customer`. - View `account_move_views`: Updated `product_id` and catalog button to pass the selected `partner_id` in the context as `customer`. - View `purchase_order_views`: Updated `product_id` to pass the selected `partner_id` in the context as `vendor`. - View `product_views`: Updated `product_view_kanban_catalog` to display `final_qty` (`virtual_available` - `qty_available`) next to `On Hand` and `last_invoice_time` after `qty_available` in `product_view_kanban_catalog`. - Template `order_line`: Updated to show `uomDisplayName` next to `price`.
…ting logic
This commit introduces the `TestLastOrderProduct` test suite to ensure the
stability of product sorting and time computation based on sales and
purchase history.
Key scenarios covered:
Last Order Computation:
- Verifies that confirming a Sale Order updates the `last_order` field.
- Checks that the 'Ago' time suffix (e.g., '--1h--') is correctly
appended to `display_name` when the context is active.
Last Invoice Date:
- Verifies that posting a Customer Invoice updates `last_invoice_date`.
- Ensures valid date comparisons between fields.
Vendor Bill Sorting:
- Verifies that posting a Vendor Bill updates `last_invoice_date`
when in a vendor context.
- Ensures products from recent bills appear at the top of search results.
Name Search Sorting:
- Verifies that recently invoiced products appear at the top of the
list in the `name_search` results.
- Confirms that sorting falls back to the default (alphabetical)
when no customer/vendor context is provided.
Time Display Logic:
- Validates `last_invoice_time` computation.
- Specifically verifies that invoices created less than a minute ago
return 'Just Now'.
Context Handling:
- Ensures logic only triggers when `customer`, `vendor`, or
`formatted_display_name` keys are present in the context, preventing
unwanted side effects in standard views.
Before, there was no customer name next to last invoice time, it was hard to identify that to which customer this product was recently invoiced. this commit add that functionality which will add customer name to whom then recent invoice created and that name is clickable will take to that invoice form. Technical Details: - Model `product.product`: Created `invoice_partner_name` Char field to store customer name. - Model `product.product`: Created action `action_open_last_invoice` to open last invoice of product. - View `product_views`: Updated to show customer name next to `last_invoice_time`.
28c1e01 to
794ea6d
Compare

Before, the product selection dropdown did not display the
time of the previous order and products were not sorted based on how
recently they were invoiced for the selected customer. Additionally,
the last invoice time and specific quantity calculations were missing
from the catalog view.
This module enhances the product selection mechanism to assist users in
identifying frequently purchased items. Specific improvements include:
last_ordertime next to the product name in thedropdown.
last_invoice_datespecific to the selectedcustomer (partner).
final_qtyandlast_invoice_timein the productcatalog kanban view.
invoice_partner_namenext tolast_invoice_time,which is clickable and open last invoice of that property.
If no customer is selected in the context, the standard selection
behavior and sorting apply.
Technical Details:
Model
product.product: Addedlast_orderDatetime field,last_invoice_dateDatetime Field,last_invoice_timeChar field,invoice_partner_nameChar field.Model
product.template: Addedlast_orderDatetime field,last_invoice_dateDatetime Field.Method
action_open_last_invoice: To open last invoice of product.Method
name_search: Overridden to order products aslast_invoice_date.Method
_compute_display_name: Overridden to showlast_orderas to stringtime at right side of product name in selection dropdown.
Method
_compute_last_order: to computelast_orderof shown products inselection dropdown in context of selected customer(
partner_id).Method
_compute_last_invoice_date: to computelast_invoice_dateto orderrecently invoiced first shown products in selection dropdown in context of
selected customer(
partner_id).Method
compute_agotime: to compute given Datetime to string format.View
sale_order_views: Updatedproduct_template_idand catalog buttonto pass the selected
partner_idin the context ascustomer.View
account_move_views: Updatedproduct_idand catalog buttonto pass the selected
partner_idin the context ascustomer.View
purchase_order_views: Updatedproduct_idto pass the selectedpartner_idin the context asvendor.View
product_views: Updatedproduct_view_kanban_catalogto displayfinal_qty(virtual_available-qty_available) next toOn Handandlast_invoice_timeafterqty_availableinproduct_view_kanban_catalog.Template
order_line: Updated to showuomDisplayNamenext toprice.