Add columns to lines of proposals, customer orders

Hello:

Is there a way to add columns to the lines of proposals, customer orders and invoices? (for developers)

I need to add 2 extra columns (width, height) in the lines of those elements so I can use it for extra information and to calculate the price. Right now I only have the quantity column, but is not enough (sometimes I need 2 products of the same measure) Is there a developer tutorial or something on where and how to add the code?

To give you and idea I add an screenshot.

Any page or idea of how to code that will be appreciated.

2 Likes

Hello,

Yes it is of course possible to do that, I have done it for my own use.
You need to create an aditional module. You can see guide lines there : https://wiki.dolibarr.org/index.php/Module_development

With two parts :
1- A trigger to update the price according to the extrafields. You can have a look on my Volume module that does it with 4 extrafields https://github.com/ksar-ksar/Dolibarr_Volume
2- A hook that recreate the HTML code to put the imput fileds on the same row.

Good luck !

3 Likes

Thanks to @ksar for the help and for the module that provided, it was very useful.

I had to do many things to be able to do what I wanted (Dolibarr version 9.0.3), here are the steps:

  1. Created 3 not visible extrafields in the lines of proposals, customer orders and invoices: length, width and quantity. The reason that I add my own quantity column is because the “qty” property of each object works to calculate the total price but I need the information separated. Example: 2 (my quantity) sheets of paper of 3(length)x1.5(width) mts will give me 9 “qty” in reality.

  1. Created my own module using Module Builder (I really encourage to use it) and change the code that I can overwrite templates (tpl = 1), the hooks are used in the context ‘propalcard’ and ‘globalcard’ and removed the menu code (so it does not appear at the top)

  1. Created the trigger (based in the module that @ksar provided with some extra lines like set $object->special_code = 0 because I don’t use directly the “qty” property of the object, I use my own, and that cause problems displaying values later.

  1. Created a hook for “printObjectLineTitle” because I put the extrafields inside the row of each line (not at the bottom) so I needed to add the columns for my extrafields. I copied the original code, made some changes to add the columns and done with that.

  1. Inside \core\tpl folder of my module I copied 3 files “objectline_create.tpl.php” “objectline_edit.tpl” “objectline_view.tpl.php” that I got from \htdocs\core\tpl folder of Dolibarr. I changed the code so it displays my extrafields (the “qty” field is hidden and given the value=“1” by default to avoid errors in the edit template, the code of the trigger makes the correct calculation later)

[code]

"> "> ">[/code]

These are the results (I keep the qty values between () for clarification:

Finding the exact contexts, functions, templates and the conditions in the templates that does this was a pain in the *** but it worked.

5 Likes

Perfect you did it !

I need exactly the same thing. I need to add some customized lines into proposal and sales orders and I want these lines to affect total price.
So i will try to follow everything in this topic but I might need your helps along the way.

Looking forward for your helps @ksar and @prueba2306
Thank you in advance

I need Exactly the same thing. @ksar and @prueba2306 and @orkut, can you please help me?

Thanks.

Hi. Im new to Dolibarr. how to activate a custom lines in dolibarr when creating a cosutom module. Please help

Hey kSir i need help on implementing something similar Stuck on how to edit the .tpl files

Hi @Eldy please help us with the above issue to make this forum useful