Skip to content

[13.0] base_import_async failing with "Wrong value for ir.attachment.type: 'product'" when importing product.template #295

Closed

Description

@Rad0van

Any attempt to import product.template from CSV ends up with this:

2020-12-14 14:20:46,937 41915 ERROR odoo13com odoo.http: Exception during JSON request handling. 
Traceback (most recent call last):
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/http.py", line 624, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/http.py", line 310, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/tools/pycompat.py", line 14, in reraise
    raise value
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/http.py", line 669, in dispatch
    result = self._call_function(**self.params)
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/http.py", line 350, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/http.py", line 339, in checked_call
    result = self.endpoint(*a, **kw)
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/http.py", line 915, in __call__
    return self.method(*args, **kw)
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/http.py", line 515, in response_wrap
    response = f(*args, **kw)
  File "/mnt/slow/rex/Programming/odoo/odoo-13.0/addons/web/controllers/main.py", line 1322, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/mnt/slow/rex/Programming/odoo/odoo-13.0/addons/web/controllers/main.py", line 1314, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/api.py", line 387, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/api.py", line 374, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/mnt/slow/rex/Programming/odoo/odoo-13.0/addons-local/base_import_async/models/base_import_import.py", line 61, in do
    import_fields, data, options, self.file_name
  File "/mnt/slow/rex/Programming/odoo/odoo-13.0/addons-local/base_import_async/models/base_import_import.py", line 95, in _create_csv_attachment
    {"name": file_name, "datas": datas}
  File "<decorator-gen-155>", line 2, in create
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/api.py", line 314, in _model_create_single
    return create(self, arg)
  File "/mnt/slow/rex/Programming/odoo/odoo-13.0/addons/website/models/ir_attachment.py", line 25, in create
    return super(Attachment, self).create(vals)
  File "<decorator-gen-40>", line 2, in create
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/api.py", line 335, in _model_create_multi
    return create(self, [arg])
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/addons/base/models/ir_attachment.py", line 526, in create
    return super(IrAttachment, self).create(vals_list)
  File "<decorator-gen-3>", line 2, in create
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/api.py", line 336, in _model_create_multi
    return create(self, arg)
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/models.py", line 3788, in create
    records = self._create(data_list)
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/models.py", line 3860, in _create
    col_val = field.convert_to_column(val, self, stored)
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/fields.py", line 2246, in convert_to_column
    value = self.convert_to_cache(value, record)
  File "/home/rex/Programming/odoo/odoo-13.0/odoo/fields.py", line 2258, in convert_to_cache
    raise ValueError("Wrong value for %s: %r" % (self, value))
ValueError: Wrong value for ir.attachment.type: 'product'

Activity

  1. etobella commented on Dec 14, 2020

    @etobella
    Member

    The error probably comes from here:

    https://github.com/OCA/queue/blob/13.0/base_import_async/models/base_import_import.py#L94

    product view sometimes has a default_type on context, that is probably giving a problem, as the field type on attachment cannot be product. The same would happen if you try to import invoices or moves as there is a field called type and defined by the context.

    If you try to import from the Invoicing/Sales/Products page, it will probably work. Can you check?

  2. Rad0van commented on Dec 14, 2020

    @Rad0van
    SponsorAuthor

    The error probably comes from here:

    https://github.com/OCA/queue/blob/13.0/base_import_async/models/base_import_import.py#L94

    product view sometimes has a default_type on context, that is probably giving a problem, as the field type on attachment cannot be product. The same would happen if you try to import invoices or moves as there is a field called type and defined by the context.

    If you try to import from the Invoicing/Sales/Products page, it will probably work. Can you check?

    Hmm, it got me further - no error when clicking import. Thanx for that. However the job's stuck on Pending state not doing anything. Should I be doing something manually? I am importing 860+ products with many variants (5-50 each). But the server does not seem to be doing anything. Reading the code it should split the input file into 100-line chunks and set them as Related to the main job. And yet, there isn't anything there. Any help would be appreciated.

    Regarding the source of error: you're saying that the product.template view has context in which type=product and this gets into creation of attachment? That doesn't seem right...

  3. Rad0van commented on Dec 15, 2020

    @Rad0van
    SponsorAuthor

    Got it... Missed the server configuration for server_wide_modules...

  4. etobella commented on Dec 15, 2020

    @etobella
    Member

    Your first error was my comment, the action on product had a default_type key on context, that was your error. For that reason the attachment couldn't be created

  5. guewen commented on Dec 15, 2020

    @guewen
    Member

    See #242

  6. Rad0van commented on Dec 15, 2020

    @Rad0van
    SponsorAuthor

    Your first error was my comment, the action on product had a default_type key on context, that was your error. For that reason the attachment couldn't be created

    I didn't mean you weren't right - the situation seemed strange. But there is even PR to fix this so great.

    Unfortunately I found that the odoo.sh instance I am stuck with for now has 1 worker only so I cannot use this :-( Can you maybe suggest some alternative?

  7. guewen commented on Dec 15, 2020

    @guewen
    Member

    odoo.sh is still hazardous grounds unfortunately, due to the way they deploy odoo (see #169 (comment)).
    I opened #256 to try solving the issues, but as I am not myself using odoo.sh, it would need some testing.

  8. Rad0van commented on Dec 17, 2020

    @Rad0van
    SponsorAuthor

    I guess this can be closed. Thanx all for help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions