With the code describe above I receive the follow error message:
Traceback (most recent call last):
File
"/opt/cr/local/lib/python2.7/site-packages/trytond/protocols/dispatcher.py",
line 165, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/opt/cr/local/lib/python2.7/site-packages/trytond/model/modelsql.py",
line 780, in read
getter_result = getter_results[fname]
TypeError: 'Decimal' object has no attribute '__getitem__'
February 2018, 15:55:07 (UTC-6), Josias Pérez escribió:
> Hi,
>
> I would appreciate if could tell how I can call a functional field from
> another module, in this case, I need to call the payable function field from
> account module.
>
> The code is the follow:
>
> currency_digits = fields.Function(fields.Integer('Currency Digits'),
> 'get_currency_digits')
>
> receivable = fields.Function(
> fields.Numeric('Por cobrar',
> digits=(16, Eval('currency_digits', 2)),
> depends=['currency_digits']),
> 'get_receivable_payable')
>
> @classmethod
> def get_currency_digits(cls, parties, name):
> pool = Pool()
> Company = pool.get('company.company')
> company_id = Transaction().context.get('company')
> if company_id:
> company = Company(company_id)
> digits = company.currency.digits
> else:
> digits = 2
> return {p.id: digits for p in parties}
>
> @classmethod
> def get_receivable_payable(cls, subscriptions, names):
> for subscription in subscriptions:
> if subscription.party:
> amount = subscription.party.receivable
> return amount
> else:
> return 0
>
> I'm trying to get the value of the payable field of account module. [1]
>
> Thanks in advance!
>
> [1] https://github.com/tryton/account/blob/develop/party.py#L75
--
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/fbd895a3-a327-4497-a282-3e8d7f8f7914%40googlegroups.com.