diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f6fac3811c4..e50ddfbc420 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1276,6 +1276,12 @@ class Facture extends CommonInvoice $this->db->begin(); $object->fetch($fromid); + // fetch() clears $object->thirdparty, but the subsequent $object->create() path + // reaches addLine() -> getLocalTaxesFromRate() -> get_localtax() and uses the + // buyer thirdparty to decide whether IRPF/localtax2 applies. Without this fetch, + // get_localtax() sees $thirdparty_buyer = null, returns 0 and the cloned lines + // lose their localtax2_tx (see issue #29052). + $object->fetch_thirdparty(); // Load source object $objFrom = clone $object;