can merge products but experimental

This commit is contained in:
Frédéric FRANCE 2021-11-23 22:36:14 +01:00
parent 799862362d
commit 99cddfa235
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
3 changed files with 21 additions and 8 deletions

View File

@ -1708,7 +1708,7 @@ class Account extends CommonObject
if ($dbs->query($sql)) {
return true;
} else {
//if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B.
//if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdparty and B-C on old one, we must get A-B-C after merge. Not A-B.
//$this->errors = $dbs->lasterror();
return false;
}

View File

@ -978,6 +978,23 @@ class ProductFournisseur extends Product
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
/**
* Function used to replace a product id with another one.
*
* @param DoliDB $db Database handler
* @param int $origin_id Old product id
* @param int $dest_id New product id
* @return bool
*/
public static function replaceProduct(DoliDB $db, $origin_id, $dest_id)
{
$tables = array(
'product_fournisseur_price'
);
return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables);
}
/**
* List supplier prices log of a supplier price
*

View File

@ -246,8 +246,6 @@ if (empty($reshook)) {
$db->begin();
// Recopy some data
//$object->client = $object->client | $productOrigin->client;
//$object->fournisseur = $object->fournisseur | $productOrigin->fournisseur;
$listofproperties = array(
'ref',
'ref_ext',
@ -310,7 +308,7 @@ if (empty($reshook)) {
// Move links
if (!$error) {
// This list is also into the api_products.class.php
// TODO add this functionality into the api_products.class.php
// TODO Mutualise the list into object product.class.php
$objects = array(
'Categorie' => '/categories/class/categorie.class.php',
@ -327,11 +325,8 @@ if (empty($reshook)) {
'CommandeFournisseur' => '/fourn/class/fournisseur.commande.class.php',
'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php',
'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php',
// 'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php',
'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php',
'Delivery' => '/delivery/class/delivery.class.php',
// 'Project' => '/projet/class/project.class.php',
// 'Ticket' => '/ticket/class/ticket.class.php',
// 'ConferenceOrBoothAttendee' => '/eventorganization/class/conferenceorboothattendee.class.php'
);
//First, all core objects must update their tables
@ -382,6 +377,7 @@ if (empty($reshook)) {
if (!$error) {
// We finally remove the old product
// TODO merge attached files from old product into new one before delete
if ($productOrigin->delete($user) < 1) {
$error++;
}