Hello I need to use tryton account-syscohada-7.2 in tryton 6.0 version.
I have actually managed to add the syscohada module inside tryton when using Gnuhealth.
When selecting an accounting account by default I choose syscoha but then I get this error.
Traceback (most recent call last):
File "/trytond/wsgi.py", line 117, in dispatch_request
return endpoint(request, **request.view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/protocols/dispatcher.py", line 46, in rpc
return methods.get(request.rpc_method, _dispatch)(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/wsgi.py", line 84, in auth_required
return wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/protocols/wrappers.py", line 181, in wrapper
return func(request, pool, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/protocols/dispatcher.py", line 180, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/wizard/wizard.py", line 313, in execute
return wizard._execute(state_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/wizard/wizard.py", line 344, in _execute
result = self._execute(transition())
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/wizard/wizard.py", line 324, in _execute
defaults = state.get_defaults(self, state_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/trytond/wizard/wizard.py", line 95, in get_defaults
defaults.update(default(fields))
^^^^^^^^^^^^^^^
File "/trytond/modules/account_syscohada/account.py", line 23, in default_properties
defaults['account_receivable'] = self.get_account(
^^^^^^^^^^^^^^^^
AttributeError: 'account.create_chart' object has no attribute 'get_account'. Did you mean: 'create_account'?
Trytond-account which is currently linked to syscohada has the get_account function. but in the trytond-syscohada module, there is another file account.py which contains elements of trytond-account. I’m talking about this code in syscohada’s account.py:
class CreateChart(metaclass=PoolMeta):
__name__ = 'account.create_chart'
def default_properties(self, fields):
pool = Pool()
ModelData = pool.get('ir.model.data')
defaults = super().default_properties(fields)
for lang in ['fr']:
for version in ['2001', '2016']:
try:
template_id = ModelData.get_id(
'account_syscohada.root_%s_%s' % (version, lang))
except KeyError:
continue
if self.account.account_template.id == template_id:
defaults['account_receivable'] = self.get_account(
'account_syscohada.4111_%s_%s' % (version, lang))
defaults['account_payable'] = self.get_account(
'account_syscohada.4011_%s_%s' % (version, lang))
break
return defaults
However, in trytond-account 6.0 we have identical references:
def get_account(self, template_id):
pool = Pool()
Account = pool.get('account.account')
ModelData = pool.get('ir.model.data')
template_id = ModelData.get_id(template_id)
account, = Account.search([
('template', '=', template_id),
('company', '=', self.account.company.id),
], limit=1)
return account.id
def default_properties(self, fields):
pool = Pool()
Account = pool.get('account.account')
defaults = {
'company': self.account.company.id,
}
receivable_accounts = Account.search([
('type.receivable', '=', True),
('company', '=', self.account.company.id),
], limit=2)
payable_accounts = Account.search([
('type.payable', '=', True),
('company', '=', self.account.company.id),
], limit=2)
if len(receivable_accounts) == 1:
defaults['account_receivable'] = receivable_accounts[0].id
else:
defaults['account_receivable'] = None
if len(payable_accounts) == 1:
defaults['account_payable'] = payable_accounts[0].id
else:
defaults['account_payable'] = None
return defaults
I know that integration and mixing versions is not recommended, but I can’t find a stable version of syscohada…
I would like to know how to read the get_account information from trytond-account inside syscohada.
Thank you for your answer