Issue 11136

Title
AttributeError: 'account.invoice.tax._record' object has no attribute '_key'
Priority
bug
Status
resolved
Nosy list
ced, reviewbot, roundup-bot, semarie
Assigned to
ced
Keywords
review

Created on 2022-01-14.12:08:51 by semarie, last changed 1 month ago by roundup-bot.

Messages

New changeset d2f64e9fb493 by Cédric Krier in branch '6.2':
Do not fail on missing attribute in InvoiceTax._key
https://hg.tryton.org/modules/account_invoice/rev/d2f64e9fb493

New changeset 1ae3fa6ec8f1 by Cédric Krier in branch '6.0':
Do not fail on missing attribute in InvoiceTax._key
https://hg.tryton.org/modules/account_invoice/rev/1ae3fa6ec8f1
New changeset 400015a90403 by Cédric Krier in branch 'default':
Do not fail on missing attribute in InvoiceTax._key
https://hg.tryton.org/tryton-env/rev/400015a90403
New changeset ac674a252a05 by Cédric Krier in branch 'default':
Do not fail on missing attribute in InvoiceTax._key
https://hg.tryton.org/modules/account_invoice/rev/ac674a252a05
Author: [hidden] (semarie)
Date: 2022-01-14.12:08:51

When recording a purchase invoice, when adding an invoice line, and when adding tax on the line, the following error popup:

Fri Jan 14 08:33:31 2022 ERROR:trytond.protocols.dispatcher:<class 'trytond.pool.account.invoice'>.on_change_taxes(*({'currency': 44, 'accounting_date': None, 'company': 1, 'lines': [{'account': None, 'amount': Decimal('0.00'), 'company': 1, 'currency': 44, 'invoice_state': 'draft', 'invoice_type': 'in', 'party': None, 'product': 7, 'product_uom_category': None, 'quantity': None, 'sequence': None, 'summary': '', 'taxes': [21], 'type': 'line', 'unit': None, 'unit_price': None, 'analytic_accounts': [{'root': 1, 'account': None, 'company': None, 'id': -3, 'origin': Pool().get('account.invoice.line')(**{'quantity': None, 'product': 7, 'asset': None, 'invoice_state': 'draft', 'taxes_deductible_rate': Decimal('1'), 'analytic_accounts': [{'company': None, 'root': 1, 'account': None, 'origin': 'account.invoice.line,-2'}], 'party': None, 'taxes': [21], 'note': '', 'type': 'line', 'invoice': -1, 'description': '', 'invoice_type': 'in', 'currency': 44, 'company': 1, 'party_lang': 'fr', 'unit_price': None, 'sequence': None, 'unit': None, 'account': None, 'product_uom_category': None, 'summary': '', 'amount': Decimal('0.00'), 'taxes_date': None, 'analytic_accounts_size': 1, 'is_assets_depreciable': False, 'origin': None})}], 'analytic_accounts_size': 1, 'asset': None, 'description': '', 'is_assets_depreciable': False, 'note': '', 'origin': None, 'party_lang': 'fr', 'taxes_date': None, 'taxes_deductible_rate': Decimal('1'), 'id': -2, 'invoice': Pool().get('account.invoice')(**{'invoice_date': datetime.date(2021, 8, 18), 'lines': [{'quantity': None, 'product': 7, 'asset': None, 'invoice_state': 'draft', 'taxes_deductible_rate': Decimal('1'), 'analytic_accounts': [{'company': None, 'root': 1, 'account': None, 'origin': 'account.invoice.line,-2'}], 'party': None, 'taxes': [21], 'note': '', 'type': 'line', 'invoice': -1, 'description': '', 'invoice_type': 'in', 'currency': 44, 'company': 1, 'party_lang': 'fr', 'unit_price': None, 'sequence': None, 'unit': None, 'account': None, 'product_uom_category': None, 'summary': '', 'amount': Decimal('0.00'), 'taxes_date': None, 'analytic_accounts_size': 1, 'is_assets_depreciable': False, 'origin': None}], 'taxes': [{'currency': None, 'base': None, 'amount': None, 'create_uid': None, 'invoice_state': None, 'sequence': None, 'create_date': None, 'invoice': -1, 'tax': None, 'legal_notice': '', 'account': None, 'manual': False, 'description': ''}], 'party': 157, 'accounting_date': None, 'untaxed_amount': Decimal('0.0'), 'currency': 44, 'company': 1, 'tax_amount': Decimal('0.0'), 'total_amount': Decimal('0.0')})}], 'taxes': [{'account': None, 'amount': None, 'base': None, 'currency': None, 'description': '', 'invoice_state': None, 'legal_notice': '', 'manual': False, 'sequence': None, 'tax': None, 'create_date': None, 'create_uid': None, 'id': -4, 'invoice': Pool().get('account.invoice')(**{'invoice_date': datetime.date(2021, 8, 18), 'lines': [{'quantity': None, 'product': 7, 'asset': None, 'invoice_state': 'draft', 'taxes_deductible_rate': Decimal('1'), 'analytic_accounts': [{'company': None, 'root': 1, 'account': None, 'origin': 'account.invoice.line,-2'}], 'party': None, 'taxes': [21], 'note': '', 'type': 'line', 'invoice': -1, 'description': '', 'invoice_type': 'in', 'currency': 44, 'company': 1, 'party_lang': 'fr', 'unit_price': None, 'sequence': None, 'unit': None, 'account': None, 'product_uom_category': None, 'summary': '', 'amount': Decimal('0.00'), 'taxes_date': None, 'analytic_accounts_size': 1, 'is_assets_depreciable': False, 'origin': None}], 'taxes': [{'currency': None, 'base': None, 'amount': None, 'create_uid': None, 'invoice_state': None, 'sequence': None, 'create_date': None, 'invoice': -1, 'tax': None, 'legal_notice': '', 'account': None, 'manual': False, 'description': ''}], 'party': 157, 'accounting_date': None, 'untaxed_amount': Decimal('0.0'), 'currency': 44, 'company': 1, 'tax_amount': Decimal('0.0'), 'total_amount': Decimal('0.0')})}], 'party': 157, 'invoice_date': datetime.date(2021, 8, 18), 'id': -1}, {'client': '3a472c12-178c-4d8b-89f7-80af9aa62915', 'company_filter': 'one', 'company': 1, 'company.rec_name': 'xxxx', 'language': 'fr', 'language_direction': 'ltr', 'groups': [5, 9, 11], 'roles': [], 'locale': {'date': '%d.%m.%Y', 'grouping': [3, 0], 'decimal_point': ',', 'thousands_sep': ' ', 'mon_grouping': [3, 0], 'mon_decimal_point': ',', 'mon_thousands_sep': ' ', 'p_sign_posn': 1, 'n_sign_posn': 1, 'positive_sign': '', 'negative_sign': '-', 'p_cs_precedes': False, 'n_cs_precedes': False, 'p_sep_by_space': True, 'n_sep_by_space': True}, 'type': 'in'}), **{}) from <user@ip>/xxxx/
Traceback (most recent call last):
  File "/usr/local/tryton-tip/lib/python3.9/site-packages/trytond/model/model.py", line 368, in _getitem
    return getattr(self, field)
AttributeError: 'account.invoice.tax._record' object has no attribute '_key'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/tryton-tip/lib/python3.9/site-packages/trytond/model/model.py", line 291, in __getattr__
    return self._values[name]
  File "/usr/local/tryton-tip/lib/python3.9/site-packages/trytond/model/model.py", line 370, in _getitem
    raise KeyError(field)
KeyError: '_key'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/tryton-tip/lib/python3.9/site-packages/trytond/protocols/dispatcher.py", line 185, in _dispatch
    result = rpc.result(meth(inst, *c_args, **c_kwargs))
  File "/usr/local/tryton-tip/lib/python3.9/site-packages/trytond/model/modelview.py", line 90, in wrapper
    result = func(self, *args, **kwargs)
  File "/usr/local/tryton-tip/lib/python3.9/site-packages/trytond/model/fields/field.py", line 123, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/tryton-tip/lib/python3.9/site-packages/trytond/modules/account_invoice/invoice.py", line 527, in on_change_taxes
    self._on_change_lines_taxes()
  File "/usr/local/tryton-tip/lib/python3.9/site-packages/trytond/model/fields/field.py", line 123, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/tryton-tip/lib/python3.9/site-packages/trytond/modules/account_invoice/invoice.py", line 558, in _on_change_lines_taxes
    key = tax._key
  File "/usr/local/tryton-tip/lib/python3.9/site-packages/trytond/model/modelstorage.py", line 1522, in __getattr__
    return super(ModelStorage, self).__getattr__(name)
  File "/usr/local/tryton-tip/lib/python3.9/site-packages/trytond/model/model.py", line 293, in __getattr__
    raise AttributeError("'%s' Model has no attribute '%s': %s"
AttributeError: 'account.invoice.tax' Model has no attribute '_key': <trytond.model.model.account.invoice.tax._record object at 0xf1a2139c930>
History
Date User Action Args
2022-03-25 19:26:59roundup-botsetkeyword: - backport
messages: + msg74743
2022-03-06 13:44:14roundup-botsetmessages: + msg74422
2022-03-06 13:44:10roundup-botsetmessages: + msg74421
nosy: + roundup-bot
status: testing -> resolved
2022-03-06 13:43:27cedsetkeyword: + backport
2022-02-22 11:25:05reviewbotsetmessages: + msg74279
2022-02-22 01:22:43reviewbotsetmessages: + msg74278
nosy: + reviewbot
2022-02-22 01:04:40cedsetkeyword: + review
reviews: 370911002
status: in-progress -> testing
2022-02-22 01:03:58cedsetassignedto: ced
nosy: + ced
status: unread -> in-progress
2022-01-14 12:08:51semariecreate

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