Purchase Module Customization

Enhances procurement with multi-level approvals, vendor/product intelligence , and operational tools (line copying, pending quantities). Features employee accountability tracking, cancellation reasons, and visual product IDs. Includes comprehensive reporting and audit trails. Streamlines purchasing while improving compliance and decision-making.

Skills You'll Gain:
Odoo Module Development Workflow Automation Custom Model Design Security Rules UI/UX Customization
17 Tasks

Project Tasks

1. Set Up Module Structure

Before implementing any functionality, we need to create the basic structure of our customized module.

Implementation Steps:
  1. Create a new module named Purchase Customization
  2. Set up the basic module structure with __init__.py, __manifest__.py
  3. Create models directory with models name.
  4. Create views directory with views name.

2. Define Manifest File

You need to provide basic description of the module, assert authorship, and choose a distribution license.

Implementation Steps:
  1. Define dictionary with the following info:
    • Module name is Purchase Customization.
    • With meaningful summary.
    • Write your name as author name.
    • Define module version.
    • Choose the appropriate License
    • Declare that the module is featured as an app in the apps list.
    • Declare that the module is available for installation.

3. Add an icon

Adding icon to represent the app.

Implementation Steps:
  1. Add icon to your app.

4.Add Salesperson Field to Purchase Orders.

The customer needs to track which salesperson is responsible for each purchase order.

Implementation Steps:
  1. Extend purchase.order model to add Saleperson field
    • Saleperson: This relational field links to res.users model.
  2. Modify the purchase order form view to display the field:
    • Place the field next to the Vendor field for better visibility

5. Implement High-Level Purchase Order Approval Workflow

The customer needs an enhanced approval workflow for purchase orders that requires management approval for high-value purchases, while maintaining the existing approval process for standard orders.

Implementation Steps:
  1. Extend res.company model to add Secondary Double Validation Amount field:
    • This field is likely used in the purchase order workflow to determine when a secondary approval is necessary based on the total amount of the purchase order
    • This field should be designed to store monetary values
    • Has default value = 10,000
    • With Minimum amount for which a double validation is required help text
  2. Modify the Company form view to display the field:
  3. Extend the module groups and Create 'Purchase Head' security group
  4. In your extended purchase.order model do the following:
    • Extend the purchase order state selection to include 'For Management Approval' status
  5. Modify the approval button button_approve logic to:
    • Check If the total amount of the order is less than a configured Secondary Double Validation Amount field
    • Check If the user belongs to Purchase Head group that allows them to approve any amount
    • If any of the above conditions are met, the order is approved by calling the parent class's button_approve method.
    • If none of the approval conditions are satisfied, the order's state is set to 'for management approval', indicating it requires higher-level authorization
  6. Add a new button labeled Approve Order to the purchase order form with the following specifications
    • This button should only be visible when the status of the purchase order is for management approval
    • The button calls button_approve method.
    • Additionally, only members of the Purchase Head group should be able to click this button.

6. Purchase Order Line Numbering Feature

The customer wants to add visible line numbers to purchase orders to make them easier to reference during discussions with vendors.

Implementation Steps:
  1. Extend purchase.order.line model to add sequence_number field
    • Make it show as "#" in the interface
    • Set it as computed (auto-calculated) and Not editable (numbers should auto-update)
  2. Write a function that runs whenever the order lines change
    • Start counting from 1
    • Go through each line in order:
      • If it's a section header or note: keep same number
      • If it's a regular product line: assign next number
    • Continue until all lines are numbered
  3. Add the new "#" column to Purchase order form view (line items table)

7. Add Line Numbers to Purchase Order PDF Reports

The customer wants to display line numbers on printed purchase orders and quotations to make them easier to reference in printed documents and email communications.

Implementation Steps:
  1. Locate the existing purchase PDF reports (report_purchaseorder_document) and (report_purchasequotation_document) to add a new column to the both reports
  2. Insert a new column header with "#" label , Place it before the description column
  3. Add a new column for the sequence numbers which displays line.sequence_number value

8. Copy Purchase Order Line Functionality

The customer needs the ability to copy purchase order lines within the same purchase order. This feature will help users quickly duplicate line items when creating similar orders or when multiple items share common details.

Implementation Steps:
  1. In your extended purchase.order.line:
    • Add copy method to purchase.order.line this method duplicates the current line.
  2. Enhance order lines view:
    • Add copy button to purchase order line list view this button should call the pre-implemented method
    • Position button after price_subtotal field
    • Use copy icon for intuitive UI
    • Make button visible only when editable

9. Display Last Purchase Price in Purchase Order Lines

The customer needs to see the last purchase price for each product directly in the purchase order line view.

Implementation Steps:
  1. In your extended purchase.order.line:
    • Add computed field last_purchase_price:
    • Display the most recent purchase price for the current product.
  2. Enhance order lines view:
    • Add the field to the purchase order line tree view
    • Make it show as Last Price in the interface
    • Position it after the quantity column
    • Make it read-only
    • Format as monetary value

10. Automatic Default Terms & Conditions in Purchase Orders

The customer wants to automatically populate purchase order terms and conditions based on the selected company. This will ensure consistent legal terms across all purchases while still allowing manual adjustments when needed.

Implementation Steps:
  1. In your extended res.company model add HTML field for default purchase terms:
    • Add translation capability for multilingual companies for this field.
    • Enhance company form view Position the field after the Website field.
  2. In your extended purchase.order model Modify Purchase Order Logic
    • Override onchange_partner_id method
    • Automatically update the purchase order terms to reflect the company’s default terms whenever the company is changed.