Skip to content

[18.] l10n_it_account_invoice_start_end_dates conflict with withholding registration #5188

@DavideSpagnuolo

Description

@DavideSpagnuolo

Module

l10n_it_account_invoice_start_end_dates

Describe the bug

When registering a payment for a vendor invoice with a withholding tax, configured with is_withholding_tax_on_payment = True, is not possibile to confirm the payment, because it gives an error.

To Reproduce

Affected versions: v18

Steps to reproduce the behavior:

  1. l10n_it_edi_withholding installed
  2. l10n_account_withholding_tax installed
  3. Configured tax "RIT" with
    • type_tax_use = purchase
    • is_withholding_tax_on_payment = True
    • amount = negative amount
  4. Create a vendor bill
  5. Add a bill line with the tax RIT applied
  6. Confirm the bill
  7. Register the payment with:
    • should_withhold_tax = true
    • withhold_outstanding_account_id configured
  8. Confirm Payment
  9. Odoo gives an error

Expected behavior
Complete payment registration process with the creation of the specific journal entry for the withholding amount

Additional context
Here the complete error:

RPC_ERROR

Odoo Server Error

Occured on davidespagnuolo-test18.odoo.com on model account.payment.register on 2026-04-30 11:41:36 GMT

Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/http.py", line 2167, in _transactioning
return service_model.retrying(func, env=self.env)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/service/model.py", line 157, in retrying
result = func()
^^^^^^
File "/home/odoo/src/odoo/odoo/http.py", line 2134, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/http.py", line 2382, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_http.py", line 333, in _dispatch
result = endpoint(**request.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/http.py", line 754, in route_wrapper
result = endpoint(self, *args, **params_ok)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/addons/web/controllers/dataset.py", line 42, in call_button
action = call_kw(request.env[model], method, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/api.py", line 535, in call_kw
result = getattr(recs, name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/addons/account/wizard/account_payment_register.py", line 1302, in action_create_payments
payments = self._create_payments()
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/addons/account/wizard/account_payment_register.py", line 1287, in _create_payments
payments = wizard.with_context(clean_context(self.env.context))._init_payments(to_process, edit_mode=edit_mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/addons/hr_expense/wizard/account_payment_register.py", line 26, in _init_payments
payments = super()._init_payments(to_process, edit_mode=edit_mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/addons/account/wizard/account_payment_register.py", line 1119, in _init_payments
.create([x['create_vals'] for x in to_process])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 2, in create
File "/home/odoo/src/odoo/odoo/api.py", line 498, in _model_create_multi
return create(self, arg)
^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/addons/account/models/account_payment.py", line 960, in create
pay._generate_journal_entry(
File "/home/odoo/src/odoo/addons/account/models/account_payment.py", line 1112, in _generate_journal_entry
pay._generate_move_vals(write_off_line_vals, force_balance, line_ids)
File "/home/odoo/src/odoo/addons/account/models/account_payment.py", line 1133, in _generate_move_vals
for line_vals in self._prepare_move_line_default_vals(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/addons/account/models/account_payment.py", line 419, in _prepare_move_line_default_vals
line_vals_per_type = self._prepare_move_lines_per_type(write_off_line_vals=write_off_line_vals, force_balance=force_balance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/addons/account/models/account_payment.py", line 352, in _prepare_move_lines_per_type
withholding_lines = self._prepare_move_withholding_lines({})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/addons/l10n_account_withholding_tax/models/account_payment.py", line 106, in _prepare_move_withholding_lines
withholding_lines += self.withholding_line_ids._prepare_withholding_amls_create_values()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/addons/l10n_account_withholding_tax/models/account_payment_withholding_line.py", line 76, in _prepare_withholding_amls_create_values
return super()._prepare_withholding_amls_create_values()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/addons/l10n_account_withholding_tax/models/account_withholding_line.py", line 374, in _prepare_withholding_amls_create_values
AccountTax._add_accounting_data_in_base_lines_tax_details(base_lines, company)
File "/home/odoo/src/odoo/addons/account/models/account_tax.py", line 2532, in _add_accounting_data_in_base_lines_tax_details
self._add_accounting_data_to_base_line_tax_details(base_line, company, include_caba_tags=include_caba_tags)
File "/home/odoo/src/odoo/addons/account/models/account_tax.py", line 2509, in _add_accounting_data_to_base_line_tax_details
base_line_grouping_key = self._prepare_base_line_grouping_key(base_line)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/user/OCA/l10n-italy/l10n_it_account_invoice_start_end_dates/models/account_tax.py", line 41, in _prepare_base_line_grouping_key
grouping_key["start_date"] = record.start_date if record else False
^^^^^^^^^^^^^^^^^
AttributeError: 'account.payment.withholding.line' object has no attribute 'start_date'. Did you mean: '_start_name'?

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
RPC_ERROR
at makeErrorFromResponse (https://davidespagnuolo-test18.odoo.com/web/assets/32a8a66/web.assets_web.min.js:3178:165)
at XMLHttpRequest. (https://davidespagnuolo-test18.odoo.com/web/assets/32a8a66/web.assets_web.min.js:3184:13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions