Adding Field to Projects Overview

Based on my conversation in previous thread Serial numbers in MO and other issues with Order/Manufacturing flow - #5 by IAmTheRealBeef I want to use the Advanced Stock Transfer module to transfer stock, but I have no visibility of these transfers in the Projects Overview tab.

I would like to add one field to the Projects Overview “List of Stock Transfers related to the project”.

  1. Since the Advanced Stock Transfer module already can associate transfers with a project, I don’t think I need to create or add a new table or database, only to add a section to the php file, is this correct?

  2. I assume I must add another array similar to the code as for re-arranging the elements (Project -> Overview -> Element), only to use the correct terminology from the Advanced Stock Transfer. I assume I can find this either searching through the wiki or github, or by downloading and looking at my database in some SQL viewer

  3. Since I am changing a built-in module, I should probably make a backup of it so that new versions don’t overwrite it?

Thanks :slight_smile:

Hmm, it appears that it already exists, just its not functioning properly

There’s a check for stocks module (in htdocs/projet/element.php)

if (isModEnabled(‘stock’)) {
require_once DOL_DOCUMENT_ROOT.‘/product/stock/class/entrepot.class.php’;
require_once DOL_DOCUMENT_ROOT.‘/product/stock/class/mouvementstock.class.php’;
}

And the list of stock movements associated with a project …

'stock_mouvement'=>array(
	'name'=>"MouvementStockAssociated",
	'title'=>"ListMouvementStockProject",
	'class'=>'MouvementStock',
	'table'=>'stock_mouvement',
	'datefieldname'=>'datem',
	'margin'=>'minus',
	'disableamount'=>0,
	'test'=>isModEnabled('stock') && $user->hasRight('stock', 'mouvement', 'lire') && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)
),

I opened an issue on Github and will try to resolve it, unless there’s something I’m missing here. [BUG] Stock Movement associated with project doesn't show up in Project / Overview window · Issue #26033 · Dolibarr/dolibarr · GitHub

So I’ve got a tentative fix in a pull request up on Github for this, and it properly links the stock movement (and Third Party, if applicable). I would like to adjust the fields displayed to properly reflect what’s important, but it appears that every item in the Project Overview suffers from this, so that’s a larger project for down-the-road.

2 Likes

@DG-Rilling

Since you are likely interested in viewing the advanced stock transfers from projects (as you mentioned to me) - you can either manually make the changes from the commit or it’ll possibly be in the next update.

If you do either method, you will still need to set the global config in Other Setup until there’s some more testing and I will in the future try to add the option into the Projects module settings once any possible bugs have been squashed.

Thanks for your solution. I am also trying to get that feature working. I have several instances I am playing around with.
Version 17.0.3. is working as expected
Version 18.0.1 gives me an HTTP ERROR 500 In /product/stock/stocktransfer/stocktransfer_card.php?id=7` as soon as I click on ADD (Hinzufügen)


Version 18.0.2 is the same as 18.0.1 and I have also created an issue on Github: Advanced Stock Transfer: Adding a line causes an HTTP ERROR 500 · Issue #26194 · Dolibarr/dolibarr · GitHub

I have seen that you are also on 18.0.1, so it is probably working. Do you have an idea what could be the issue? Maybe I am missing something, and you can give me a hint into the right direction.

Thanks

I think this is an issue with your particular install for some reason - or you don’t have some kind of module enabled perhaps? I have only had issues with trying to delete an advanced stock transfer as there’s something wrong in the SQL query there, but creating one works properly on my end.

I had to manually delete the entries from the SQL database after I was experimenting but eventually I’d like to fix this bug as well

Thanks for your answer! Can you tell me what you are using for your installation? I am using a fresh installation on an Ubuntu System 22.04.3 LTS. Before that, I was using Docker.

Can you confirm that it works for you with the current version 18.0.3?

Hello,

Error 500 means PHP Error => What does the Apache logs says about it ?

Hello, I have just created a brand-new installation of 18.0.3 on Ubuntu with this image Download dolibarr_18.0.3-4_all.deb (Dolibarr ERP - CRM)

Initially, I have set company name and country.
Then, I have created two warehouses and some products (also corrected the stock and added a stock value)

Here is the error log of the Apache after I hit “ADD”

[Wed Nov 15 10:31:26.782922 2023] [php:error] [pid 682] [client xxxxxx:50458] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /usr/share/dolibarr/htdocs/product/stock/stocktransfer/stocktransfer_card.php:198\nStack trace:\n#0 {main}\n thrown in /usr/share/dolibarr/htdocs/product/stock/stocktransfer/stocktransfer_card.php on line 198, referer: http://xxxxxxxxx/dolibarr/product/stock/stocktransfer/stocktransfer_card.php?id=1

I actually ended up doing a local install of Dolibarr today, as we previously had it on a remote server but want it locally … I set up Dolibarr and backed up / restored my existing database into this local version and now I am running into the same issue.

[Mon Nov 20 14:17:44.862045 2023] [php:warn] [pid 232549] [client 192.168.1.111:56902] PHP Warning: Undefined array key “arrayofkeyval” in /var/www/html/dolibarr/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php on line 150, referer: http://192.168.1.111/dolibarr/htdocs/product/stock/stocktransfer/stocktransfer_card.php?id=233&save_lastsearch_values=1

[Mon Nov 20 14:17:44.862531 2023] [php:error] [pid 232549] [client 192.168.1.111:56902] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/html/dolibarr/htdocs/product/stock/stocktransfer/stocktransfer_card.php:198\nStack trace:\n#0 {main}\n thrown in /var/www/html/dolibarr/htdocs/product/stock/stocktransfer/stocktransfer_card.php on line 198, referer: http://192.168.1.111/dolibarr/htdocs/product/stock/stocktransfer/stocktransfer_card.php?id=233&save_lastsearch_values=1

I think I’ve fixed it, you can see the changes in pull request and/or manually add them to your install since its just two lines @Ramon

2 Likes

:heart_eyes: Great! Thanks - I will try it later and let you know the result.