Automated merge from 21.0 to 22.0 by tool pullmerge.sh
This commit is contained in:
commit
45560ce69c
9 changed files with 65 additions and 15 deletions
|
|
@ -2223,6 +2223,12 @@ if (empty($reshook)) {
|
|||
|
||||
$object->situation_counter += 1;
|
||||
|
||||
// Set extrafields from the create form BEFORE createFromCurrent(), so they are already
|
||||
// present when create() inserts them and fires the BILL_CREATE trigger. This avoids firing
|
||||
// BILL_CREATE a second time just to expose the extrafields (#32217).
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$extrafields->setOptionalsFromPost(null, $object);
|
||||
|
||||
$id = $object->createFromCurrent($user);
|
||||
if ($id <= 0) {
|
||||
$mesg = $object->error;
|
||||
|
|
@ -2230,13 +2236,6 @@ if (empty($reshook)) {
|
|||
$nextSituationInvoice = new Facture($db);
|
||||
$nextSituationInvoice->fetch($id);
|
||||
|
||||
// create extrafields with data from create form
|
||||
$extrafields->fetch_name_optionals_label($nextSituationInvoice->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $nextSituationInvoice);
|
||||
if ($ret > 0) {
|
||||
$nextSituationInvoice->insertExtraFields();
|
||||
}
|
||||
|
||||
// Hooks
|
||||
$parameters = array('origin_type' => $object->origin_type, 'origin_id' => $object->origin_id);
|
||||
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $nextSituationInvoice, $action); // Note that $action and $object may have been
|
||||
|
|
|
|||
|
|
@ -1171,7 +1171,10 @@ class Facture extends CommonInvoice
|
|||
|
||||
// Retrieve all extrafield
|
||||
// fetch optionals attributes and labels
|
||||
$this->fetch_optionals();
|
||||
// (unless the caller already set array_options, e.g. from a create form, so we don't overwrite them)
|
||||
if (empty($this->array_options)) {
|
||||
$this->fetch_optionals();
|
||||
}
|
||||
|
||||
if (!empty($this->array_options)) {
|
||||
$facture->array_options = $this->array_options;
|
||||
|
|
|
|||
|
|
@ -526,8 +526,8 @@ class ContratLigne extends CommonObjectLine
|
|||
$this->ref = $obj->rowid;
|
||||
|
||||
$this->tms = $this->db->jdate($obj->tms);
|
||||
$this->fk_contrat = $obj->fk_contrat;
|
||||
$this->fk_product = $obj->fk_product;
|
||||
$this->fk_contrat = (int) $obj->fk_contrat;
|
||||
$this->fk_product = (int) $obj->fk_product;
|
||||
$this->statut = $obj->statut;
|
||||
$this->product_ref = $obj->product_ref;
|
||||
$this->product_label = $obj->product_label;
|
||||
|
|
|
|||
|
|
@ -10185,7 +10185,7 @@ abstract class CommonObject
|
|||
public function isInt($info)
|
||||
{
|
||||
if (is_array($info)) {
|
||||
if (isset($info['type']) && (preg_match('/(^int|int$)/i', $info['type']))) {
|
||||
if (isset($info['type']) && (preg_match('/^(?:tiny|small|medium|big)?int|int$/i', $info['type']))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1191,7 +1191,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
|
|||
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
$sql .= " AND (sc.fk_user = ".((int) $user->id)." OR sc.fk_user IS NULL)";
|
||||
}
|
||||
} elseif (isModEnabled('multicompany')) {
|
||||
} elseif (isModEnabled('multicompany') && (!empty($object->ismultientitymanaged) || !isset($object->ismultientitymanaged))) {
|
||||
// If multicompany, and user is an internal user with all permissions, check that object is in correct entity
|
||||
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
|
|
|
|||
|
|
@ -298,8 +298,10 @@ class MoLine extends CommonObjectLine
|
|||
$sqlwhere = array();
|
||||
if (count($filter) > 0) {
|
||||
foreach ($filter as $key => $value) {
|
||||
if ($key == 't.rowid') {
|
||||
if ($key == 't.rowid' || $key == 'fk_mo' || $key == 'origin_id') {
|
||||
$sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value);
|
||||
} elseif ($key == 'origin_type') {
|
||||
$sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->escape($value)."'";
|
||||
} elseif (strpos($key, 'date') !== false) {
|
||||
$sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate((int) $value)."'";
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -170,7 +170,15 @@ if (empty($reshook)) {
|
|||
|
||||
$objectbomchildline->fetch($id_bom_line);
|
||||
|
||||
$TMoLines = $moline->fetchAll('DESC', 'rowid', 1, 0, array('origin_id' => $id_bom_line));
|
||||
// Find the consume line of the parent MO generated from this BOM line.
|
||||
// The lookup must be scoped to the parent MO and use an exact match on origin_id/origin_type,
|
||||
// otherwise the default 'origin_id LIKE %..%' filter can return an unrelated line (or none),
|
||||
// which would let the child MO be created from the leftover parent POST data (duplicate MO).
|
||||
$TMoLines = $moline->fetchAll('DESC', 'rowid', 1, 0, array('fk_mo' => $mo_parent->id, 'origin_id' => $id_bom_line, 'origin_type' => 'bomline'));
|
||||
|
||||
if (empty($TMoLines)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($TMoLines as $tmpmoline) {
|
||||
$_POST['fk_bom'] = $objectbomchildline->fk_bom_child;
|
||||
|
|
|
|||
|
|
@ -621,7 +621,9 @@ if ($action == 'confirm_generateinvoice' && $user->hasRight('facture', 'creer'))
|
|||
$arrayoftasks[$object->timespent_id]['fk_product'] = $object->timespent_fk_product;
|
||||
}
|
||||
|
||||
$pu_ht_saved = $pu_ht; // Save the base unit price (price of the selected product/service if any, 0 otherwise)
|
||||
foreach ($arrayoftasks as $timespent_id => $value) {
|
||||
$pu_ht = $pu_ht_saved; // Reset for each line, so a line does not inherit the unit price computed for the previous one
|
||||
$userid = $value['user'];
|
||||
//$pu_ht = $value['timespent'] * $fuser->thm;
|
||||
|
||||
|
|
@ -630,7 +632,9 @@ if ($action == 'confirm_generateinvoice' && $user->hasRight('facture', 'creer'))
|
|||
|
||||
// If no unit price known
|
||||
if (empty($pu_ht)) {
|
||||
$pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU');
|
||||
if ($value['timespent']) {
|
||||
$pu_ht = price2num(($value['totalvaluetodivideby3600'] / $value['timespent']), 'MU');
|
||||
}
|
||||
}
|
||||
|
||||
// Add lines
|
||||
|
|
|
|||
|
|
@ -117,4 +117,38 @@ class CommonObjectTest extends CommonClassTest
|
|||
$this->assertLessThanOrEqual($result, 0);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testIsInt
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIsInt()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject = new Commande($db);
|
||||
|
||||
// Integer types, with or without a size/unsigned suffix, must be detected.
|
||||
$this->assertTrue($localobject->isInt(array('type' => 'int')), 'int');
|
||||
$this->assertTrue($localobject->isInt(array('type' => 'int(11)')), 'int(11)');
|
||||
$this->assertTrue($localobject->isInt(array('type' => 'integer')), 'integer');
|
||||
$this->assertTrue($localobject->isInt(array('type' => 'tinyint(4)')), 'tinyint(4)');
|
||||
$this->assertTrue($localobject->isInt(array('type' => 'smallint(6)')), 'smallint(6)');
|
||||
$this->assertTrue($localobject->isInt(array('type' => 'bigint(20)')), 'bigint(20)');
|
||||
// Dolibarr foreign-key column syntax "integer:Class:path" must keep being detected.
|
||||
$this->assertTrue($localobject->isInt(array('type' => 'integer:User:user/class/user.class.php')), 'integer:User:...');
|
||||
|
||||
// Non-integer types must not be detected, including strings that merely contain "int".
|
||||
$this->assertFalse($localobject->isInt(array('type' => 'varchar(255)')), 'varchar(255)');
|
||||
$this->assertFalse($localobject->isInt(array('type' => 'double(24,8)')), 'double(24,8)');
|
||||
$this->assertFalse($localobject->isInt(array('type' => 'date')), 'date');
|
||||
$this->assertFalse($localobject->isInt(array('type' => 'sellist:llx_c_typent:libelle:id')), 'sellist:...');
|
||||
|
||||
print __METHOD__." OK\n";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue