NEW add method confirmProduced in MOs API (#39324)
* FIX commande/stats: do not default "Created by" filter to current user (#39256) The order statistics query is not filtered on the current user on first page load, so the results shown are global. However the "Created by" selector defaulted to the current user (select_dolusers auto-selects $user->id when the passed value is empty), wrongly suggesting the displayed figures were limited to that user. Pass -1 instead of 0 when no user is selected so the combo keeps its empty entry, matching the unfiltered query. The empty option posts -1, which the query turns back into "no user filter", so the round-trip stays consistent after a refresh. * FIX Missing translation for "Weight" * Fix/supplier doc keep project (#39306) * FIX : situation invoice credit note wrong amount in progressive mode When creating a credit note "with same lines" from a situation invoice, the code always subtracts the previous situation invoice's line values before inverting the sign, assuming lines are stored cumulative (INVOICE_USE_SITUATION = 1, legacy mode). In progressive mode (INVOICE_USE_SITUATION = 2), each situation invoice line already stores its own delta amount and percent, so this extra subtraction credits the wrong amount and percent (e.g. 60% / 1272 instead of the correct 20% / 424 on a real cycle). Skip the subtraction in progressive mode so the credit note reuses the source line's own delta values, as expected. * FIX supplier order/proposal loses project after supplier selection On the create form of a supplier order (fourn/commande/card.php) and a supplier price request (supplier_proposal/card.php), the project select was filtered on the supplier third party as soon as one was chosen: the `if ($socid > 0)` branch took precedence over the PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS constant. As a result, a supplier document created from a customer project lost its preselected project when the page reloaded after picking the supplier (the customer project is not linked to the supplier, so it was filtered out). This aligns the behavior with the supplier invoice (fourn/facture/card.php), which gives priority to PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS. The external user restriction now targets $user->socid (the real external-user marker) instead of $socid > 0, which also matched internal users after selecting a supplier. * Fix Standalone reception creation (#39299) Fatal error: Uncaught Error: Call to a member function fetch_optionals() on null * Fix missing include * add method confirmProduced in MOs API which was missing --------- Co-authored-by: atm-corentin <165782689+atm-corentin@users.noreply.github.com> Co-authored-by: Alexandre SPANGARO <alexandre.spangaro@gmail.com> Co-authored-by: Alexandre SPANGARO <aspangaro.dolibarr@gmail.com> Co-authored-by: atm-jonathan <146709163+atm-jonathan@users.noreply.github.com> Co-authored-by: sonikf <93765174+sonikf@users.noreply.github.com> Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
cdc6063405
commit
9e6804de64
7 changed files with 53 additions and 11 deletions
|
|
@ -421,7 +421,10 @@ if (isModEnabled('category')) {
|
|||
// User
|
||||
print '<tr><td>'.$langs->trans("CreatedBy").'</td><td>';
|
||||
print img_picto('', 'user', 'class="pictofixedwidth"');
|
||||
print $form->select_dolusers($userid, 'userid', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
|
||||
// Pass -1 (not 0) when no user is selected so the combo keeps its empty entry instead of defaulting to the
|
||||
// current user. The statistics query below is not filtered on the current user by default, so preselecting
|
||||
// them here wrongly suggests the displayed figures are limited to that user while they are actually global.
|
||||
print $form->select_dolusers(($userid > 0 ? $userid : -1), 'userid', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
|
||||
// Status
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
||||
if ($mode == 'customer') {
|
||||
|
|
|
|||
|
|
@ -1763,6 +1763,7 @@ abstract class CommonDocGenerator
|
|||
|
||||
// Load extrafields if not already done
|
||||
if (is_null($this->extrafieldsCache)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$this->extrafieldsCache = new ExtraFields($this->db);
|
||||
}
|
||||
if (empty($this->extrafieldsCache->attributes[$object->table_element])) {
|
||||
|
|
|
|||
|
|
@ -2077,13 +2077,12 @@ if ($action == 'create') {
|
|||
|
||||
$langs->load('projects');
|
||||
print '<tr><td>'.$langs->trans('Project').'</td><td>';
|
||||
|
||||
if ($socid > 0) { // external user
|
||||
$projSocFilter = $socid;
|
||||
} elseif ((int) $socid == 0 || getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS')) {
|
||||
$projSocFilter = -1;
|
||||
} else {
|
||||
$projSocFilter = $societe->id;
|
||||
$projSocFilter = $socid;
|
||||
}
|
||||
print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects($projSocFilter, $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
|
||||
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?action=create&status=1'.(!empty($societe->id) ? '&socid='.$societe->id : "").'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create'.(!empty($societe->id) ? '&socid='.$societe->id : "")).'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans("AddProject").'"></span></a>';
|
||||
|
|
|
|||
|
|
@ -342,6 +342,44 @@ class Mos extends DolibarrApi
|
|||
return $this->_cleanObjectDatas($this->mo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close=Confirm Produced MO
|
||||
*
|
||||
* @param int $id MO ID
|
||||
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
||||
* @return Object Object with cleaned properties
|
||||
*
|
||||
* @url POST {id}/confirmproduced
|
||||
*
|
||||
* @throws RestException 304
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500 System error
|
||||
*/
|
||||
public function confirmProduced($id, $notrigger = 0)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->hasRight('mrp', 'write')) {
|
||||
throw new RestException(403);
|
||||
}
|
||||
|
||||
$result = $this->mo->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'MO not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('mrp', $this->mo->id, 'mrp_mo')) {
|
||||
throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->mo->setStatut($this->mo::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED');
|
||||
if ($result < 0) {
|
||||
throw new RestException(500, 'Error when setting MO Produced: '.$this->mo->error);
|
||||
}
|
||||
$result = $this->mo->fetch($id);
|
||||
|
||||
return $this->_cleanObjectDatas($this->mo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete MO
|
||||
*
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ if (isModEnabled('category')) {
|
|||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('products', 'stocks', 'suppliers', 'companies', 'margins'));
|
||||
$langs->loadLangs(array('products', 'stocks', 'suppliers', 'companies', 'margins', 'other'));
|
||||
if (isModEnabled('productbatch')) {
|
||||
$langs->load("productbatch");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1305,9 +1305,8 @@ if ($action == 'create' && $permissiontoadd) {
|
|||
// Here $object can be of an object Reception
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
if (empty($reshook) && !empty($extrafields->attributes[$object->table_element]['label'])) {
|
||||
// copy from order
|
||||
if ($objectsrc->fetch_optionals() > 0) {
|
||||
$recept->array_options = array_merge($recept->array_options, $objectsrc->array_options);
|
||||
if ($object->fetch_optionals() > 0) {
|
||||
$recept->array_options = array_merge($recept->array_options, $object->array_options);
|
||||
}
|
||||
print $recept->showOptionals($extrafields, 'create', $parameters);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1669,12 +1669,14 @@ if ($action == 'create') {
|
|||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Project").'</td><td colspan="2">';
|
||||
if ($socid > 0) { // external user
|
||||
$projSocFilter = $socid;
|
||||
} elseif ((int) $soc->id == 0 || getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS')) {
|
||||
if (!empty($user->socid)) { // external user: restrict to their own third party
|
||||
$projSocFilter = $user->socid;
|
||||
} elseif (getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') || $socid == 0) {
|
||||
// Give priority to the constant (as on supplier invoice), so a supplier document created from a
|
||||
// customer project keeps that project selected after the supplier is chosen.
|
||||
$projSocFilter = -1;
|
||||
} else {
|
||||
$projSocFilter = $soc->id;
|
||||
$projSocFilter = $socid;
|
||||
}
|
||||
print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects($projSocFilter, $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
|
||||
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.((int) $soc->id).'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans("AddProject").'"></span></a>';
|
||||
|
|
|
|||
Loading…
Reference in a new issue