Re: [tryton] why doesn' t this field get assigned ?

2018-01-13 Thread Cédric Krier
On 2018-01-13 01:31, Cato Nano wrote:
> Il giorno venerdì 12 gennaio 2018 23:45:06 UTC+1, Cédric Krier ha scritto:
> > On 2018-01-10 09:03, Cato Nano wrote:
> > > I have these 2 fields
> > > 
> > > numeroGiorni = fields.Function(fields.Integer('Numero 
> > > Giorni'),'on_change_with_numeroGiorni')
> > > @fields.depends('dataInizio', 'dataFine')
> > > def on_change_with_numeroGiorni(self, name=None):
> > > if self.dataInizio and self.dataFine:
> > > return abs((self.dataFine - self.dataInizio).days) + 1
> > > return 0
> > > 
> > > [...]
> > > 
> > > fattoreGiorni = fields.Function(fields.Numeric('fattoreGiorni'), 
> > > 'on_change_with_fattoreGiorni')
> > > 
> > > @fields.depends('numeroGiorni')
> > > def on_change_with_fattoreGiorni(self, name=None):
> > > return (self.numeroGiorni - 10) / 5
> > > 
> > > 
> > > fattoreGiorni DOESN'T get assigned
> > > I can't see why
> > 
> > It is difficult to answer without having more information about the
> > scenario you are following.
> > 
> > But already there are some potential issues like using the value of a
> > field without checking if it is not 'None'.
> > Also be aware that Function fields does not trigger other on_change*,
> > indeed you must make the other one depending on the first one. It should
> > look like that:
> > 
> > @fields.depends(methods='numeroGiorni')

@fields.depends(methods=['numeroGiorni'])

> > def on_change_with_fattoreGiorni(self, name=None):
> > numeroGiorni = self.on_change_with_numeroGiorni()
> > return (numeroGiorni - 10) / 5
> > 
> 
> 
> So with this variant of yours, when I issue
> 
> trytond-admin -c ./trytond.conf -d tryton -u tributi
> 
> 
> I get these errors
> 
> Traceback (most recent call last):
>   File "/home/catonano/tributi/env/bin/trytond-admin", line 21, in 
> admin.run(options)
>   File 
> "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/admin.py", 
> line 54, in run
> installdeps=options.installdeps)
>   File 
> "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/pool.py", 
> line 153, in init
> lang=lang, installdeps=installdeps)
>   File 
> "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py",
>  line 462, in load_modules
> _load_modules(update)
>   File 
> "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py",
>  line 432, in _load_modules
> load_module_graph(graph, pool, update, lang)
>   File 
> "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py",
>  line 229, in load_module_graph
> pool.setup(classes)
>   File 
> "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/pool.py", 
> line 227, in setup
> cls.__post_setup__()
>   File 
> "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/model/modelview.py",
>  line 195, in __post_setup__
> other_field = getattr(cls, other)
> AttributeError: type object 'tributi.affissione' has no attribute 'i'

See correction above.

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: cedric.kr...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/20180113100105.GG4227%40kei.


Re: [tryton] why doesn' t this field get assigned ?

2018-01-13 Thread Cato Nano
Il giorno venerdì 12 gennaio 2018 23:45:06 UTC+1, Cédric Krier ha scritto:
> On 2018-01-10 09:03, Cato Nano wrote:
> > I have these 2 fields
> > 
> > numeroGiorni = fields.Function(fields.Integer('Numero 
> > Giorni'),'on_change_with_numeroGiorni')
> > @fields.depends('dataInizio', 'dataFine')
> > def on_change_with_numeroGiorni(self, name=None):
> > if self.dataInizio and self.dataFine:
> > return abs((self.dataFine - self.dataInizio).days) + 1
> > return 0
> > 
> > [...]
> > 
> > fattoreGiorni = fields.Function(fields.Numeric('fattoreGiorni'), 
> > 'on_change_with_fattoreGiorni')
> > 
> > @fields.depends('numeroGiorni')
> > def on_change_with_fattoreGiorni(self, name=None):
> > return (self.numeroGiorni - 10) / 5
> > 
> > 
> > fattoreGiorni DOESN'T get assigned
> > I can't see why
> 
> It is difficult to answer without having more information about the
> scenario you are following.
> 
> But already there are some potential issues like using the value of a
> field without checking if it is not 'None'.
> Also be aware that Function fields does not trigger other on_change*,
> indeed you must make the other one depending on the first one. It should
> look like that:
> 
> @fields.depends(methods='numeroGiorni')
> def on_change_with_fattoreGiorni(self, name=None):
> numeroGiorni = self.on_change_with_numeroGiorni()
> return (numeroGiorni - 10) / 5
> 


So with this variant of yours, when I issue

trytond-admin -c ./trytond.conf -d tryton -u tributi


I get these errors

Traceback (most recent call last):
  File "/home/catonano/tributi/env/bin/trytond-admin", line 21, in 
admin.run(options)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/admin.py", line 
54, in run
installdeps=options.installdeps)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/pool.py", line 
153, in init
lang=lang, installdeps=installdeps)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py",
 line 462, in load_modules
_load_modules(update)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py",
 line 432, in _load_modules
load_module_graph(graph, pool, update, lang)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py",
 line 229, in load_module_graph
pool.setup(classes)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/pool.py", line 
227, in setup
cls.__post_setup__()
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/model/modelview.py",
 line 195, in __post_setup__
other_field = getattr(cls, other)
AttributeError: type object 'tributi.affissione' has no attribute 'i'



and


Traceback (most recent call last):
  File "/home/catonano/tributi/env/bin/trytond-admin", line 21, in 
admin.run(options)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/admin.py", line 
54, in run
installdeps=options.installdeps)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/pool.py", line 
153, in init
lang=lang, installdeps=installdeps)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py",
 line 462, in load_modules
_load_modules(update)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py",
 line 432, in _load_modules
load_module_graph(graph, pool, update, lang)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py",
 line 229, in load_module_graph
pool.setup(classes)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/pool.py", line 
227, in setup
cls.__post_setup__()
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/model/modelview.py",
 line 195, in __post_setup__
other_field = getattr(cls, other)
AttributeError: type object 'tributi.affissione' has no attribute 'n'



and

Traceback (most recent call last):
  File "/home/catonano/tributi/env/bin/trytond-admin", line 21, in 
admin.run(options)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/admin.py", line 
54, in run
installdeps=options.installdeps)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/pool.py", line 
153, in init
lang=lang, installdeps=installdeps)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py",
 line 462, in load_modules
_load_modules(update)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py",
 line 432, in _load_modules
load_module_graph(graph, pool, update, lang)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py",
 line 229, in load_module_graph
pool.setup(classes)
  File 
"/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/pool.

Re: [tryton] Proteus

2018-01-13 Thread Cédric Krier
On 2018-01-12 23:16, Cato Nano wrote:
> Today the error message is different. Yesterday I probably messed up because 
> I was tired, it happens
> 
> So here I am now
> 
> >>> from proteus import config, Model, Wizard, Report 
> >>> config = config.set_trytond('sqlite:///:memory:') 
> /home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py:143:
>  DeprecationWarning: This method will be removed in future versions.  Use 
> 'parser.read_file()' instead.
>   module_config.readfp(fp)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File 
> "/home/catonano/tributi/env/lib/python3.6/site-packages/proteus/config.py", 
> line 274, in set_trytond
> _CONFIG.current = TrytondConfig(database, user, config_file=config_file)
>   File 
> "/home/catonano/tributi/env/lib/python3.6/site-packages/proteus/config.py", 
> line 228, in __init__
> self.pool.init()
>   File 
> "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/pool.py", 
> line 153, in init
> lang=lang, installdeps=installdeps)
>   File 
> "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/modules/__init__.py",
>  line 461, in load_modules
> with Transaction().start(database_name, 0):
>   File 
> "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/transaction.py",
>  line 106, in start
> Cache.clean(database.name)
>   File 
> "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/cache.py", 
> line 111, in clean
> cursor.execute(*table.select(table.timestamp, table.name))
> sqlite3.OperationalError: no such table: ir_cache

Now you are connecting to a database that was not setup:
http://doc.tryton.org/4.6/trytond/doc/topics/setup_database.html#topics-setup-database

For memory database, you can use create_db from
trytond.tests.test_tryton like it is done for the test.
Indeed the README is not useful: https://bugs.tryton.org/issue7056

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: cedric.kr...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/20180113085900.GF4227%40kei.