Error adding tax in sales automatically

Hello, I started with tryton (5.8) a few days ago and have a problem adding tax to sales automatically. The first steps I already made were importing German SKR03 account template, adding a company and a product with a category containing the tax (“Umsatzsteuer-Normalsatz”). When I create a sale and add a product to the sale line I get the following error:

AttributeError: ‘account.tax’ Model has no attribute ‘sequence’: None

On the taxes tab of this line an empty entry is added, when I try to save the line i get the message “The values of “Taxes” are not valid”. If a add the tax manually there is no problem, the tax is added correctly.

I tried to add a sequence to the taxes (also to “Umsatzsteuer-Normalsatz”) but this didn’t work. Thanks for your help.

Without the full traceback it is difficult to answer.

Thanks for your quick reply. Here is the traceback:

Traceback (most recent call last):
  File "/trytond/model/model.py", line 282, in __getattr__
    return self._values[name]
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/trytond/wsgi.py", line 116, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/dispatcher.py", line 48, in rpc
    request, database_name, *request.rpc_params)
  File "/wrapt/wrappers.py", line 567, in __call__
    args, kwargs)
  File "/trytond/wsgi.py", line 83, in auth_required
    return wrapped(*args, **kwargs)
  File "/trytond/protocols/wrappers.py", line 131, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/dispatcher.py", line 186, in _dispatch
    result = rpc.result(meth(inst, *c_args, **c_kwargs))
  File "/trytond/model/modelview.py", line 780, in on_change
    method()
  File "/trytond/model/modelview.py", line 88, in wrapper
    result = func(self, *args, **kwargs)
  File "/trytond/model/fields/field.py", line 118, in wrapper
    return func(self, *args, **kwargs)
  File "/trytond/modules/sale/sale.py", line 477, in on_change_lines
    self.tax_amount = self.get_tax_amount()
  File "/trytond/model/fields/field.py", line 118, in wrapper
    return func(self, *args, **kwargs)
  File "/trytond/modules/sale/sale.py", line 504, in get_tax_amount
    (v['amount'] for v in self._get_taxes().values()), Decimal(0))
  File "/trytond/model/fields/field.py", line 118, in wrapper
    return func(self, *args, **kwargs)
  File "/trytond/modules/account/tax.py", line 1173, in _get_taxes
    line.quantity, line.tax_date or self.tax_date)
  File "/trytond/modules/account/tax.py", line 1017, in compute
    taxes = cls.sort_taxes(taxes)
  File "/trytond/modules/account/tax.py", line 1002, in sort_taxes
    return sorted(taxes, key=key, reverse=reverse)
  File "/trytond/modules/account/tax.py", line 1001, in key
    return 0 if tax.sequence is None else 1, tax.sequence or 0, tax.id
  File "/trytond/model/modelstorage.py", line 1414, in __getattr__
    return super(ModelStorage, self).__getattr__(name)
  File "/trytond/model/model.py", line 285, in __getattr__
    % (self.__name__, name, self._values))
AttributeError: 'account.tax' Model has no attribute 'sequence': None

Have you any custom module? Because I think there are some code that wrongly create a new tax to add to the line instead of link existing tax.

No, I installed via pip and only added the sales module. I also imported the countries and currencies. Should I try a new installation?

The behavior is very strange and I can not reproduce it.
Could you provide the RPC log of the client (request and result) from when you create the sale line up to the error?

Are you sure to use sao from the same series? Because it looks like you do not have the sao changes from Issue 4140: Missing delete in on_change keywords - Tryton issue tracker but the trytond.

Thanks for your quick reply. I installed the whole system 2 month ago. The version of trytond is 5.8.5.
The package-lock.json from the installation of sao via npm shows the following:

"tryton-sao": {
  "version": "5.0.37",
  "resolved": "https://registry.npmjs.org/tryton-sao/-/tryton-sao-5.0.37.tg$
  "integrity": "sha512-ZyI2siZnpcFp9HmkQ2S4ZFDtvTUdHo/PZn3NsWKxf3a9WsHXrgga$
  "requires": {
	"bower": "1.8.12",
	"grunt": "0.4.5",
	"grunt-cli": "0.1.13",
	"grunt-contrib-concat": "0.5.1",
	"grunt-contrib-jshint": "0.11.3",
	"grunt-contrib-less": "1.4.1",
	"grunt-contrib-uglify": "0.9.2",
	"grunt-po2json": "0.3.0"
  }

Is there a documentation or a way to check if both versions are compatible with each other?

Yes, to make them comptable the first two digits of the versions should be equal. So if you are using trytond with version 5.8.5 you should use sao with version 5.8.x:

In your case you are using 5.0 series of sao, which makes it incompatible and causes the error.
Installing the right series of sao should fix your issue.

I documented for myself that I installed sao via “npm i tryton-sao”. I din’t realize this did not install the latest verison but the version 5.0.37.

So finalls I updated to latest verison with a simple “npm update” and now everything works fine. Many thanks for the great support.