Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ For users:
----------


* NEW: Ajout de la permission "Consulter les prix d'achat" pour permettre la consultation des prix fournisseurs sans droit de création.

For developers:
---------------
Expand Down
9 changes: 5 additions & 4 deletions htdocs/core/lib/product.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@
$langs->load("products");

$label = $langs->trans('Product');
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_prices') : $user->hasRight('product', 'read');
$usercancreadsupplierprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_supplier_prices') : $user->hasRight('product', 'read');
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_prices') : $user->hasRight('product', 'read');

Check failure on line 46 in htdocs/core/lib/product.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Tabs must be used to indent lines; spaces are not allowed
// Allow supplier price consultation with dedicated permission when advanced rights are enabled / Permet la consultation des prix fournisseurs avec la permission dédiée lorsque les droits avancés sont activés

Check failure on line 47 in htdocs/core/lib/product.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Tabs must be used to indent lines; spaces are not allowed
$usercancreadsupplierprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? ($user->hasRight('product', 'product_advance', 'read_supplier_prices') || $user->hasRight('product', 'product_advance', 'consult_supplier_prices')) : $user->hasRight('product', 'read');

Check failure on line 48 in htdocs/core/lib/product.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Tabs must be used to indent lines; spaces are not allowed

if ($object->isService()) {
$label = $langs->trans('Service');
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('service', 'service_advance', 'read_prices') : $user->hasRight('service', 'read');
$usercancreadsupplierprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('service', 'service_advance', 'read_supplier_prices') : $user->hasRight('service', 'read');
$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('service', 'service_advance', 'read_prices') : $user->hasRight('service', 'read');

Check failure on line 52 in htdocs/core/lib/product.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Tabs must be used to indent lines; spaces are not allowed
$usercancreadsupplierprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? ($user->hasRight('service', 'service_advance', 'read_supplier_prices') || $user->hasRight('service', 'service_advance', 'consult_supplier_prices')) : $user->hasRight('service', 'read');

Check failure on line 53 in htdocs/core/lib/product.lib.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Tabs must be used to indent lines; spaces are not allowed
}

$h = 0;
Expand Down
23 changes: 16 additions & 7 deletions htdocs/core/modules/modProduct.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,22 @@
$this->rights[$r][5] = 'read_prices';
$r++;

$this->rights[$r][0] = 35; // id de la permission
$this->rights[$r][1] = 'Read supplier prices'; // libelle de la permission
$this->rights[$r][2] = 'w'; // type de la permission (deprecated)
$this->rights[$r][3] = 0; // La permission est-elle une permission par default
$this->rights[$r][4] = 'product_advance';
$this->rights[$r][5] = 'read_supplier_prices';
$r++;
$this->rights[$r][0] = 35; // id de la permission

Check failure on line 141 in htdocs/core/modules/modProduct.class.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Tabs must be used to indent lines; spaces are not allowed
$this->rights[$r][1] = 'Read supplier prices'; // libelle de la permission

Check failure on line 142 in htdocs/core/modules/modProduct.class.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Tabs must be used to indent lines; spaces are not allowed
$this->rights[$r][2] = 'w'; // type de la permission (deprecated)

Check failure on line 143 in htdocs/core/modules/modProduct.class.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Tabs must be used to indent lines; spaces are not allowed
$this->rights[$r][3] = 0; // La permission est-elle une permission par default

Check failure on line 144 in htdocs/core/modules/modProduct.class.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Tabs must be used to indent lines; spaces are not allowed
$this->rights[$r][4] = 'product_advance';

Check failure on line 145 in htdocs/core/modules/modProduct.class.php

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Tabs must be used to indent lines; spaces are not allowed
$this->rights[$r][5] = 'read_supplier_prices';
$r++;

// Allow consulting supplier buying prices when advanced rights are enabled / Permet de consulter les prix d'achat fournisseurs quand les droits avancés sont activés
$this->rights[$r][0] = 36; // id de la permission
$this->rights[$r][1] = 'PermissionConsultSupplierBuyingPrices'; // libelle de la permission
$this->rights[$r][2] = 'r'; // type de la permission (deprecated)
$this->rights[$r][3] = 0; // La permission est-elle une permission par default
$this->rights[$r][4] = 'product_advance';
$this->rights[$r][5] = 'consult_supplier_prices';
$r++;

$this->rights[$r][0] = 34; // id de la permission
$this->rights[$r][1] = 'Delete products'; // libelle de la permission
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/products.lang
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ ProductIsUsed=This product is used
NewRefForClone=Ref. of new product/service
SellingPrices=Selling prices
BuyingPrices=Buying prices
PermissionConsultSupplierBuyingPrices=View supplier buying prices
CustomerPrices=Customer prices
SuppliersPrices=Vendor prices
SuppliersPricesOfProductsOrServices=Vendor prices (of products or services)
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/fr_FR/products.lang
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ ProductIsUsed=Ce produit est utilisé
NewRefForClone=Réf. du nouveau produit/service
SellingPrices=Prix de vente
BuyingPrices=Prix d'achat
PermissionConsultSupplierBuyingPrices=Consulter les prix d'achat
CustomerPrices=Prix clients
SuppliersPrices=Prix fournisseurs
SuppliersPricesOfProductsOrServices=Prix fournisseurs (des produits ou services)
Expand Down
35 changes: 28 additions & 7 deletions htdocs/product/price_suppliers.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,37 @@

$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'lire')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire')));
$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer')));
// Allow supplier price consultation right without creation capability / Permet la consultation des prix fournisseurs sans droit de création
$usercanconsultsuppliers = (bool) $usercancreate;
if ($prod->id > 0) {
if ($prod->type == Product::TYPE_PRODUCT) {
if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
$usercanconsultsuppliers = $usercanconsultsuppliers || $user->hasRight('product', 'product_advance', 'read_supplier_prices') || $user->hasRight('product', 'product_advance', 'consult_supplier_prices');
} else {
$usercanconsultsuppliers = $usercanconsultsuppliers || $user->hasRight('produit', 'lire');
}
} elseif ($prod->type == Product::TYPE_SERVICE) {
if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
$usercanconsultsuppliers = $usercanconsultsuppliers || $user->hasRight('service', 'service_advance', 'read_supplier_prices') || $user->hasRight('service', 'service_advance', 'consult_supplier_prices');
} else {
$usercanconsultsuppliers = $usercanconsultsuppliers || $user->hasRight('service', 'lire');
}
}
}

if ($object->id > 0) {
if ($object->type == $object::TYPE_PRODUCT) {
restrictedArea($user, 'produit', $object->id, 'product&product', '', '');
}
if ($object->type == $object::TYPE_SERVICE) {
restrictedArea($user, 'service', $object->id, 'product&product', '', '');
}
if ($object->type == $object::TYPE_PRODUCT) {
restrictedArea($user, 'produit', $object->id, 'product&product', '', '');
}
if ($object->type == $object::TYPE_SERVICE) {
restrictedArea($user, 'service', $object->id, 'product&product', '', '');
}
} else {
restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
}

if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty($usercanconsultsuppliers)) {
accessforbidden();
}


Expand Down
Loading