19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:31:47 +01:00
parent accf5918df
commit 6e65e8c877
688 changed files with 225434 additions and 199401 deletions

View file

@ -1,35 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import base64
import json
import logging
from odoo import http
from odoo.http import request
from odoo.tools.translate import _
logger = logging.getLogger(__name__)
from odoo.addons.product.controllers.product_document import ProductDocumentController
class MrpDocumentRoute(http.Controller):
class MRPProductDocumentController(ProductDocumentController):
@http.route('/mrp/upload_attachment', type='http', methods=['POST'], auth="user")
def upload_document(self, ufile, **kwargs):
files = request.httprequest.files.getlist('ufile')
result = {'success': _("All files uploaded")}
for ufile in files:
try:
mimetype = ufile.content_type
request.env['mrp.document'].create({
'name': ufile.filename,
'res_model': kwargs.get('res_model'),
'res_id': int(kwargs.get('res_id')),
'mimetype': mimetype,
'datas': base64.encodebytes(ufile.read()),
})
except Exception as e:
logger.exception("Fail to upload document %s" % ufile.filename)
result = {'error': str(e)}
return json.dumps(result)
def get_additional_create_params(self, **kwargs):
super_values = super().get_additional_create_params(**kwargs)
if kwargs.get('attached_on_bom'):
return super_values | {'attached_on_mrp': 'bom'}
return super_values