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

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

Closed
Rad0van opened this issue Dec 14, 2020 · 8 comments

Comments

@Rad0van
Copy link
Sponsor

Rad0van commented Dec 14, 2020

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'

@etobella
Copy link
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?

@Rad0van
Copy link
Sponsor Author

Rad0van commented Dec 14, 2020

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...

@Rad0van
Copy link
Sponsor Author

Rad0van commented Dec 15, 2020

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

@etobella
Copy link
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

@guewen
Copy link
Member

guewen commented Dec 15, 2020

See #242

@Rad0van
Copy link
Sponsor Author

Rad0van commented Dec 15, 2020

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?

@guewen
Copy link
Member

guewen commented Dec 15, 2020

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.

@Rad0van
Copy link
Sponsor Author

Rad0van commented Dec 17, 2020

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants