ATM-Consulting / dolibarr_module_workstation

Gestion des postes de travail pour scrumboard et GPAO à terme
2 stars 12 forks source link

SQL error on validation of factory order when workstation with type not "STT" is added #37

Open splohmer opened 1 year ago

splohmer commented 1 year ago

Description In case an workstation (where the type is not "STT") is added to an factory order and order is validated, then an SQL error var_dump is shown: Unknown column 'aex.fk_workstation' in 'where clause'.

Affected versions:

Steps to reproduce

Current behaviour var_dump of sql error is shown

Expected behaviour factory order is validated, no errors are shown

Additional information

Currently I am not sure how to fix it as I cannot get the intention of the sql ammendment for the capacity planning. Therefore I cannot provide an pull request. Therefore I hope this can be fixed from your side.

splohmer commented 1 year ago

Description Dans le cas où un poste de travail (dont le type n'est pas "STT") est ajouté à une commande d'usine et que la commande est validée, une erreur SQL var_dump est affichée : Unknown column 'aex.fk_workstation' in 'where clause'.

Versions affectées :

Étapes à suivre pour reproduire le problème

Comportement actuel var_dump de l'erreur sql est affiché

Comportement attendu l'ordre d'usine est validé, aucune erreur n'est affichée

Informations complémentaires

Actuellement, je ne sais pas comment le résoudre car je ne peux pas obtenir l'intention de l'amendement sql pour la planification de la capacité. Par conséquent, je ne peux pas fournir une demande d'extraction. Par conséquent, j'espère que cela peut être corrigé de votre côté.

splohmer commented 1 year ago

Hi,

I checked it again and it looks like I oversaw the comment in the code: needed_ressource is created by gantt module. Currently I see 2 solutions depending if the workstation module is intended to be used also without gantt module or not:

  1. If the module should be usable without gantt module: The extrafield could be added also to the workflow module. The activated module which is first creates it. In case it is already created, then the addExtraField function will return "not ok", but the result is not used in the gantt module.
  2. If the module should be usable only with gantt module: In this case I think it should be defined as dependency in the module description. Then it will be automatically activated if the workstation module is activated.

Personally I prefer the first solution as it keeps the modules independently. I will create a pull request for that. Let me know if you prefer the other solution.

splohmer commented 1 year ago

Pull request created: https://github.com/ATM-Consulting/dolibarr_module_workstation/pull/38

atm-florianm commented 1 year ago

As answered on your PR (I summarize it here to make it easier for other contributors to follow), I think more detail is required to reproduce the bug and to fix it appropriately: currently, workstationatm is designed to work with or without Gantt (which we don't sell or recommend anymore). The SQL query in your report is run within an if block causing it to be executed only if Gantt is enabled, which is why we couldn't reproduce the problem. I think the error might stem from Gantt not being completely disabled as far as the database goes. If the issue reoccurs, we will improve our response time to ensure we get all the details needed to troubleshoot / fix it.

splohmer commented 1 year ago

Hi @atm-florianm, sorry to contradict here, but the if statement is executed only if gantt is disabled. See code line from the PR: if(empty($conf->gantt->enabled)) This checks if the variable is empty and this is the case if the module is disabled.

atm-florianm commented 1 year ago

@splohmer There is a misunderstanding here: I was not referring to the line from the PR but to this line in the Workstation class, which conditions the execution of the SQL query. The query that caused the error from your issue runs only if Gantt is enabled.