Merge branch '18.0' of github.com:Dolibarr/dolibarr into 18.0

This commit is contained in:
Laurent Destailleur 2024-10-24 03:07:20 +02:00
commit aa096448be
6 changed files with 36 additions and 11 deletions

View file

@ -146,7 +146,6 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
$backurlforlist = DOL_URL_ROOT.'/comm/propal/list.php';
@ -1614,7 +1613,20 @@ if (empty($reshook)) {
$result = $object->set_demand_reason($user, GETPOST('demand_reason_id', 'int'));
} elseif ($action == 'setconditions' && $usercancreate) {
// Terms of payment
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'), GETPOST('cond_reglement_id_deposit_percent', 'alpha'));
$sql = "SELECT code ";
$sql .= "FROM " . $db->prefix() . "c_payment_term";
$sql .= " WHERE rowid = " . ((int) GETPOST('cond_reglement_id', 'int'));
$result = $db->query($sql);
if ($result) {
$obj = $db->fetch_object($result);
if ($obj->code == 'DEP30PCTDEL') {
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'), GETPOST('cond_reglement_id_deposit_percent', 'alpha'));
} else {
$object->deposit_percent = 0;
$object->update($user);
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'), $object->deposit_percent);
}
}
} elseif ($action == 'setremisepercent' && $usercancreate) {
$result = $object->set_remise_percent($user, price2num(GETPOST('remise_percent'), '', 2));
} elseif ($action == 'setremiseabsolue' && $usercancreate) {

View file

@ -2016,7 +2016,7 @@ if ($resql) {
$productstat_cachevirtual[$obj->fk_product]['stock_reel'] = $generic_product->stock_theorique;
} else {
$generic_product->stock_reel = $productstat_cache[$obj->fk_product]['stock_reel'];
$generic_product->stock_theorique = $productstat_cachevirtual[$obj->fk_product]['stock_reel'] = $generic_product->stock_theorique;
$generic_product->stock_theorique = $productstat_cachevirtual[$obj->fk_product]['stock_reel'];
}
if ($reliquat > $generic_product->stock_reel) {

View file

@ -321,7 +321,7 @@ if (empty($reshook)) {
$object->date = dol_now();
}
if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) {
if (!empty($conf->global->INVOICE_CHECK_POSTERIOR_DATE)) {
$last_of_type = $object->willBeLastOfSameType(true);
if (empty($object->date_validation) && !$last_of_type[0]) {
setEventMessages($langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $object->ref, dol_print_date($object->date, 'day'), dol_print_date($last_of_type[1], 'day')), null, 'errors');

View file

@ -1340,6 +1340,14 @@ class FactureRec extends CommonInvoice
$facture->multicurrency_tx = $facturerec->multicurrency_tx;
}
if (isset($facture->array_options) && isset($facturerec->array_options)) {
foreach ($facturerec->array_options as $key => $value) {
if (isset($facture->array_options[$key])) {
$facture->array_options[$key] = $value;
}
}
}
$invoiceidgenerated = $facture->create($user);
if ($invoiceidgenerated <= 0) {
$this->errors = $facture->errors;

View file

@ -537,8 +537,8 @@ if (empty($reshook)) {
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
// Update if prices fields are defined
$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
$tva_tx = get_default_tva($object->thirdparty, $mysoc, $prod->id);
$tva_npr = get_default_npr($object->thirdparty, $mysoc, $prod->id);
if (empty($tva_tx)) {
$tva_npr = 0;
}
@ -546,7 +546,7 @@ if (empty($reshook)) {
// Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp'].
$pqp = (GETPOST('pbq', 'int') ? GETPOST('pbq', 'int') : 0);
$datapriceofproduct = $prod->getSellPrice($mysoc, $object->thirdparty, $pqp);
$datapriceofproduct = $prod->getSellPrice($object->thirdparty, $mysoc, $pqp);
$pu_ht = $datapriceofproduct['pu_ht'];
$pu_ttc = $datapriceofproduct['pu_ttc'];
@ -661,8 +661,8 @@ if (empty($reshook)) {
$buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value
// Local Taxes
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr);
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
$info_bits = 0;
if ($tva_npr) {
$info_bits |= 0x01;
@ -1082,7 +1082,7 @@ if ($action == 'create') {
$disableedit = 1;
$disablemove = 1;
$disableremove = 1;
$object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice
$object->printObjectLines('', $object->thirdparty, $mysoc, $lineid, 0); // No date selector for template invoice
}
print "</table>\n";
@ -1571,7 +1571,7 @@ if ($action == 'create') {
$canchangeproduct = 0;
$object->statut = $object->suspended;
$object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice
$object->printObjectLines($action, $object->thirdparty, $mysoc, $lineid, 0); // No date selector for template invoice
}
// Form to add new line

View file

@ -1058,6 +1058,11 @@ class Reception extends CommonObject
$mouvS->origin = null;
$result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ReceptionDeletedInDolibarr", $this->ref), '', $obj->eatby, $obj->sellby, $obj->batch); // Price is set to 0, because we don't want to see WAP changed
if ($result < 0) {
$error++;
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
}
}
} else {
$error++; $this->errors[] = "Error ".$this->db->lasterror();