Comptes comptables avec trop de 0
Le code suivant change seulement les comptes avec 4 chiffres, en compte avec 3 chiffres, si le dernier chiffre est un 0.
Paramètre : mettre le trigramme de l'activité dans la requête.
-- LIST account with the following pattern XXX0
SELECT
code,
substring(code from 1 for 3)
FROM account_account
WHERE char_length(code) = 4
AND substring(code from 4 for 1) = '0'
AND company_id = (select id from res_company where code ='XXX');
-- Update account that have the following pattern XXX0, removing the leading 0
UPDATE account_account
SET code = substring(code from 1 for 3)
WHERE char_length(code) = 4
AND substring(code from 4 for 1) = '0'
AND company_id = (select id from res_company where code ='XXX');