After upgrade "Method" not callable

20 views
Skip to first unread message

Hendrik Brandes

unread,
Jun 23, 2018, 5:40:06 PM6/23/18
to tryton-dev
Hello,

I tried to migrate an existing tryton installation and get the following error:

AssertionError: <class 'trytond.pool.sale.line'>.margin not callable

The definition of the field looks like this:

margin = fields.Function(fields.Numeric('Margin',
digits=(16, Eval('_parent_sale', {}).get('currency_digits', 2)),
states={
'invisible': ~Eval('type').in_(['line', 'subtotal']),
'readonly': ~Eval('_parent_sale'),
},
depends=['type', 'amount']),
'on_change_with_margin')

and for the implementation:

@fields.depends('type', 'amount', 'quantity', 'cost_price', '_parent_sale.currency',
'_parent_sale.lines')
def on_change_with_margin(self):
'''
Return the margin of each sale lines
'''
...

I thought, that it is enough, to declare all fields, which are used within the method.

Actual, I have read the documentation and saw, that the dependency of fields has been introduced, but I cannot understand, what is missing concretely in this case.

Thank you and best regards,
Hendrik Brandes

Cédric Krier

unread,
Jun 23, 2018, 5:55:05 PM6/23/18
to tryton-dev
On 2018-06-23 09:31, 'Hendrik Brandes' via tryton-dev wrote:
> I tried to migrate an existing tryton installation and get the following error:
>
> AssertionError: <class 'trytond.pool.sale.line'>.margin not callable

What is the traceback?

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

Hendrik Brandes

unread,
Jun 25, 2018, 3:30:06 AM6/25/18
to tryton-dev
Am Samstag, 23. Juni 2018 23:55:05 UTC+2 schrieb Cédric Krier:
> On 2018-06-23 09:31, 'Hendrik Brandes' via tryton-dev wrote:
> > I tried to migrate an existing tryton installation and get the following error:
> >
> > AssertionError: <class 'trytond.pool.sale.line'>.margin not callable
>
> What is the traceback?

I started the trytond-admin command with parameter --all and finally got the following traceback:

Traceback (most recent call last):
File "/opt/projekte/git/tryton2018/EBBTryton2018/bin/trytond-admin", line 21, in <module>
admin.run(options)
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/admin.py", line 54, in run
activatedeps=options.activatedeps)
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/pool.py", line 162, in init
lang=lang, activatedeps=activatedeps)
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/modules/__init__.py", line 406, in load_modules
_load_modules(update)
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/modules/__init__.py", line 376, in _load_modules
load_module_graph(graph, pool, update, lang)
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/modules/__init__.py", line 165, in load_module_graph
pool.setup(classes)
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/pool.py", line 236, in setup
cls.__setup__()
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/modules/sale_margin/sale.py", line 109, in __setup__
super(SaleLine, cls).__setup__()
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/modules/sale_price_list/sale.py", line 49, in __setup__
super(SaleLine, cls).__setup__()
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/modules/sale_discount/sale.py", line 56, in __setup__
super(SaleLine, cls).__setup__()
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/modules/sale/sale.py", line 1120, in __setup__
super(SaleLine, cls).__setup__()
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/model/order.py", line 15, in __setup__
super(SequenceOrderedMixin, cls).__setup__()
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/model/modelsql.py", line 164, in __setup__
super(ModelSQL, cls).__setup__()
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/model/modelstorage.py", line 59, in __setup__
super(ModelStorage, cls).__setup__()
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/model/modelview.py", line 194, in __setup__
setup_field(name, field, attribute)
File "/opt/projekte/git/tryton2018/EBBTryton2018/trytond/model/modelview.py", line 175, in setup_field
"%s.%s not callable" % (cls, meth_name)
AssertionError: <class 'trytond.pool.sale.line'>.margin not callable



>

Cédric Krier

unread,
Jun 25, 2018, 3:40:05 AM6/25/18
to tryton-dev
This looks like you have defined 'margin' in the methods argument of
fields.depends. Something like: @fields.depends(methods=['margin'])
But margin is a field not a method, so it should be:
@fields.depends('margin')

Hendrik Brandes

unread,
Jun 28, 2018, 4:40:05 AM6/28/18
to tryton-dev
Thank you! That did it, I looked inside the margin-field declaration, but it was in another field, which had this declaration inside.
Reply all
Reply to author
Forward
0 new messages