Le 20/04/2018 à 20:22, Richard PALO a écrit :
Le 20/04/2018 à 20:15, Richard PALO a écrit :


Thanks, I'm finding the correct account.account.type instance now with
the following simplified snippet:
        md, = ModelData.find(['fs_id', '=', data[-1]])
        at, = AccountType.find(['template', '=', md.db_id])

But import_data() still balks...

Doesn't seem to like either at.id nor str(at.id)

Looked a bit at the code, which suggests that .rec_name should be used,
but that fails as well

        data[-1] = at.rec_name
        Account.import_data(header, [data], Account._config.context)


The exception message, which is for a type 'provisions_charges',
the first record in my file, gives:
trytond.exceptions.UserError: ('UserError', ("Relation not found: 'Plan de types de 
compte (France)\\\\Passif\\\\Provisions\\\\Provisions                   >pour charges' in 
account.account.type", ''))
The updated 'data' record is as follows:
['158200', 'Provisions pour risques et charges litiges', 'True', '158200', 
'other', '158', '', '', 'True', 'Plan de types de compte
(France)\\Passif\\Provisions\\Provisions pour charges']

I'm wondering if it's a quoting problem returned from rec_name?

Any suggestions?


BTW, It's choking in import_data's get_many2one()


Unless I'm missing something, this can not work currently.

The query generated to lookup 'rec_name' uses the simple 'name' :
'SELECT "a"."id" AS "id", "a"."balance_sheet" AS "balance_sheet", "a"."company" AS "company", "a"."create_date" AS "create_date", "a"."create_uid" AS "create_uid", "a"."display_balance" AS "display_balance", "a"."income_statement" AS "income_statement", "a"."name" AS "name", "a"."parent" AS "parent", "a"."sequence" AS "sequence", "a"."template" AS "template", "a"."write_date" AS "write_date", "a"."write_uid" AS "write_uid", CAST(EXTRACT(%s FROM COALESCE("a"."write_date", "a"."create_date")) AS VARCHAR) AS "_timestamp" FROM "account_account_type" AS "a" WHERE (((("a"."name" = %s))) AND ((("a"."company" IN (%s))))) ORDER BY "a"."sequence" ASC NULLS FIRST, "a"."id" ASC LIMIT 2'

but get_rec_name() returns the hierarchy of names when there is a parent type,
case not treated for but which is *always* the case for account_account_type.

If I set on the header 'type:id', then the lookup seems to expect the 
identifier of
the account_account_type_template and not the instance of it in 
account_account_type
as it invokes ModelData.get_id() much like Sergi mentioned (and must be 
specified
like 'account_fr.provisions_charges'

This seems to imply indirectly what I feared in that the simple name *must* be 
unique
else the supporting code must know about treating for hierarchical names
and/or know about treating the instantiated template tables
and/or have a means to stipulate that the db 'id' is supplied for relations
(something like 'type:dbid').

cheers,
--
Richard PALO

--
You received this message because you are subscribed to the Google Groups 
"tryton-dev" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton-dev/d5cfeb94-ff1e-9875-1236-6f9e38d06f01%40netbsd.org.

Reply via email to