Merge pull request #23194 from frederic34/modproductlot

doc
This commit is contained in:
Laurent Destailleur 2022-12-14 00:20:22 +01:00 committed by GitHub
commit 112f16a605
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 52 additions and 28 deletions

View File

@ -139,7 +139,7 @@ class mod_codeproduct_elephant extends ModeleProductCode
* Return an example of result returned by getNextValue
*
* @param Translate $langs Object langs
* @param product $objproduct Object product
* @param Product $objproduct Object product
* @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
* @return string Return string example
*/

View File

@ -33,10 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.class.php'
class mod_codeproduct_leopard extends ModeleProductCode
{
/*
* Attention ce module est utilise par defaut si aucun module n'a
* ete definit dans la configuration
* Please note this module is used by default if no module has been defined in the configuration
*
* Le fonctionnement de celui-ci doit donc rester le plus ouvert possible
* Its operation must therefore remain as open as possible
*/
/**
@ -100,7 +99,7 @@ class mod_codeproduct_leopard extends ModeleProductCode
/**
* Return an example of result returned by getNextValue
*
* @param product $objproduct Object product
* @param Product $objproduct Object product
* @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
* @return string Return next value
*/

View File

@ -132,7 +132,7 @@ class mod_lot_advanced extends ModeleNumRefBatch
* Return next free value
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @param Productlot $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue($objsoc, $object)
@ -143,6 +143,15 @@ class mod_lot_advanced extends ModeleNumRefBatch
// We get cursor rule
$mask = getDolGlobalString('LOT_ADVANCED_MASK');
$filter = '';
if (getDolGlobalString('PRODUCTBATCH_LOT_USE_PRODUCT_MASKS') && !empty($object->fk_product)) {
$product = new Product($db);
$res = $product->fetch($object->fk_product);
if ($res > 0 && !empty($product->batch_mask)) {
$mask = $product->batch_mask;
$filter = '';
}
}
if (!$mask) {
$this->error = 'NotConfigured';
@ -151,7 +160,7 @@ class mod_lot_advanced extends ModeleNumRefBatch
$date = dol_now();
$numFinal = get_next_value($db, $mask, 'product_lot', 'batch', '', null, $date);
$numFinal = get_next_value($db, $mask, 'product_lot', 'batch', $filter, null, $date);
return $numFinal;
}

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2022 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -26,16 +27,15 @@
require_once DOL_DOCUMENT_ROOT.'/core/modules/product_batch/modules_product_batch.class.php';
/**
* \class mod_codeproduct_leopard
* \brief Classe permettant la gestion leopard des codes produits
* \class mod_lot_free
* \brief Class allowing lot_free management of batch numbers
*/
class mod_lot_free extends ModeleNumRefBatch
{
/*
* Attention ce module est utilise par defaut si aucun module n'a
* ete definit dans la configuration
* Please note this module is used by default if no module has been defined in the configuration
*
* Le fonctionnement de celui-ci doit donc rester le plus ouvert possible
* Its operation must therefore remain as open as possible
*/
@ -44,7 +44,10 @@ class mod_lot_free extends ModeleNumRefBatch
*/
public $name = 'lot_free';
public $code_modifiable; // Code modifiable
/**
* @var string Code modifiable
*/
public $code_modifiable;
public $code_modifiable_invalide; // Code modifiable si il est invalide
@ -94,12 +97,11 @@ class mod_lot_free extends ModeleNumRefBatch
* Return an example of result returned by getNextValue
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @param Productlot $object Object we need next value for
* @return string Return next value
*/
public function getNextValue($objsoc, $object)
{
global $langs;
return '';
}
}

View File

@ -112,7 +112,7 @@ class mod_lot_standard extends ModeleNumRefBatch
* Return next free value
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @param Productlot $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue($objsoc, $object)

View File

@ -132,7 +132,7 @@ class mod_sn_advanced extends ModeleNumRefBatch
* Return next free value
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @param Productlot $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue($objsoc, $object)
@ -144,6 +144,16 @@ class mod_sn_advanced extends ModeleNumRefBatch
// We get cursor rule
$mask = getDolGlobalString('SN_ADVANCED_MASK');
$filter = '';
if (getDolGlobalString('PRODUCTBATCH_SN_USE_PRODUCT_MASKS') && !empty($object->fk_product)) {
$product = new Product($db);
$res = $product->fetch($object->fk_product);
if ($res > 0 && !empty($product->batch_mask)) {
$mask = $product->batch_mask;
$filter = '';
}
}
if (!$mask) {
$this->error = 'NotConfigured';
return 0;
@ -151,7 +161,7 @@ class mod_sn_advanced extends ModeleNumRefBatch
$date = dol_now();
$numFinal = get_next_value($db, $mask, 'product_lot', 'batch', '', null, $date);
$numFinal = get_next_value($db, $mask, 'product_lot', 'batch', $filter, null, $date);
return $numFinal;
}

View File

@ -93,7 +93,7 @@ class mod_sn_free extends ModeleNumRefBatch
* Return an example of result returned by getNextValue
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @param Productlot $object Object we need next value for
* @return string Return next value
*/
public function getNextValue($objsoc, $object)

View File

@ -112,7 +112,7 @@ class mod_sn_standard extends ModeleNumRefBatch
* Return next free value
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @param Productlot $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue($objsoc, $object)

View File

@ -125,7 +125,7 @@ abstract class ModeleNumRefBatch
* Returns next assigned value
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @param Productlot $object Object we need next value for
* @return string Valeur
*/
public function getNextValue($objsoc, $object)

View File

@ -68,6 +68,7 @@ ShipmentBackToDraftInDolibarr=Shipment %s go back to draft status
ShipmentDeletedInDolibarr=Shipment %s deleted
ShipmentCanceledInDolibarr=Shipment %s canceled
ReceptionValidatedInDolibarr=Reception %s validated
ReceptionDeletedInDolibarr=Reception %s deleted
ReceptionClassifyClosedInDolibarr=Reception %s classified closed
OrderCreatedInDolibarr=Order %s created
OrderValidatedInDolibarr=Order %s validated
@ -177,4 +178,4 @@ AddReminder=Create an automatic reminder notification for this event
ErrorReminderActionCommCreation=Error creating the reminder notification for this event
BrowserPush=Browser Popup Notification
ActiveByDefault=Enabled by default
Until=until
Until=until

View File

@ -110,10 +110,13 @@ class Productlot extends CommonObject
public $entity;
/**
* @var int ID
* @var int Product ID
*/
public $fk_product;
/**
* @var string batch ref
*/
public $batch;
public $eatby = '';
public $sellby = '';
@ -126,15 +129,18 @@ class Productlot extends CommonObject
public $tms = '';
/**
* @var int ID
* @var int user ID
*/
public $fk_user_creat;
/**
* @var int ID
* @var int user ID
*/
public $fk_user_modif;
/**
* @var string import key
*/
public $import_key;
@ -241,9 +247,6 @@ class Productlot extends CommonObject
}
if (!$error && !$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action to call a trigger.
// Call triggers
$result = $this->call_trigger('PRODUCTLOT_CREATE', $user);
if ($result < 0) {