// SupplierOrder now adds products in warehouses
This commit is contained in:
@@ -224,7 +224,7 @@ class SupplierOrderDetailCore extends ObjectModel
|
|||||||
protected function calculatePrices()
|
protected function calculatePrices()
|
||||||
{
|
{
|
||||||
// calcul entry price
|
// calcul entry price
|
||||||
$htis->price_te = (float)$this->unit_price_te * (int)$this->quantity_expected;
|
$this->price_te = (float)$this->unit_price_te * (int)$this->quantity_expected;
|
||||||
|
|
||||||
// calcul entry discount value
|
// calcul entry discount value
|
||||||
if ($this->discount_rate != null && is_numeric($this->discount_rate) && $this->discount_rate > 0)
|
if ($this->discount_rate != null && is_numeric($this->discount_rate) && $this->discount_rate > 0)
|
||||||
|
|||||||
@@ -175,8 +175,7 @@ class AdminStockMvtControllerCore extends AdminController
|
|||||||
*/
|
*/
|
||||||
$this->addRowAction('edit');
|
$this->addRowAction('edit');
|
||||||
$this->addRowAction('delete');
|
$this->addRowAction('delete');
|
||||||
$this->addRowActionSkipList('edit', array(6, 7));
|
$this->addRowActionSkipList('delete', array(1, 2, 3, 4, 6, 7, 8));
|
||||||
$this->addRowActionSkipList('delete', array(1, 2, 3, 4, 6, 7));
|
|
||||||
|
|
||||||
$this->toolbar_title = $this->l('Stock : Stock movements reasons');
|
$this->toolbar_title = $this->l('Stock : Stock movements reasons');
|
||||||
$first_list = parent::initList();
|
$first_list = parent::initList();
|
||||||
|
|||||||
@@ -1134,22 +1134,45 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
|||||||
$this->_errors[] = sprintf(Tools::displayError('Quantity (%d) for product #%d is not valid'), (int)$quantity, (int)$id_supplier_order_detail);
|
$this->_errors[] = sprintf(Tools::displayError('Quantity (%d) for product #%d is not valid'), (int)$quantity, (int)$id_supplier_order_detail);
|
||||||
else // everything is valid : updates
|
else // everything is valid : updates
|
||||||
{
|
{
|
||||||
|
// creates the history
|
||||||
$supplier_receipt_history = new SupplierOrderReceiptHistory();
|
$supplier_receipt_history = new SupplierOrderReceiptHistory();
|
||||||
$supplier_receipt_history->id_supplier_order_detail = (int)$id_supplier_order_detail;
|
$supplier_receipt_history->id_supplier_order_detail = (int)$id_supplier_order_detail;
|
||||||
$supplier_receipt_history->id_employee = (int)$this->context->employee->id;
|
$supplier_receipt_history->id_employee = (int)$this->context->employee->id;
|
||||||
$supplier_receipt_history->id_supplier_order_state = (int)$supplier_order->id_supplier_order_state;
|
$supplier_receipt_history->id_supplier_order_state = (int)$supplier_order->id_supplier_order_state;
|
||||||
$supplier_receipt_history->quantity = (int)$quantity;
|
$supplier_receipt_history->quantity = (int)$quantity;
|
||||||
$supplier_receipt_history->add();
|
|
||||||
|
|
||||||
|
// updates quantity received
|
||||||
$supplier_order_detail->quantity_received += (int)$quantity;
|
$supplier_order_detail->quantity_received += (int)$quantity;
|
||||||
$supplier_order_detail->save();
|
|
||||||
|
|
||||||
// if current state is "Pending receipt", then we sets it to "Order received in part"
|
// if current state is "Pending receipt", then we sets it to "Order received in part"
|
||||||
if (3 == $supplier_order->id_supplier_order_state)
|
if (3 == $supplier_order->id_supplier_order_state)
|
||||||
{
|
|
||||||
$supplier_order->id_supplier_order_state = 4;
|
$supplier_order->id_supplier_order_state = 4;
|
||||||
|
|
||||||
|
// Adds to stock
|
||||||
|
$warehouse = new Warehouse($supplier_order->id_warehouse);
|
||||||
|
if (!Validate::isLoadedObject($warehouse))
|
||||||
|
{
|
||||||
|
$this->_errors[] = Tools::displayError('Warehouse could not be loaded');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$manager = StockManagerFactory::getManager();
|
||||||
|
$res = $manager->addProduct($supplier_order_detail->id_product,
|
||||||
|
$supplier_order_detail->id_product_attribute,
|
||||||
|
$warehouse,
|
||||||
|
(int)$quantity,
|
||||||
|
Configuration::get('PS_STOCK_MVT_SUPPLIER_ORDER'),
|
||||||
|
$supplier_order_detail->price_te,
|
||||||
|
true,
|
||||||
|
$supplier_order->id);
|
||||||
|
if ($res) // if product has been added
|
||||||
|
{
|
||||||
|
$supplier_receipt_history->add();
|
||||||
|
$supplier_order_detail->save();
|
||||||
$supplier_order->save();
|
$supplier_order->save();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
$this->_errors[] = Tools::displayError('Something went wrong when adding products in warehouse');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -332,7 +332,8 @@ INSERT INTO `PREFIX_configuration` (`id_configuration`, `name`, `value`, `date_a
|
|||||||
(156, 'PS_ADMINREFRESH_NOTIFICATION', '1', NOW(), NOW()),
|
(156, 'PS_ADMINREFRESH_NOTIFICATION', '1', NOW(), NOW()),
|
||||||
(157, 'PS_STOCK_MVT_TRANSFER_TO', '6', NOW(), NOW()),
|
(157, 'PS_STOCK_MVT_TRANSFER_TO', '6', NOW(), NOW()),
|
||||||
(158, 'PS_STOCK_MVT_TRANSFER_FROM', '7', NOW(), NOW()),
|
(158, 'PS_STOCK_MVT_TRANSFER_FROM', '7', NOW(), NOW()),
|
||||||
(159, 'PS_CARRIER_DEFAULT_ORDER', '0', NOW(), NOW());
|
(159, 'PS_CARRIER_DEFAULT_ORDER', '0', NOW(), NOW()),
|
||||||
|
(160, 'PS_STOCK_MVT_SUPPLIER_ORDER', '8', NOW(), NOW());
|
||||||
|
|
||||||
INSERT INTO `PREFIX_configuration_lang` (`id_configuration`, `id_lang`, `value`, `date_upd`) VALUES
|
INSERT INTO `PREFIX_configuration_lang` (`id_configuration`, `id_lang`, `value`, `date_upd`) VALUES
|
||||||
(36, 1, 'IN', NOW()),(36, 2, 'FA', NOW()),(36, 3, 'CU', NOW()),(36, 4, 'FA', NOW()),(36, 5, 'FA', NOW()),
|
(36, 1, 'IN', NOW()),(36, 2, 'FA', NOW()),(36, 3, 'CU', NOW()),(36, 4, 'FA', NOW()),(36, 5, 'FA', NOW()),
|
||||||
@@ -1401,7 +1402,7 @@ INSERT INTO `PREFIX_group_group_shop` (`id_group`, `id_group_shop`) (SELECT `id_
|
|||||||
INSERT INTO `PREFIX_category_group` (`id_category`, `id_group`) VALUES (1, 1);
|
INSERT INTO `PREFIX_category_group` (`id_category`, `id_group`) VALUES (1, 1);
|
||||||
|
|
||||||
INSERT INTO `PREFIX_stock_mvt_reason` (`id_stock_mvt_reason`, `sign`, `date_add`, `date_upd`) VALUES
|
INSERT INTO `PREFIX_stock_mvt_reason` (`id_stock_mvt_reason`, `sign`, `date_add`, `date_upd`) VALUES
|
||||||
(1, 1, NOW(), NOW()), (2, -1, NOW(), NOW()), (3, -1, NOW(), NOW()), (4, -1, NOW(), NOW()), (5, 1, NOW(), NOW()), (6, 1, NOW(), NOW()), (7, -1, NOW(), NOW());
|
(1, 1, NOW(), NOW()), (2, -1, NOW(), NOW()), (3, -1, NOW(), NOW()), (4, -1, NOW(), NOW()), (5, 1, NOW(), NOW()), (6, 1, NOW(), NOW()), (7, -1, NOW(), NOW()), (8, 1, NOW(), NOW());
|
||||||
INSERT INTO `PREFIX_stock_mvt_reason_lang` (`id_stock_mvt_reason`, `id_lang`, `name`) VALUES
|
INSERT INTO `PREFIX_stock_mvt_reason_lang` (`id_stock_mvt_reason`, `id_lang`, `name`) VALUES
|
||||||
(1, 1, 'Increase'),
|
(1, 1, 'Increase'),
|
||||||
(1, 2, 'Augmenter'),
|
(1, 2, 'Augmenter'),
|
||||||
@@ -1413,8 +1414,8 @@ INSERT INTO `PREFIX_stock_mvt_reason_lang` (`id_stock_mvt_reason`, `id_lang`, `n
|
|||||||
(2, 3, 'Disminuir'),
|
(2, 3, 'Disminuir'),
|
||||||
(2, 4, 'Reduzieren'),
|
(2, 4, 'Reduzieren'),
|
||||||
(2, 5, 'Decrease'),
|
(2, 5, 'Decrease'),
|
||||||
(3, 1, 'Order'),
|
(3, 1, 'Client Order'),
|
||||||
(3, 2, 'Commande'),
|
(3, 2, 'Commande client'),
|
||||||
(3, 3, 'Pedido'),
|
(3, 3, 'Pedido'),
|
||||||
(3, 4, 'Bestellung'),
|
(3, 4, 'Bestellung'),
|
||||||
(3, 5, 'Ordine'),
|
(3, 5, 'Ordine'),
|
||||||
@@ -1437,7 +1438,12 @@ INSERT INTO `PREFIX_stock_mvt_reason_lang` (`id_stock_mvt_reason`, `id_lang`, `n
|
|||||||
(7, 2, 'Transferer (depuis)'),
|
(7, 2, 'Transferer (depuis)'),
|
||||||
(7, 3, 'Transfer (from)'),
|
(7, 3, 'Transfer (from)'),
|
||||||
(7, 4, 'Transfer (from)'),
|
(7, 4, 'Transfer (from)'),
|
||||||
(7, 5, 'Transfer (from)');
|
(7, 5, 'Transfer (from)'),
|
||||||
|
(8, 1, 'Supplier Order'),
|
||||||
|
(8, 2, 'Commande fournisseur)'),
|
||||||
|
(8, 3, 'Supplier Order'),
|
||||||
|
(8, 4, 'Supplier Order'),
|
||||||
|
(8, 5, 'Supplier Order');
|
||||||
|
|
||||||
INSERT INTO `PREFIX_warehouse` (`id_warehouse`, `id_currency`, `id_address`, `id_employee`, `reference`, `name`, `management_type`) VALUES
|
INSERT INTO `PREFIX_warehouse` (`id_warehouse`, `id_currency`, `id_address`, `id_employee`, `reference`, `name`, `management_type`) VALUES
|
||||||
(1, 1, 0, 1, 'default_warehouse', 'default warehouse', 'WA');
|
(1, 1, 0, 1, 'default_warehouse', 'default warehouse', 'WA');
|
||||||
|
|||||||
Reference in New Issue
Block a user