Tryton - Issues

 

Issue8712

Title Unable to add tax_line: 'account.move.line' Model has no attribute 'currency_digits'
Priority bug Status resolved
Superseder Nosy List ced, reviewbot, roundup-bot, 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 roundup-bot.

Messages
New changeset bb65b220a6d1 by Cédric Krier in branch '5.2':
Add missing parent depends
https://hg.tryton.org/modules/account/rev/bb65b220a6d1

New changeset fc0b19aed53d by Cédric Krier in branch '5.0':
Add missing parent depends
https://hg.tryton.org/modules/account/rev/fc0b19aed53d

New changeset 2c000c51e364 by Cédric Krier in branch '4.8':
Add missing parent depends
https://hg.tryton.org/modules/account/rev/2c000c51e364

New changeset e510bc1533ac by Cédric Krier in branch '4.6':
Add missing parent depends
https://hg.tryton.org/modules/account/rev/e510bc1533ac

New changeset e09681cb526d by Cédric Krier in branch '4.4':
Add missing parent depends
https://hg.tryton.org/modules/account/rev/e09681cb526d
New changeset 9084335e3498 by Cédric Krier in branch 'default':
Improve tests on depends
https://hg.tryton.org/tryton-env/rev/9084335e3498
New changeset f1ac853b1006 by Cédric Krier in branch 'default':
Improve tests on depends
https://hg.tryton.org/trytond/rev/f1ac853b1006
New changeset 757d0442fd41 by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/stock_supply/rev/757d0442fd41
New changeset 2368031e1a1d by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/sale_secondary_unit/rev/2368031e1a1d
New changeset 4292f6caa1c7 by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/sale_product_customer/rev/4292f6caa1c7
New changeset 1e8447bad546 by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/sale_complaint/rev/1e8447bad546
New changeset d0a4bde356a5 by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/purchase_request_quotation/rev/d0a4bde356a5
New changeset 16cbb3ba462e by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/purchase/rev/16cbb3ba462e
New changeset 018cd75e1181 by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/production_work/rev/018cd75e1181
New changeset f235f5fda4a1 by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/product/rev/f235f5fda4a1
New changeset 5f543723b662 by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/customs/rev/5f543723b662
New changeset c96b389a15bd by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/account_statement_rule/rev/c96b389a15bd
New changeset 3d315d34c73b by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/account_statement/rev/3d315d34c73b
New changeset 046480dafd25 by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/account_product/rev/046480dafd25
New changeset 9070eb9cb2e2 by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/account_payment/rev/9070eb9cb2e2
New changeset 9b385ff0d6db by Cédric Krier in branch 'default':
Add missing parent depends
https://hg.tryton.org/modules/account/rev/9b385ff0d6db
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-23 00:50:33roundup-botsetstatus: testing -> resolved
messages: + msg52625
keyword: - backport
2019-10-16 21:26:02cedsetstatus: resolved -> testing
keyword: + backport
2019-10-16 21:25:31roundup-botsetmessages: + msg52525
2019-10-16 21:25:28roundup-botsetmessages: + msg52524
2019-10-16 21:25:23roundup-botsetmessages: + msg52523
2019-10-16 21:25:15roundup-botsetmessages: + msg52522
2019-10-16 21:25:11roundup-botsetmessages: + msg52521
2019-10-16 21:25:07roundup-botsetmessages: + msg52520
2019-10-16 21:25:00roundup-botsetmessages: + msg52519
2019-10-16 21:24:57roundup-botsetmessages: + msg52518

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