[SQL] fix currency, invoice_type and party on invoice line
UPDATE account_invoice_line SET currency = (SELECT currency FROM account_invoice WHERE id = account_invoice_line.invoice) WHERE invoice IS NOT NULL;
UPDATE account_invoice_line SET invoice_type = (SELECT type FROM account_invoice WHERE id = account_invoice_line.invoice) WHERE invoice_type IS NOT NULL AND invoice IS NOT NULL;
UPDATE account_invoice_line SET party = (SELECT party FROM account_invoice WHERE id = account_invoice_line.invoice) WHERE party IS NOT NULL AND invoice IS NOT NULL;
[SQL] before update, add access on field
ALTER TABLE ir_model_field ADD COLUMN "access" BOOLEAN;
Sorry for being picky at this point, but it seems as if there are two semicolons missing at the end of the command lines. True? For the less experienced user it is not obvious whether they are needed or not… ):
As well, to me it was not clear that commands 1-3 and 4 need to be executed in one sequence, is there any argument against putting all of the 4 lines in one box?
UPDATE account_invoice_line SET party = (SELECT party FROM account_invoice WHERE id = account_invoice_line.invoice) WHERE party IS NOT NULL;
This query set nulls to party column of the invoice lines without invoice when the module purchase_invoice_line_standalone is activated.
The following query solves the issue:
update account_invoice_line as il set party = p.party from purchase_line pl, purchase_purchase p where invoice is null and il.party is null and il.origin like 'purchase.line,%' and CAST(substring(il.origin FROM POSITION(',' in il.origin)+1) AS integer) = pl.id and p.id = pl.purchase;
Also I found some account invoice lines have not set the invoice_type. At the moment I fixed with:
UPDATE account_invoice_line SET invoice_type = 'in' WHERE invoice_type IS NULL and invoice is NULL and origin like 'purchase%';
UPDATE account_invoice_line SET invoice_type = 'out' WHERE invoice_type IS NULL and invoice is NULL and origin like 'sale%';