diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8dc60dd6812..7b3ea585ba2 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -23,6 +23,7 @@ * Copyright (C) 2023 Nick Fragoulis * Copyright (C) 2024-2025 MDW * Copyright (C) 2024-2025 Frédéric France + * Copyright (C) 2025 Lenin Rivas * * 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 @@ -2447,12 +2448,12 @@ class Facture extends CommonInvoice /** * Load all detailed lines into this->lines * - * @param int $only_product Return only physical products + * @param int $only_type_product Return only for type products * @param int $loadalsotranslation Return translation for products * * @return int 1 if OK, < 0 if KO */ - public function fetch_lines($only_product = 0, $loadalsotranslation = 0) + public function fetch_lines($only_type_product = '', $loadalsotranslation = 0) { global $conf, $extrafields; @@ -2517,6 +2518,9 @@ class Facture extends CommonInvoice $sql .= ' LEFT JOIN '.$this->db->prefix().'product as p ON l.fk_product = p.rowid'; $sql .= ' WHERE l.fk_facture = '.((int) $this->id); + if (is_int($only_type_product)) { + $sql .= ' AND p.fk_product_type='.$only_type_product; + } $sql .= ' ORDER BY l.rang, l.rowid'; dol_syslog(get_class($this).'::fetch_lines', LOG_DEBUG);