Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SERVICE new line on a BOM tiny DB error when not enabled Workstations module [EASY FIX PROPOSED] #31152

Closed
caos30 opened this issue Sep 27, 2024 · 2 comments
Labels
Bug This is a bug (something does not work as expected)

Comments

@caos30
Copy link

caos30 commented Sep 27, 2024

Bug

If you have not enabled STILL the Workstations module, then there is database error when you access to BoM still in draft mode:

imagen

This is because in the /bom/tpl/objectline_create.tpl.php appear this:

print $formproduct->selectWorkstations('', 'idworkstations', 1);

before to check if the module Workstations is enabled. So it could be fixed adding this:

if (isModEnabled('workstation')) {
	$coldisplay++;
	print '<td class="bordertop nobottom nowrap linecolworkstation">';
	print $formproduct->selectWorkstations('', 'idworkstations', 1);
	print '</td>';
}

as it appears on /product/card.php , but if you ask me would be a better solution (to avoid similar error on the future) to modify the function selectWorkstations() to return empty string when the module workstations is not enabled:

public function selectWorkstations($selected = '', $htmlname = 'idworkstations', ...)
{
	global $conf, $langs, $user, $hookmanager;

	if (!isModEnabled('workstation')) return ''; // <------ my proposed solution to avoid this error in the future
...
}

Note: this function is defined on /product/class/html.formproduct.class.php.

Dolibarr Version

19, 20

Environment PHP

No response

Environment Database

No response

Steps to reproduce the behavior and expected behavior

  1. create a BoM draft, without having enabled the module Workstations

Note: if you have enabled ONCE the module Workstations, then the table workstatiosn_workstations has been created and then you will not get the error. So, this error only happens when you have not enabled never this module.

Attached files

No response

@caos30 caos30 added the Bug This is a bug (something does not work as expected) label Sep 27, 2024
@caos30
Copy link
Author

caos30 commented Sep 27, 2024

Please, @eldy check it. I'm sure that you will find obvious to apply any of my both fixes... it's only a reasonable IF check. Thanks!

@sonikf
Copy link
Contributor

sonikf commented Sep 27, 2024

Ηι @caos30
Why don't you make a pull request?

eldy added a commit that referenced this issue Sep 27, 2024
@eldy eldy closed this as completed Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug (something does not work as expected)
Projects
None yet
Development

No branches or pull requests

3 participants