Le 20/04/2018 à 11:35, Sergi Almacellas Abellana a écrit :
You can use the following code to get the db ids: pool = Pool() ModelData = pool.get('ir.model.data') db_id = ModelData.get_id('account_fr', 'creances_autres') And then you can get the type of your company with: Type = pool.get('account.type') type, = Type.search([('company', '=', company.id), ('template', '=', db_id)])
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? -- 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/68a6d8e7-be89-0b41-8de2-959f181cfa85%40netbsd.org.