Tryton - Issues

 

Issue8712

Title Unable to add tax_line: 'account.move.line' Model has no attribute 'currency_digits'
Priority bug Status testing
Superseder Nosy List ced, reviewbot, semarie
Type crash Components trytond
Assigned To ced Keywords review
Reviews 258221002
View: 258221002

Created on 2019-10-05.12:28:01 by semarie, last changed by reviewbot.

Messages
review258221002 updated at https://codereview.tryton.org/258221002/#ps266161003
review258221002 updated at https://codereview.tryton.org/258221002/#ps276111002
review258221002 updated at https://codereview.tryton.org/258221002/#ps262241002
msg52302 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-10-06.00:53:46
Here is review258221002 which adds a generic test for such case and fix all modules.
msg52297 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-10-05.18:53:46
For me, we must enforce to declare depends on the _parent_ if a dependency to a Many2One field is set and that this Many2One is used in a One2Many.
In this case, we are missing a '_parent_move_line.currency_digits' dependency on the on_change_with_currency_digits.
msg52296 (view) Author: [hidden] (semarie) Date: 2019-10-05.17:37:09
I am able to reproduce with tryton desktop client too.

- create a Move
- add a Line
- try to add a TaxLine on the Line

The backtrace is similar
msg52295 (view) Author: [hidden] (semarie) Date: 2019-10-05.12:27:57
Using tip, I have the following problem when using proteus:

Proteus code:

from proteus import config, Model
config = config.set_xmlrpc('http://admin:admin@localhost:8000/database/')
Move = Model.get('account.move')
m = Move()
line = m.lines.new()
tax_line = line.tax_lines.new()

The last expression raises an Exception:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/proteus/__init__.py", line 625, in new
    self.append(new_record)
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/proteus/__init__.py", line 574, in append
    self.__check([record])
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/proteus/__init__.py", line 569, in __check
    setattr(record, self.parent_name, self.parent)
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/proteus/__init__.py", line 276, in __set__
    super(Many2OneDescriptor, self).__set__(instance, value)
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/proteus/__init__.py", line 124, in __set__
    instance._on_change([self.name])
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/proteus/__init__.py", line 1145, in _on_change
    list(to_change), context)
  File "/usr/local/lib/python3.7/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/usr/local/lib/python3.7/xmlrpc/client.py", line 1452, in __request
    verbose=self.__verbose
  File "/usr/local/lib/python3.7/xmlrpc/client.py", line 1154, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/local/lib/python3.7/xmlrpc/client.py", line 1170, in single_request
    return self.parse_response(resp)
  File "/usr/local/lib/python3.7/xmlrpc/client.py", line 1342, in parse_response
    return u.close()
  File "/usr/local/lib/python3.7/xmlrpc/client.py", line 656, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault 255: "'account.move.line' Model has no attribute 'currency_digits': {'account': None}">



Server Log:

35176 20168388318272 [2019-10-05 10:25:26,492] INFO trytond.protocols.dispatcher <class 'trytond.modules.account.tax.TaxLine'>.on_change_with(*({'move_line': {'id': -2, 'account': None, 'amount': None, 'amount_currency': None, 'amount_currency_digits': None, 'amount_second_currency': None, 'analytic_lines': [], 'analytic_state': 'draft', 'create_date': datetime.datetime(2019, 10, 5, 10, 24, 35), 'create_uid': 1, 'credit': Decimal('0'), 'currency_digits': 2, 'date': datetime.date(2019, 10, 5), 'debit': Decimal('0'), 'description': None, 'invoice_payment': None, 'invoice_payments': [], 'journal': None, 'maturity_date': None, 'move': {'id': -1, 'company': 1, 'create_date': datetime.datetime(2019, 10, 5, 10, 24, 21), 'create_uid': 1, 'date': datetime.date(2019, 10, 5), 'description': None, 'journal': None, 'number': None, 'origin': None, 'period': 10, 'post_date': None, 'post_number': None, 'rec_name': None, 'state': 'draft', 'write_date': None, 'write_uid': None}, 'move_description': None, 'move_origin': None, 'move_state': 'draft', 'origin': None, 'party': None, 'party_required': False, 'payment_amount': None, 'payment_blocked': False, 'payment_direct_debit': False, 'payment_kind': None, 'payments': [], 'period': None, 'rec_name': None, 'reconciliation': None, 'reconciliations_delegated': [], 'second_currency': None, 'second_currency_digits': None, 'second_currency_required': None, 'state': 'draft', 'write_date': None, 'write_uid': None}, '_parent_move_line.account': None, 'id': -3}, ['company', 'currency_digits'], {'employee': None, 'company': 1, 'company.rec_name': 'COMPANY', 'language': 'fr', 'language_direction': 'ltr', 'groups': [1, 8, 6, 4, 2, 7, 3, 10, 5, 9, 11], 'locale': {'date': '%d.%m.%Y', 'grouping': [3, 0], 'decimal_point': ',', 'thousands_sep': ' '}, 'journal': None, 'period': 10, 'date': datetime.date(2019, 10, 5)}), **{}) from admin@127.0.0.1//database/
35176 20168388318272 [2019-10-05 10:25:26,502] ERROR trytond.protocols.dispatcher <class 'trytond.modules.account.tax.TaxLine'>.on_change_with(*({'move_line': {'id': -2, 'account': None, 'amount': None, 'amount_currency': None, 'amount_currency_digits': None, 'amount_second_currency': None, 'analytic_lines': [], 'analytic_state': 'draft', 'create_date': datetime.datetime(2019, 10, 5, 10, 24, 35), 'create_uid': 1, 'credit': Decimal('0'), 'currency_digits': 2, 'date': datetime.date(2019, 10, 5), 'debit': Decimal('0'), 'description': None, 'invoice_payment': None, 'invoice_payments': [], 'journal': None, 'maturity_date': None, 'move': {'id': -1, 'company': 1, 'create_date': datetime.datetime(2019, 10, 5, 10, 24, 21), 'create_uid': 1, 'date': datetime.date(2019, 10, 5), 'description': None, 'journal': None, 'number': None, 'origin': None, 'period': 10, 'post_date': None, 'post_number': None, 'rec_name': None, 'state': 'draft', 'write_date': None, 'write_uid': None}, 'move_description': None, 'move_origin': None, 'move_state': 'draft', 'origin': None, 'party': None, 'party_required': False, 'payment_amount': None, 'payment_blocked': False, 'payment_direct_debit': False, 'payment_kind': None, 'payments': [], 'period': None, 'rec_name': None, 'reconciliation':
None, 'reconciliations_delegated': [], 'second_currency': None, 'second_currency_digits': None, 'second_currency_required': None, 'state': 'draft', 'write_date': None, 'write_uid': None}, '_parent_move_line.account': None, 'id': -3}, ['company', 'currency_digits'], {'employee': None, 'company': 1, 'company.rec_name': 'COMPANY', 'language': 'fr', 'language_direction': 'ltr', 'groups': [1, 8, 6, 4, 2, 7, 3, 10, 5, 9, 11], 'locale': {'date': '%d.%m.%Y', 'grouping': [3, 0], 'decimal_point': ',', 'thousands_sep': ' '}, 'journal': None, 'period': 10, 'date': datetime.date(2019, 10, 5)}), **{}) from admin@127.0.0.1//database/
Traceback (most recent call last):
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/trytond/model/model.py", line 277, in __getattr__
    return self._values[name]
KeyError: 'currency_digits'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/trytond/protocols/dispatcher.py", line 191, in _dispatch
    result = rpc.result(meth(inst, *c_args, **c_kwargs))
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/trytond/model/modelview.py", line 736, in on_change_with
    changes[fieldname] = getattr(self, method_name)()
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/trytond/model/fields/field.py", line 117, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/trytond/modules/account/tax.py", line 1224, in on_change_with_currency_digits
    return self.move_line.currency_digits
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/trytond/model/modelstorage.py", line 1403, in __getattr__
    return super(ModelStorage, self).__getattr__(name)
  File "/usr/local/tryton-tip/lib/python3.7/site-packages/trytond/model/model.py", line 280, in __getattr__
    % (self.__name__, name, self._values))
AttributeError: 'account.move.line' Model has no attribute 'currency_digits': {'account': None}
History
Date User Action Args
2019-10-07 15:42:35reviewbotsetmessages: + msg52323
2019-10-07 13:43:19reviewbotsetmessages: + msg52321
2019-10-06 01:06:56reviewbotsetnosy: + reviewbot
messages: + msg52303
2019-10-06 00:53:48cedsetstatus: in-progress -> testing
reviews: 258221002
messages: + msg52302
keyword: + review
2019-10-05 18:53:47cedsetstatus: chatting -> in-progress
assignedto: ced
component: + trytond
messages: + msg52297
nosy: + ced
2019-10-05 17:37:09semariesetstatus: unread -> chatting
messages: + msg52296
title: Unable to get tax_lines using proteus: 'account.move.line' Model has no attribute 'currency_digits' -> Unable to add tax_line: 'account.move.line' Model has no attribute 'currency_digits'
2019-10-05 12:28:02semariecreate

Showing 10 items. Show all history (warning: this could be VERY long)