From 8772c53723ed13e655deba058aceb9f7fa1a531a Mon Sep 17 00:00:00 2001 From: atm-arnaud Date: Wed, 30 Jun 2021 12:37:21 +0200 Subject: [PATCH 1/5] FIX deposit can create credit note in payment conf --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 31c42e5ba9e..e15b2722800 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5260,7 +5260,7 @@ elseif ($id > 0 || !empty($ref)) } // Create a credit note - if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut > 0 && $usercancreate) + if (($object->type == Facture::TYPE_STANDARD || ($object->type == Facture::TYPE_DEPOSIT && empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) ) || $object->type == Facture::TYPE_PROFORMA) && $object->statut > 0 && $usercancreate) { if (!$objectidnext) { From 5b34ea6c228210fd613d5f813d94e32f2030ebce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Jul 2021 03:06:40 +0200 Subject: [PATCH 2/5] FIX permission to close a proposal when using advanced permissions --- htdocs/comm/propal/card.php | 11 ++++++++--- htdocs/comm/propal/list.php | 6 +++++- htdocs/core/modules/modPropale.class.php | 3 ++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 175486dcca0..c220e1f320d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2520,9 +2520,14 @@ if ($action == 'create') } // Close as accepted/refused - if ($object->statut == Propal::STATUS_VALIDATED && $usercanclose) { - print 'global->MAIN_JUMP_TAG) ? '' : '#close').'"'; - print '>'.$langs->trans('SetAcceptedRefused').''; + if ($object->statut == Propal::STATUS_VALIDATED) { + if ($usercanclose) { + print 'global->MAIN_JUMP_TAG) ? '' : '#close').'"'; + print '>'.$langs->trans('SetAcceptedRefused').''; + } else { + print ''.$langs->trans('SetAcceptedRefused').''; + } } // Clone diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index fcd8f067e01..e5700fca445 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -114,7 +114,11 @@ if (!$sortorder) $sortorder = 'DESC'; $permissiontoread = $user->rights->propal->lire; $permissiontoadd = $user->rights->propal->write; $permissiontodelete = $user->rights->propal->supprimer; -$permissiontoclose = $user->rights->propal->cloturer; +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { + $permissiontoclose = $user->rights->propale->propal_advance->close; +} else { + $permissiontoclose = $user->rights->propal->creer; +} // Security check $module = 'propal'; diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index c0ffa6f0811..9b40a236511 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -157,7 +157,8 @@ class modPropale extends DolibarrModules $this->rights[$r][1] = 'Close commercial proposals'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'cloturer'; + $this->rights[$r][4] = 'propal_advance'; + $this->rights[$r][5] = 'close'; $r++; $this->rights[$r][0] = 27; // id de la permission From 9392624e54d301fc0b36690ef201c292677410f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Jul 2021 13:36:04 +0200 Subject: [PATCH 3/5] Fix deletion of line on replacement invoice --- htdocs/core/tpl/objectline_view.tpl.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 428fac31789..3463de14240 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -315,6 +315,15 @@ if ($outputalsopricetotalwithtax) { } if ($this->statut == 0 && ($object_rights->creer) && $action != 'selectlines') { + + $situationinvoicelinewithparent = 0; + if ($line->fk_prev_id != null && in_array($object->element, array('facture', 'facturedet'))) { + if ($object->type == $object::TYPE_SITUATION) { // The constant TYPE_SITUATION exists only for object invoice + // Set constant to disallow editing during a situation cycle + $situationinvoicelinewithparent = 1; + } + } + print ''; $coldisplay++; if (($line->info_bits & 2) == 2 || !empty($disableedit)) { @@ -326,7 +335,7 @@ if ($this->statut == 0 && ($object_rights->creer) && $action != 'selectlines') { print ''; $coldisplay++; - if (($line->fk_prev_id == null) && empty($disableremove)) { //La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation + if (!$situationinvoicelinewithparent && empty($disableremove)) { // For situation invoice, deletion is not possible if there is a parent company. print 'id.'">'; print img_delete(); print ''; From 3aa24cccffd35d1a087be7f909023c9389e93df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 1 Jul 2021 15:15:35 +0200 Subject: [PATCH 4/5] fix can't remove extrafield date or datetime value --- htdocs/core/class/commonobject.class.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 91c09f1226a..417cb3042b7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5739,10 +5739,12 @@ abstract class CommonObject $this->array_options["options_".$key] = price2num($this->array_options["options_".$key]); break; case 'date': - $this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]); - break; case 'datetime': - $this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]); + if (empty($this->array_options["options_".$key])) { + $this->array_options["options_".$key] = null; + } else { + $this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]); + } break; /* case 'link': @@ -5790,7 +5792,11 @@ abstract class CommonObject } if ($linealreadyfound) { - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'"; + if ($this->array_options["options_".$key] === null) { + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = null"; + } else { + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'"; + } $sql .= " WHERE fk_object = ".$this->id; } else { $result = $this->insertExtraFields('', $user); From 3c5bc3fef421b34feb50a1d30b148dc4f0b1e015 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 2 Jul 2021 11:53:32 +0200 Subject: [PATCH 5/5] fix division by zero on of create --- htdocs/mrp/class/mo.class.php | 2 +- htdocs/mrp/tpl/originproductline.tpl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index f8ff5751221..1369741e07d 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -649,7 +649,7 @@ class Mo extends CommonObject if ($line->qty_frozen) { $moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce } else { - $moline->qty = price2num(($line->qty / $bom->qty) * $this->qty / $line->efficiency, 'MS'); // Calculate with Qty to produce and more presition + $moline->qty = price2num(($line->qty / ( ! empty($bom->qty) ? $bom->qty : 1 ) ) * $this->qty / ( ! empty($line->efficiency) ? $line->efficiency : 1 ), 'MS'); // Calculate with Qty to produce and more presition } if ($moline->qty <= 0) { $error++; diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index 6f3b63f6d4e..f149a75589f 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -25,7 +25,7 @@ if (empty($conf) || !is_object($conf)) if (!is_object($form)) $form = new Form($db); -$qtytoconsumeforline = $this->tpl['qty'] / $this->tpl['efficiency']; +$qtytoconsumeforline = $this->tpl['qty'] / ( ! empty($this->tpl['efficiency']) ? $this->tpl['efficiency'] : 1 ); /*if ((empty($this->tpl['qty_frozen']) && $this->tpl['qty_bom'] > 1)) { $qtytoconsumeforline = $qtytoconsumeforline / $this->tpl['qty_bom']; }*/