Commit Graph

3136 Commits

Author SHA1 Message Date
Florian Mortgat
e8cb259d05 NEW hook allowing external modules to replace the behavior of fetchObjectLinked() (#34724)
Note: if subclasses overload fetchObjectLinked, adding the same hook should be considered as well if deemed useful.
2025-08-02 00:21:53 +02:00
ldestailleur
6339eaf879 Fix date variables must be in UTC in memory. 2025-07-18 02:57:49 +02:00
VIAL-GOUTEYRON Quentin
7f9b477401 Fix(core): Ensure tms field is always updated in updateCommon (#34723)
* fix(commonobject): ensure `tms` field is updated with current timestamp

- Added logic to automatically update the `tms` field with the current timestamp when it exists in `$fieldvalues`.
- Aligns `tms` behavior with other timestamp fields like `date_modification`.

Improves consistency in timestamp handling across the codebase.

* fix(commonobject): set timezone for `dol_now()` call

- Updated `dol_now()` to use the user's timezone (`tz_user`).
- Ensures timestamps are consistent with user-specific settings.

* fix(commonobject): correct parameter for `dol_now()` function

- Updated `dol_now()` to use 'tzuser' instead of 'tz_user'.
- Fixes incorrect parameter causing potential timezone inconsistencies.

* fix(commonobject): respect `MAIN_DISABLE_AUTO_UPDATE_OF_TMS_FIELDS` setting

- Added a check for `MAIN_DISABLE_AUTO_UPDATE_OF_TMS_FIELDS` in the logic updating the `tms` field.
- Ensures the `tms` field is not auto-updated when this global setting is enabled.
- Retains the update behavior for `date_modification` and `fk_user_modif` fields.

Improves flexibility by honoring user-defined global settings for timestamp management.

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-07-18 02:54:07 +02:00
Laurent Destailleur
6b68f5aad0 Fix CI 2025-07-05 11:33:46 +02:00
ldestailleur
358daa3ca0 Clean doc and code 2025-06-27 13:39:50 +02:00
ldestailleur
497d774a21 Fix the selectForFormsList was not using correctly the
ismultientitymanaged. Replace a join with and exists.
2025-06-27 00:21:50 +02:00
Alexandre Janniaux
efd95ad107 Qual commonobject: line_max: factor conditonals together (#34600)
* commonobject: line_max: factor conditonals together

The SQL request is shared, except for the additional filter.

* Update commonobject.class.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-06-23 18:28:13 +02:00
ldestailleur
cf8beb8505 Fix error return 2025-06-21 14:39:53 +02:00
Alexandre Janniaux
1a3430f40a commonobject: updateLineDown: use early return on query failure (#34598)
Simplify the code by early returning on query failure, which removes
almost every indentation level of the function.

It also highlights some important flaws here, since there is a return
without value (void return type) between the two queries if an error
happened, which would indicate the first query failed and nothing was
registered, but also an error check leading to printing an error message
if the second query fails, without actually reverting the first one, and
since there is no error code, there's no way to trigger a db->rollback()
from the caller code for this reason.
2025-06-21 14:36:07 +02:00
Alexandre Janniaux
1113ae6dc1 Qual: Commonobject reverse happy path (#34599)
* commonobject: getRangOfLine: reverse happy and error path

* commonobject: getIdOfLine: reverse error and happy path
2025-06-21 14:35:01 +02:00
ldestailleur
9c2da8b9b6 Merge branch '21.0' of git@github.com:Dolibarr/dolibarr.git into develop 2025-06-19 11:31:44 +02:00
ldestailleur
a78e63dbf0 Merge branch '20.0' of git@github.com:Dolibarr/dolibarr.git into 21.0 2025-06-19 11:13:59 +02:00
ldestailleur
ec098b2632 Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into 20.0 2025-06-19 10:59:07 +02:00
ldestailleur
0da1e6b464 Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into 19.0 2025-06-19 10:48:18 +02:00
ldestailleur
247847cd14 Fix warnings 2025-06-19 10:39:19 +02:00
Alexandre Janniaux
0770e79749 commonobject: updateLineUp: use early return on query failure (#34570)
Simplify the code by early returning on query failure, which removes
almost every indentation level of the function.

It also highlights some important flaws here, since there is a return
without value (void return type) between the two queries if an error
happened, which would indicate the first query failed and nothing was
registered, but also an error check leading to printing an error message
if the second query fails, without actually reverting the first one, and
since there is no error code, there's no way to trigger a db->rollback()
from the caller code for this reason.
2025-06-19 10:12:55 +02:00
Alexandre Janniaux
1da9aab8d4 commonobject: updateRangOfLine: de-indent happy path (#34569)
There's no need for the else{} block when the if block early returns,
and it helps highlighting the happy path. Note that this kind of change
only make sense when one of the block is an error, not a choice between
two possibilities.
2025-06-19 10:11:12 +02:00
Alexandre Janniaux
f04a390cb5 commonobject: getChildrenOfLine: early return on query error (#34547)
This makes the code more readable by deindenting two whole levels on the
happy path.
2025-06-18 14:19:37 +02:00
Marc de Lima Lucio
467c772504 FIX: common fields: php warning with select input field (#34495) 2025-06-14 11:58:25 +02:00
Laurent Destailleur
b1812b1080 Debug v22 2025-06-10 02:24:08 +02:00
Laurent Destailleur
221c27c091 Merge branch '21.0' of git@github.com:Dolibarr/dolibarr.git into develop 2025-06-09 18:15:59 +02:00
Laurent Destailleur
326c75dc51 Merge branch '20.0' of git@github.com:Dolibarr/dolibarr.git into 21.0 2025-06-09 17:58:54 +02:00
kkhelifa-opendsi
115a430652 FIX: Fix delete ecm file into database when delete a contract (#34310) 2025-06-04 14:31:23 +02:00
Günter Lukas
eaf0ec2e30 Fix #34346 - SQL Error (#34347)
* Fix #34346 - SQL Error

* Update commonobject.class.php
2025-06-03 17:05:10 +02:00
Laurent Destailleur
c35965030c Debug v22 2025-05-28 01:16:02 +02:00
Laurent Destailleur
1b3b123472 Debug v22 2025-05-28 00:09:02 +02:00
Quentin-Seekness
024f266089 Allow insertion of value equals to 0 with int type (#34294)
The issue is that right now we can't insert a value of 0 as an int extrafields (unless the filed is mandatory, wich is not always the case)
2025-05-27 18:55:28 +02:00
Laurent Destailleur
393537d1e4 FIX portal module, prepare to replace duplication of code 2025-05-27 18:47:19 +02:00
ldestailleur
62e305f7fa Debug the asset module. Can't delete. 2025-05-10 21:03:27 +02:00
ldestailleur
f0eaae6a1d Debug v22 2025-05-05 17:09:24 +02:00
ldestailleur
e4e5b1e597 Clean code 2025-05-05 02:22:02 +02:00
Florian Mortgat
9d0d8f7ec5 Fix/140/t250062/extrafields multicompany data loss (#34022)
* insertExtrafields(): simplify by returning 0 early if array_options is empty

* insertExtrafields(): simplify by using local variables $newValue and $attributeType

* insertExtrafields(): refactor by grouping the empty value cases for geodatabase-type extrafields

* insertExtrafields(): refactor by using a static mapping of geodata types to their ST_* db function on ExtraField class

* FIX: when an object that is shared across multiple entities already has some extrafields from another entity that are not reachable from the current entity, their values are lost

* Compliance with
- phan ( Closure Closure($key) has no declared or inferred parameter type for $key)
- php-stan (Error: Property ExtraFields::$geoDataTypes has no type specified)
2025-05-04 18:42:01 +02:00
ldestailleur
2aa17f9c3f Fix update of foregin rate on recurring invoices 2025-04-25 03:39:04 +02:00
ThomasNgr-OpenDSI
a56a8e05f0 FIX : set default extrafield value for supplier order (#33971)
* fill extrafields default values in case THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_SUPPLIER_ORDER applies

* Fix: send param changecompany when changing company on a supplier order creation
2025-04-24 19:19:39 +02:00
ThomasNgr-OpenDSI
730667ed5a NEW : force Extrafields values when constants THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_(ORDER|INVOICE) are set (#33954)
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-04-24 15:46:56 +02:00
Laurent Destailleur
e034b4b0ef Standardize code 2025-04-24 00:51:47 +02:00
ldestailleur
4d80dc9d69 Debug v22 2025-04-12 16:18:40 +02:00
ldestailleur
6da74b90ce Debug v22 2025-04-10 21:25:45 +02:00
ldestailleur
50b6281041 FIX #33353 2025-04-10 21:20:37 +02:00
ldestailleur
ee0c465421 Doc 2025-04-10 16:27:44 +02:00
Frédéric FRANCE
ac3364138d fix sql (#33754)
if ref or ref_ext doen't exists in object (by example ref with llx_societe) sql will fails

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-04-07 16:37:08 +02:00
ThomasNgr-OpenDSI
b431b1bc90 FIX sales representatives can affect contacts from thirdparties they are not allowed to see (#33353)
* introduce method User::getAffectedThirdparties()

* Forbid to display thirdparties on contact tab is user has no right to see them

* add control in add_contacts

* fix precommit

* fix phan, phpstan

* fix travis + fix using wrong table

* Forbid to display thirdparties on contact tab is user has no right to see them (more secure way)

* try to fix TRAVIS

* more efficient way to check user is allowed to ad a socpeople

* remove dead code
2025-04-06 19:51:30 +02:00
ldestailleur
ef95c311a7 Merge branch '21.0' of git@github.com:Dolibarr/dolibarr.git into develop 2025-04-03 21:09:46 +02:00
VIAL-GOUTEYRON Quentin
3ad05c2dde FIX: Incorrect entity used when downloading a document generated in another entity (#33565)
* FIX : Wrong entity to download document

* MODIFICATION : Remplacement de l'ID d'entité par l'objet dans les fonctions de gestion des fichiers pour une meilleure cohérence.

* Update files.lib.php

* Update files.lib.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-04-01 23:13:31 +02:00
Etienne BENDER
d73df8d931 Add hook printObjectLinesList in CommonObject::printObjectLines() (#33641)
* Add hook printObjectLinesList in CommonObject::printObjectLines()

* Update commonobject.class.php

* Update commonobject.class.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2025-04-01 22:24:35 +02:00
ldestailleur
ffa7413cda Clean code 2025-04-01 22:14:56 +02:00
Frédéric FRANCE
387e3b1da7 shipping can manage its contacts (#33680)
* shipping can manage its contacts

* shipping can manage its contacts

* fix

* add contacts from origin

* clean code

* apply changes

* apply changes
2025-04-01 20:47:40 +02:00
ldestailleur
1325b249b0 Clean code to fix some phan warnings 2025-04-01 09:36:36 +02:00
ldestailleur
ca1afd6535 Clean code 2025-03-31 12:39:19 +02:00
ldestailleur
ae59c409f6 Modulebuilderization 2025-03-26 00:56:24 +01:00