Line Items in a Custom Module

Hi,
how can I reproduce Line Items like in Quotes mdoule in a custom module?
I see in custo/module/Aos_Quotes where is definied the field but i try to make similar in filed of a custom module but i don’t see nothing
I know how customize javascript code but I think I miss one step for visualize in edit view and detail view.

HELP

DONE!!!

Please post it…It could be useful for others

2 Likes

How? :slight_smile:

Please share your solution, thank you so much

All your customize or edit or duplicates in Developer Tools / STUDIO (Customize module fields, layouts and relationships)

Dear SuiteCRM community,

I created the custom module Lieferscheine (delivery notes). The basis is the contract. Workflow: quote -> contract -> delivery notes (Lieferscheine). To create the delivery notes (Lieferscheine) I use createContract.php, in the contract module.
All data are transferred correctly, except the ā€œline itemsā€. These are neither displayed in detailview nor in editview. Only this is shown in editview:

But when a delivery note is printed in a PDF, all datas are displayed, includ the ā€œline itemsā€.

What did I make wrong? What I have to do, so that I can edit the positions in the editview?

Does it have to do with realationship ?:

Can someone help me, please. I would be very happy about it

  1. In a custom module in modules/modulename/vardefs.php file and localization file (/en-us.lang.php) define the fields and relationships (AOS_Products_Quotes and AOS_Line_Item_Groups):
    ā€˜LBL_IMPORT_LINE_ITEMS’
    ā€˜LBL_LINE_ITEMS’
    ā€˜LBL_GRAND_TOTAL’
    ā€˜LBL_TOTAL_AMT’
    ā€˜LBL_TAX_AMOUNT’
    ā€˜LBL_SUBTOTAL_AMOUNT’
    ā€˜LBL_SHIPPING_AMOUNT’
    ā€˜LBL_SHIPPING_TAX_AMT’
    ā€˜LBL_DISCOUNT_AMOUNT’
    ā€˜LBL_ADD_PRODUCT_LINE’
    ā€˜LBL_ADD_SERVICE_LINE’
    ā€˜LBL_REMOVE_PRODUCT_LINE’
    ā€˜LBL_SERVICE_NAME’
    ā€˜LBL_SERVICE_LIST_PRICE’
    ā€˜LBL_SERVICE_PRICE’
    ā€˜LBL_SERVICE_DISCOUNT’
    ā€˜LBL_VAT_AMT’
    ā€˜LBL_TOTAL_PRICE’
    ā€˜LBL_PRODUCT_QUANITY’
    ā€˜LBL_PRODUCT_NAME’
    ā€˜LBL_PART_NUMBER’
    ā€˜LBL_PRODUCT_NOTE’
    ā€˜LBL_PRODUCT_DESCRIPTION’
    ā€˜LBL_LIST_PRICE’
    ā€˜LBL_DISCOUNT_AMT’
    ā€˜LBL_UNIT_PRICE’
    ā€˜LNK_LIST’


My custom module name: acts_company_acts
This fields and relationships copy from AOS Invoices (vardefs.php) (By changing the name of the module to yours ).

  1. Copy from AOS_Invoices.php function ( public function save($check_notify = false)) to you custom module main class (my class ā€œacts_company_acts extends Basicā€)

  2. Copy PANNEL settings edit view, detail view and panel view from AOS_Invoices to (custom/modules/custommodules/metadata/editviewdefs.php, custom/modules/custommodules/metadata/detailviewdefs.php)

  3. Repair and Rebuild (with updating database fields)

Everything should work.

1 Like

Hi @Ankita14, please note that the Line Item section is a custom fuction field

Thankyou but i have found out the solution and now i can get the complete functionality of line items in my custom module

You’re welcome.
If you want you could share it here, it would be a good idea for the Show and Tell - SuiteCRM section

Please share the code, it could be useful for lot of people.

Hi @Ankita14
I am also looking for the same. Would you kindly share

@LionSolution @rainolf @okinyo have you guys found any way to implement customized line items?

Hi @rsp, we’re dealing here of a full custom development.
You can have a custom module with Line Items or you can have custom lines in standard modules like AOS_Quotes or AOS_Invoices.

Which is your scenario?

We want to Add Product line functionality with qty, part number, and description fields in the cases module.
Also, when I download PDF, it should displayed those values.

Yes, it makes sense.
You have to mimic the behavior of AOS_Quotes; please consider two crucial points:

  • The main record is saved before Line Items are saved
  • It isn’t enough to add fields in Line Items; you have to take care of saving and fetching data by yourself in the JS code

To add the Product Line functionality you’re looking for (with quantity, part number, and description fields) to the Cases module in SuiteCRM, there’s not an out-of-the-box solution; you’ll need to create a custom module that holds the cases details and then relate it to the Cases module. Here’s a step-by-step outline to guide you through the process:

1. Create a Custom Module for Product Lines (Cases Details)

  • Module Builder or Studio:
    Use SuiteCRM’s Module Builder (or Studio) to create a new custom module.
  • Add Custom Fields:
    In your new module, add the fields you need:
    • Quantity: (number/integer or decimal field)
    • Part Number: (varchar/string field)
    • Description: (text field)
      These fields will store the details for each product line.

2. Establish a Relationship with the Cases Module

  • Define a One-to-Many Relationship:
    In Studio, open the Cases module and create a new relationship to your custom ā€œCases Detailsā€ module. This establishes that one Case can have multiple product lines.
  • Configure Subpanel:
    Once the relationship is set up, ensure that the ā€œProduct Lines (Cases Details)ā€ subpanel is enabled on the Cases detail view so that users can add and view product line items related to a Case.

3. Adjust Layouts and Views

  • Detail View Customization:
    Customize the Cases detail view layout (using Studio) to display the subpanel for Product Lines (Cases Details).
  • Edit View:
    If you want inline editing or a custom view for adding product line items directly from the Case edit view, further layout adjustments are needed in the JS part. Check how modules/AOS_Products_Quotes/line_items.js and
    modules/AOS_Products_Quotes/Line_Items.php work.

4. Final Steps

  • Quick Repair and Rebuild:
    After making these customizations, run a ā€œQuick Repair and Rebuildā€ to ensure your changes are applied correctly.

Additional Considerations

  • Custom Logic Hooks:
    If you need to perform additional calculations (like summing quantities or updating totals), you might need to implement logic hooks in the Cases or Product Lines (Cases Details) module.
  • User Permissions:
    Ensure that the appropriate roles and permissions are set so that users can access and modify the new module and its relationship with Cases.

Best of Luck!

1 Like