This happens in both 1.3, and 1.4. Most vendor and customer invoices open fine. However, after updating to the tip of 1.3 and 1.4, when I attempt to open any vendor invoice from a particular vendor, I get an error.
Steps:
For any of this particular vendor's invoices, I get this error (1.4):
SELECT i.id as invoice_id,
coalesce(i.vendor_sku, p.partnumber)
as partnumber,
i.description, i.qty,
i.fxsellprice, i.sellprice, i.precision,
i.parts_id AS id, i.unit, p.bin,
i.deliverydate,
i.serialnumber,
i.discount, i.notes, pg.partsgroup,
p.partsgroup_id, p.partnumber AS sku,
p.weight, p.onhand, p.inventory_accno_id,
p.income_accno_id, p.expense_accno_id,
t.description AS partsgrouptranslation
FROM invoice i
JOIN parts p ON (i.parts_id = p.id)
LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id)
LEFT JOIN translation t
ON (t.trans_id = p.partsgroup_id
AND t.language_code = ?)
WHERE i.trans_id = ?
ORDER BY i.id
called with 3 bind variables when 2 are needed at LedgerSMB/IR.pm line 1174
'
dbversion: 1.4.5, company: ...
... or 1.3:
Error!
SELECT i.id as invoice_id,
coalesce(i.vendor_sku, p.partnumber)
as partnumber,
i.description, i.qty,
i.fxsellprice, i.sellprice, i.precision,
i.parts_id AS id, i.unit, p.bin,
i.deliverydate,
pr.projectnumber, i.project_id,
i.serialnumber,
i.discount, i.notes, pg.partsgroup,
p.partsgroup_id, p.partnumber AS sku,
p.weight, p.onhand, p.inventory_accno_id,
p.income_accno_id, p.expense_accno_id,
t.description AS partsgrouptranslation
FROM invoice i
JOIN parts p ON (i.parts_id = p.id)
LEFT JOIN project pr ON (i.project_id = pr.id)
LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id)
LEFT JOIN translation t
ON (t.trans_id = p.partsgroup_id
AND t.language_code = ?)
WHERE i.trans_id = ?
ORDER BY i.id
called with 3 bind variables when 2 are needed
This is a regression caused by the fix for #1260.
On my 1.3 instance, checking out LedgerSMB/IR.pm from the previous commit fixes the issue.
I see in the 1.4 instance, the query being prepared has two lines removed, one of which contains a placeholder. So removing the parameter from the database call appears to fix the issue:
(edit: fixing formatting)
Last edit: John Locke 2014-10-29
... and here's the corresponding patch for 1.3:
~~~~~~~~~~~
diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm
index 9ae8c26..530628a 100644
--- a/LedgerSMB/IR.pm
+++ b/LedgerSMB/IR.pm
@@ -1282,7 +1282,7 @@ sub retrieve_invoice {
WHERE i.trans_id = ?
ORDER BY i.id|;
$sth = $dbh->prepare($query);
|| $form->dberror($query);
~~~~~~~~~~~~
Istvan, Chris, can you review and let me know if this is the appropriate fix?
I recall these patches being applied.