Migració 3.2 a 3.4

LLibreries

Revisar que estiguin java-7-openjdk-amd64

Pre Migració

Si tenen el mòdul survey instal·lat, cal descomentar en el DynamicModel el setup, register, post_setup.

1. Crearem el directori public_data i els enllaços simbòlics:

mkdir /home/<NOM_INSTANCIA>/tryton/www
cd /home/<NOM_INSTANCIA>/tryton/www
ln -s ../sao .
ln -s ../angular-tryton .

2. Els tornarem a instal·lar (per canvis en el repos d'estructura i branques):

3. Actualitzar config repo

4. Crear l'usuari test a PSQL "nom_test"

5. Crear el nou fitxer de configuració + nous ports + supervisor -O + fitxer logs

Migració

1. Actualitzem ja el pyme (per treure dependencies)

hg pull -u;hg checkout 3.2

2. Mirem quins mòduls que ja no ens donen suport estan instal·lats:

Eliminem dependencies:

delete from ir_module_module_dependency where name = 'account_move_party_required' and module = (select id from ir_module_module where name = 'pyme');
delete from ir_module_module_dependency where name = 'sale_payment_web' and module = (select id from ir_module_module where name = 'galatea_esale');
delete from ir_module_module_dependency where name = 'product_template_code' and module = (select id from ir_module_module where name = 'product_esale');

select * from ir_module_module where name in ('account_move_party_required','project_template','sale_project_template','ldap_connection','django','esale_sale','product_template_code','sale_asterisk', 'asset_project','product_measurements_density','purchase_request_celery', 'sale_payment_web', 'account_payment_csv', 'sale_commission', 'sale_opportunity_next_action');

3. Si tenim algún módul del punt 1, canviem a les branques "uninstall":

sudo /home/NOM/tryton/bin/python /home/NOM/tryton/bin/trytond -c /etc/trytond/.trytond_NOM -u account_move_party_required -d DB

4. Eliminem els mòduls i dependencies:

delete from ir_module_module_dependency where module in (select id from ir_module_module where name in ('account_move_party_required','project_template','sale_project_template','ldap_connection','django','esale_sale','product_template_code','sale_asterisk','asset_project','product_measurements_density','purchase_request_celery', 'asset_elevator', 'sale_payment_web', 'account_invoice_default_invoicing', 'account_payment_csv', 'sale_commission', 'sale_opportunity_next_action', 'product_esale_manufacturer', 'product_esale_purchasable'));

delete from ir_module_module where name in ('account_move_party_required','project_template','sale_project_template','ldap_connection','django','esale_sale','product_template_code','sale_asterisk','asset_project','product_measurements_density','purchase_request_celery', 'asset_elevator', 'sale_payment_web', 'account_invoice_default_invoicing', 'account_payment_csv', 'sale_commission', 'sale_opportunity_next_action', 'product_esale_manufacturer', 'product_esale_purchasable');

Si ens dona error que no troba camp fs_values, executem el SQL:

alter table ir_model_data ADD COLUMN fs_values text;

ATENCIÓ SI JA TENIM PLANTILLES:

Inserim el SQL de pyme/migrations:

Al pyme/tryton.cfg descomentem:

    electronic_mail_template_data.xml

Al finalitzar, tornem a comentar i:

postgres@CanDB4:/tmp$ psql basedades < ir_model_data.sql

I tornem actualizar el pyme

5. Canviem TOTS els mòduls a la branca "default":

6. Instal·lem els nous mòduls:

invoke install

7. Canviem la estructura del fitxer trytond.conf + logs

http://www.tryton-erp.es/posts/configuracion-servidor-tryton-34.html

Si tenen el mòdul Galatea instal·lat, cal afegir les variables al config

[galatea]
host = localhost
password = XXXXX

8. Actualitzem:

sudo /home/NOM/tryton/bin/python /home/NOM/tryton/bin/trytond -c /etc/trytond/.trytond_NOM  -c trytond.conf --all -d DB

Post Migració

1. SQL:

update country_zip set country = (select id from country_country where name = 'Spain');
ALTER TABLE "country_zip" ALTER COLUMN "country" SET NOT NULL;
ALTER TABLE "account_move" ALTER COLUMN "company" SET NOT NULL;
ALTER TABLE "account_statement" ALTER COLUMN "name" SET NOT NULL;

2. Traduccions:

Desactivar Revisió

3- Crear supervisor test

Party Required

1. Actualitzar pla de comptes + sql queries:

https://groups.google.com/d/msg/tryton-es-dev/X46VfYWWMOs/1aqrSGwBkAsJ

Pot passar que no deixi actualitzar comptes pq hi ha codis duplicats. Això és pq hi ha comptes creats amb la duplicació que conserven el lligam amb la plantilla, degut a un bug de tryton 3.0 ja solucionat. Es pot arreglar fent (alguns comptes amb el template duplicat (última select) cal fer alguna actualització manual update account_account set template=null where code='...';):

select code,template from account_account where code not like '%0' and kind!='view' and code not like '472%' and code not like '473%' and code not like '475%' and code not like '477%' and template is not null order by code;
update account_account set template= null where code not like '%0' and kind!='view' and code not like '472%' and code not like '473%' and code not like '475%' and code not like '477%' and template is not null;
select o.id,o.code from account_account o where exists ( select 'x' from account_account i where i.template = o.template and i.id < o.id);

1. Al migrar una base de datos a la versión 3.4, si se tiene instalado el account_es o el account_es_pyme se debe actualizar el plan de cuentas (a través del asistente) para que te marque las cuentas contables.

1.1. Se puede dar el caso de que en la base de datos existente, haya apuntes contables que no tienen tercero pero que con la nueva actualización deberían tenerlo. En ese caso, el asistente de actualizar plan de cuentas te da un error muy bonito, que se puede corregir con la siguiente consulta (primer arreglem apunts relacionats amb factures agafant el tercer de la factura, desprès arreglem apunts que estan conciliats agafant el tercer de l'apunt conciliat, desprès arreglem els que queden assignant-lis la pròpia empresa com a tercer):

SELECT count(*) FROM account_move_line l, account_account a, account_account_template as at, account_move m, account_invoice i WHERE l.party is null AND at.party_required=true AND l.account=a.id AND at.id = a.template AND l.move=m.id AND m.origin like 'account.invoice,%' AND substring(m.origin from 17)::numeric=i.id;

UPDATE account_move_line l SET party=sub.party FROM
(SELECT l.id,i.party FROM account_move_line l, account_account a, account_account_template as at, account_move m, account_invoice i WHERE l.party is null AND at.party_required=true AND l.account=a.id AND at.id = a.template AND l.move=m.id AND m.origin like 'account.invoice,%' AND substring(m.origin from 17)::numeric=i.id) sub
WHERE l.id=sub.id;

SELECT count(distinct(l.id)) FROM account_move_line l, account_account a, account_account_template as at, account_move_line l2 WHERE l.party is null AND at.party_required=true AND l.account=a.id AND at.id = a.template AND l.reconciliation=l2.reconciliation AND l.id!=l2.id AND l2.party is not null;

UPDATE account_move_line l SET party=sub.party FROM
(SELECT l.id,l2.party FROM account_move_line l, account_account a, account_account_template as at, account_move_line l2 WHERE l.party is null AND at.party_required=true AND l.account=a.id AND at.id = a.template AND l.reconciliation=l2.reconciliation AND l.id!=l2.id AND l2.party is not null) sub
WHERE l.id=sub.id;

SELECT a.code, ml.description FROM account_move_line as ml, account_account as a, account_account_template as at, company_company as c WHERE a.id = ml.account  AND at.id = a.template AND c.id = a.company AND at.party_required AND ml.party is null;

UPDATE account_move_line as ml SET party = c.party
FROM account_account as a,
     account_account_template as at,
     company_company as c
WHERE
a.id = ml.account  AND
at.id = a.template AND
c.id = a.company AND
at.party_required AND
ml.party is null; 

1.2. Actualizamos el plan contable mediante cliente Tryton

1.3 (NOTA IMPORTANT: No aplicar si els mòduls pyme o account_reconcile_different_party estan instal·lats, per no perdre informació interessant). Se puede dar el caso inverso, que existan movimientos de cuentas no marcadas cómo party_required que tengan el tercero establecido. En ese caso, nos dará un error de dominio si modificamos algun campo de la línea. Lo podemos corregir con la siguiente consulta:

select count(*) from account_move_line as ml, account_account as a WHERE a.id = ml.account  AND not COALESCE(a.party_required, False) AND ml.party is not null;
select distinct(a.code) from account_move_line as ml, account_account as a WHERE a.id = ml.account  AND not COALESCE(a.party_required, False) AND ml.party is not null order by a.code;

UPDATE account_move_line as ml SET party = null
FROM account_account as a
WHERE
a.id = ml.account  AND
not COALESCE(a.party_required, False) AND
ml.party is not null; 

Detectar i corregir apunts de comptes amb tercer requerit desprès d'actualitzar pla comptable

Corregir apuntes contables que no tienen tercero pero que deberían tenerlo. https://bugs.tryton.org/issue4465

SELECT count(*) FROM account_move_line l, account_account a, account_move m, account_invoice i WHERE l.party is null AND party_required=true AND l.account=a.id AND l.move=m.id AND m.origin like 'account.invoice,%' AND substring(m.origin from 17)::numeric=i.id;

UPDATE account_move_line l SET party=sub.party FROM
(SELECT l.id,i.party FROM account_move_line l, account_account a, account_move m, account_invoice i WHERE l.party is null AND party_required=true AND l.account=a.id AND l.move=m.id AND m.origin like 'account.invoice,%' AND substring(m.origin from 17)::numeric=i.id) sub
WHERE l.id=sub.id;

SELECT count(distinct(l.id)) FROM account_move_line l, account_account a, account_move_line l2 WHERE l.party is null AND party_required=true AND l.account=a.id AND l.reconciliation=l2.reconciliation AND l.id!=l2.id AND l2.party is not null;

UPDATE account_move_line l SET party=sub.party FROM
(SELECT l.id,l2.party FROM account_move_line l, account_account a, account_move_line l2 WHERE l.party is null AND party_required=true AND l.account=a.id AND l.reconciliation=l2.reconciliation AND l.id!=l2.id AND l2.party is not null) sub
WHERE l.id=sub.id;

SELECT count(distinct(l.id)) FROM account_move_line l, account_account a, account_move_line l2 WHERE l.party is null AND party_required=true AND l.account=a.id AND a.code like '57%00%' AND l.move=l2.move AND l.id!=l2.id AND l2.party is not null;

UPDATE account_move_line l SET party=sub.party FROM
(SELECT l.id,l2.party FROM account_move_line l, account_account a, account_move_line l2 WHERE l.party is null AND party_required=true AND l.account=a.id AND code like '57%00%' AND l.move=l2.move AND l.id!=l2.id AND l2.party is not null) sub
WHERE l.id=sub.id;

SELECT count(*) FROM account_move_line l, account_account a WHERE party is null AND party_required=true AND l.account=a.id;

UPDATE account_move_line as ml SET party = c.party
FROM account_account as a,
     company_company as c
WHERE
a.id = ml.account  AND
c.id = a.company AND
a.party_required AND
ml.party is null;

Migracio3.2-3.4 (last edited 2016-02-25 16:31:24 by jesteve)

Contenidos creados por el equipo de Zikzakmedia. Creative Commons By-NC-SA

PythonZikzakmedia