odoo/tutorials#1083

Created by Darshil Naliyapara (danal)

Blocked

label
odoo-dev:19.0-last_purchased_products-danal
head
c91f7fba1279484ddc02bf9dd72081eeba99963e
odoo/tutorials
19.0 #1083 missing r+
master

[ADD] last_purchased_products: sort selection by recent customer history

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.
- Displaying invoice_partner_name next to last_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: Added last_order Datetime field,
last_invoice_date Datetime Field, last_invoice_time Char field,
invoice_partner_name Char field.
- Model product.template: Added last_order Datetime field,
last_invoice_date Datetime Field.
- Method action_open_last_invoice: To open last invoice of product.
- 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.