mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-16 06:21:28 +01:00
Clean code and prepare database for reception from any source
This commit is contained in:
@@ -260,6 +260,21 @@ abstract class CommonObject
|
||||
*/
|
||||
public $origin_id;
|
||||
|
||||
/**
|
||||
* @var Object Origin object. This is set by fetch_origin() from this->origin and this->origin_id.
|
||||
*/
|
||||
public $origin_object;
|
||||
|
||||
// TODO Remove this. Has been replaced with ->origin_object.
|
||||
// This is set by fetch_origin() from this->origin and this->origin_id
|
||||
/** @deprecated */
|
||||
public $expedition;
|
||||
/** @deprecated */
|
||||
public $livraison;
|
||||
/** @deprecated */
|
||||
public $commandeFournisseur;
|
||||
|
||||
|
||||
/**
|
||||
* @var string The object's reference
|
||||
*/
|
||||
@@ -1870,7 +1885,9 @@ abstract class CommonObject
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Read linked origin object
|
||||
* Read linked origin object.
|
||||
* Set ->origin_object
|
||||
* Set also ->expedition or ->livraison or ->commandFournisseur (deprecated)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -1883,15 +1900,18 @@ abstract class CommonObject
|
||||
if ($this->origin == 'delivery') {
|
||||
$this->origin = 'livraison';
|
||||
}
|
||||
if ($this->origin == 'order_supplier') {
|
||||
if ($this->origin == 'order_supplier' || $this->origin == 'supplier_order') {
|
||||
$this->origin = 'commandeFournisseur';
|
||||
}
|
||||
|
||||
$origin = $this->origin;
|
||||
|
||||
$classname = ucfirst($origin);
|
||||
$this->$origin = new $classname($this->db);
|
||||
$this->$origin->fetch($this->origin_id);
|
||||
$this->origin_object = new $classname($this->db);
|
||||
$this->origin_object->fetch($this->origin_id);
|
||||
|
||||
// TODO Remove this line
|
||||
$this->$origin = $this->origin_object;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1755,7 +1755,8 @@ if ($action == 'create') {
|
||||
$typeobject = $object->origin;
|
||||
$origin = $object->origin;
|
||||
$origin_id = $object->origin_id;
|
||||
$object->fetch_origin(); // Load property $object->commande, $object->propal, ...
|
||||
|
||||
$object->fetch_origin(); // Load property $object->origin_object (old $object->commande, $object->propal, ...)
|
||||
}
|
||||
|
||||
$soc = new Societe($db);
|
||||
@@ -1768,7 +1769,7 @@ if ($action == 'create') {
|
||||
|
||||
$formconfirm = '';
|
||||
|
||||
// Confirm deleteion
|
||||
// Confirm deletion
|
||||
if ($action == 'delete') {
|
||||
$formquestion = array();
|
||||
if ($object->statut == Expedition::STATUS_CLOSED && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
|
||||
|
||||
@@ -191,3 +191,5 @@ CREATE TABLE llx_mrp_production_extrafields
|
||||
) ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_mrp_production_extrafields ADD INDEX idx_mrp_production_fk_object(fk_object);
|
||||
|
||||
ALTER TABLE llx_commande_fournisseur_dispatch ADD COLUMN element_type varchar(50) DEFAULT 'supplier_order' NOT NULL;
|
||||
|
||||
@@ -14,21 +14,23 @@
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
--
|
||||
-- This table is just an history table to track all receiving done for a
|
||||
-- This table is just an history table to track all receiption to do or done for a
|
||||
-- particular supplier order. A movement with same information is also done
|
||||
-- into stock_movement so this table may be useless.
|
||||
--
|
||||
-- Detail of each lines of a reception (qty, batch and into which warehouse must be
|
||||
-- received or has been receveived a purchase order line).
|
||||
-- This table should have been named llx_receptiondet_batch
|
||||
--
|
||||
-- This table should be renamed into llx_receptiondet_batch
|
||||
-- ===================================================================
|
||||
|
||||
create table llx_commande_fournisseur_dispatch
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_product integer,
|
||||
fk_commande integer,
|
||||
fk_commandefourndet integer,
|
||||
fk_commande integer, -- should be renamed into fk_element
|
||||
fk_commandefourndet integer, -- should be renamed into fk_elementdet
|
||||
element_type varchar(50) DEFAULT 'supplier_order' NOT NULL, -- Type of source ('supplier_order', ...)
|
||||
fk_projet integer DEFAULT NULL,
|
||||
fk_reception integer DEFAULT NULL,
|
||||
qty float, -- qty to move
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
--
|
||||
-- Note: a shipment is linked to an order or other object using llx_element_element table.
|
||||
-- ===================================================================
|
||||
|
||||
create table llx_expedition
|
||||
@@ -31,11 +32,11 @@ create table llx_expedition
|
||||
ref_ext varchar(255), -- reference into an external system (not used by dolibarr)
|
||||
ref_customer varchar(255), -- customer number
|
||||
|
||||
date_creation datetime, -- date de creation
|
||||
date_creation datetime, -- date of creation
|
||||
fk_user_author integer, -- author of creation
|
||||
fk_user_modif integer, -- author of last change
|
||||
date_valid datetime, -- date de validation
|
||||
fk_user_valid integer, -- valideur
|
||||
date_valid datetime, -- date of validation
|
||||
fk_user_valid integer, -- user that validate
|
||||
date_delivery datetime DEFAULT NULL, -- date planned of delivery
|
||||
date_expedition datetime, -- not used (deprecated)
|
||||
fk_address integer DEFAULT NULL, -- delivery address (deprecated)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
--
|
||||
-- Note: a reception is linked to a supplier order or other object using llx_element_element table.
|
||||
-- ===================================================================
|
||||
|
||||
create table llx_reception
|
||||
@@ -29,7 +30,7 @@ create table llx_reception
|
||||
fk_projet integer DEFAULT NULL,
|
||||
|
||||
ref_ext varchar(30), -- reference into an external system (not used by dolibarr)
|
||||
ref_supplier varchar(255), -- supplier number
|
||||
ref_supplier varchar(255), -- reference of reception on supplier side
|
||||
|
||||
date_creation datetime, -- date de creation
|
||||
fk_user_author integer, -- author of creation
|
||||
|
||||
@@ -122,6 +122,7 @@ if ($id > 0 || !empty($ref)) {
|
||||
$object->fetch($id, $ref);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$typeobject = '';
|
||||
if (!empty($object->origin)) {
|
||||
$origin = $object->origin;
|
||||
|
||||
@@ -129,11 +130,10 @@ if ($id > 0 || !empty($ref)) {
|
||||
$typeobject = $object->origin;
|
||||
}
|
||||
|
||||
// Linked documents
|
||||
if ($origin == 'order_supplier' && $object->$typeobject->id && isModEnabled("supplier_order")) {
|
||||
$origin_id = $object->$typeobject->id;
|
||||
$objectsrc = new CommandeFournisseur($db);
|
||||
$objectsrc->fetch($object->$typeobject->id);
|
||||
// Set $origin_id and $objectsrc
|
||||
if (($origin == 'order_supplier' || $origin == 'supplier_order') && is_object($object->origin_object) && isModEnabled("supplier_order")) {
|
||||
$origin_id = $object->origin_object->id;
|
||||
$objectsrc = $object->origin_object;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user