Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][l10n_br_nfe] Error when creating invoice with document issuer being the partner #3596

Open
WesleyOliveira98 opened this issue Jan 23, 2025 · 0 comments
Labels

Comments

@WesleyOliveira98
Copy link
Contributor

Error when creating invoice with document issuer being the partner.

Module

l10n_br_nfe

Describe the bug

When we try to add an invoice where the partner is the issuer, it gives an error related to the document date, but without the key it is possible to create the invoice

Error:

Odoo Server Error

Traceback (most recent call last):
  File "/opt/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
    result = request.dispatch()
  File "/opt/odoo/odoo/http.py", line 696, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/odoo/http.py", line 370, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo/http.py", line 358, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/odoo/odoo/http.py", line 919, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/odoo/http.py", line 544, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/addons/web/controllers/main.py", line 1370, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/addons/web/controllers/main.py", line 1362, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoo/odoo/api.py", line 404, in call_kw
    result = _call_kw_model_create(method, model, args, kwargs)
  File "/opt/odoo/odoo/api.py", line 382, in _call_kw_model_create
    result = method(recs, *args, **kwargs)
  File "<decorator-gen-243>", line 2, in create
  File "/opt/odoo/odoo/api.py", line 352, in _model_create_multi
    return create(self, [arg])
  File "/mnt/data/odoo-addons-dir/l10n_br_account/models/account_move.py", line 378, in create
    invoice = super(AccountMove, self.with_context(create_from_move=True)).create(
  File "<decorator-gen-231>", line 2, in create
  File "/opt/odoo/odoo/api.py", line 333, in _model_create_single
    return self.browse().concat(*(create(self, vals) for vals in arg))
  File "/opt/odoo/odoo/api.py", line 333, in <genexpr>
    return self.browse().concat(*(create(self, vals) for vals in arg))
  File "/opt/odoo-venv/lib/python3.8/site-packages/odoo/addons/account_payment_partner/models/account_move.py", line 171, in create
    return super().create(vals)
  File "<decorator-gen-226>", line 2, in create
  File "/opt/odoo/odoo/api.py", line 352, in _model_create_multi
    return create(self, [arg])
  File "/opt/odoo/addons/purchase/models/account_invoice.py", line 110, in create
    moves = super(AccountMove, self).create(vals_list)
  File "<decorator-gen-145>", line 2, in create
  File "/opt/odoo/odoo/api.py", line 353, in _model_create_multi
    return create(self, arg)
  File "/opt/odoo/addons/account/models/account_move.py", line 2080, in create
    rslt = super(AccountMove, self).create(vals_list)
  File "<decorator-gen-131>", line 2, in create
  File "/opt/odoo/odoo/api.py", line 353, in _model_create_multi
    return create(self, arg)
  File "/opt/odoo/addons/mail/models/mail_thread.py", line 264, in create
    threads = super(MailThread, self).create(vals_list)
  File "<decorator-gen-66>", line 2, in create
  File "/opt/odoo/odoo/api.py", line 353, in _model_create_multi
    return create(self, arg)
  File "/opt/odoo/odoo/addons/base/models/ir_fields.py", line 534, in create
    recs = super().create(vals_list)
  File "<decorator-gen-15>", line 2, in create
  File "/opt/odoo/odoo/api.py", line 353, in _model_create_multi
    return create(self, arg)
  File "/opt/odoo/odoo/models.py", line 3891, in create
    parents = self.env[model_name].create([
  File "<decorator-gen-245>", line 2, in create
  File "/opt/odoo/odoo/api.py", line 353, in _model_create_multi
    return create(self, arg)
  File "/mnt/data/odoo-addons-dir/l10n_br_account/models/document.py", line 143, in create
    return super().create(filtered_vals_list)
  File "<decorator-gen-131>", line 2, in create
  File "/opt/odoo/odoo/api.py", line 353, in _model_create_multi
    return create(self, arg)
  File "/opt/odoo/addons/mail/models/mail_thread.py", line 264, in create
    threads = super(MailThread, self).create(vals_list)
  File "<decorator-gen-66>", line 2, in create
  File "/opt/odoo/odoo/api.py", line 353, in _model_create_multi
    return create(self, arg)
  File "/opt/odoo/odoo/addons/base/models/ir_fields.py", line 534, in create
    recs = super().create(vals_list)
  File "<decorator-gen-15>", line 2, in create
  File "/opt/odoo/odoo/api.py", line 353, in _model_create_multi
    return create(self, arg)
  File "/opt/odoo/odoo/models.py", line 3899, in create
    records = self._create(data_list)
  File "/opt/odoo/odoo/models.py", line 4072, in _create
    records._validate_fields(name for data in data_list for name in data['stored'])
  File "/opt/odoo/odoo/models.py", line 1277, in _validate_fields
    check(self)
  File "/mnt/data/odoo-addons-dir/l10n_br_nfe/models/document.py", line 857, in _check_document_date_key
    rec, rec.document_date
  File "/opt/odoo/odoo/fields.py", line 991, in __get__
    self.recompute(record)
  File "/opt/odoo/odoo/fields.py", line 1177, in recompute
    self.compute_value(recs)
  File "/opt/odoo/odoo/fields.py", line 1199, in compute_value
    records._compute_field_value(self)
  File "/opt/odoo/addons/mail/models/mail_thread.py", line 410, in _compute_field_value
    return super()._compute_field_value(field)
  File "/opt/odoo/odoo/models.py", line 4094, in _compute_field_value
    self.filtered('id')._validate_fields(fnames)
  File "/opt/odoo/odoo/models.py", line 1277, in _validate_fields
    check(self)
  File "/mnt/data/odoo-addons-dir/l10n_br_nfe/models/document.py", line 856, in _check_document_date_key
    document_date = fields.Datetime.context_timestamp(
  File "/opt/odoo/odoo/fields.py", line 1897, in context_timestamp
    assert isinstance(timestamp, datetime), 'Datetime instance expected'
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/odoo/odoo/http.py", line 652, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/odoo/http.py", line 317, in _handle_exception
    raise exception.with_traceback(None) from new_cause
AssertionError: Datetime instance expected

To Reproduce

  1. Create a vendor bill with the issuer as partner and with 35250109128969000117550000000110451646360730 as key
    Image

  2. When we try to save the bill, the error is displayed
    Image

Can be related to #3521

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant