integrate auto increment on 'auto' keyword.
This commit is contained in:
parent
b72a1c9964
commit
de4986a570
@ -531,7 +531,7 @@ class Boms extends DolibarrApi
|
|||||||
{
|
{
|
||||||
$myobject = array();
|
$myobject = array();
|
||||||
foreach ($this->bom->fields as $field => $propfield) {
|
foreach ($this->bom->fields as $field => $propfield) {
|
||||||
if (in_array($field, array('rowid', 'entity', 'ref', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) {
|
if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) {
|
||||||
continue; // Not a mandatory field
|
continue; // Not a mandatory field
|
||||||
}
|
}
|
||||||
if (!isset($data[$field])) {
|
if (!isset($data[$field])) {
|
||||||
@ -550,10 +550,18 @@ class Boms extends DolibarrApi
|
|||||||
private function checkRefNumbering(): void
|
private function checkRefNumbering(): void
|
||||||
{
|
{
|
||||||
$ref = substr($this->bom->ref, 1, 4);
|
$ref = substr($this->bom->ref, 1, 4);
|
||||||
if ($this->bom->status > 0 && (empty($this->bom->ref) || $ref == 'PROV')) {
|
if ($this->bom->status > 0 && $ref == 'PROV') {
|
||||||
|
throw new RestException(400, "Wrong naming scheme '(PROV%)' is only allowed on 'DRAFT' status. For automatic increment use 'auto' on the 'ref' field.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->bom->ref == 'auto'){
|
||||||
|
if (empty($this->bom->id) && $this->bom->status == 0){
|
||||||
|
$this->bom->ref = ''; // 'ref' will auto incremented with '(PROV' + newID + ')'
|
||||||
|
} else {
|
||||||
$this->bom->fetch_product();
|
$this->bom->fetch_product();
|
||||||
$numref = $this->bom->getNextNumRef($this->bom->product);
|
$numref = $this->bom->getNextNumRef($this->bom->product);
|
||||||
$this->bom->ref = $numref;
|
$this->bom->ref = $numref;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user