Public release from ruodoo-project: 19.0 - 2026-11-01 22:52:25 UTC
This commit is contained in:
2
ruodoo_sale_control/controllers/__init__.py
Normal file
2
ruodoo_sale_control/controllers/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
from . import portal
|
||||
35
ruodoo_sale_control/controllers/portal.py
Normal file
35
ruodoo_sale_control/controllers/portal.py
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
import base64
|
||||
import datetime
|
||||
|
||||
import werkzeug
|
||||
|
||||
from odoo.http import request, route
|
||||
from odoo.addons.portal.controllers.portal import CustomerPortal
|
||||
|
||||
|
||||
class SaleControlPortal(CustomerPortal):
|
||||
|
||||
@route(['/my/closing_document'], type='http', auth='user', website=True)
|
||||
def submit_closing_document(self, redirect=None, **post):
|
||||
"""Приём закрывающего документа (скан) от клиента из портала."""
|
||||
name = post.get('name')
|
||||
invoice_id = post.get('invoice_id')
|
||||
redirect_url = post.get('url') or '/my/invoices'
|
||||
|
||||
file_data = False
|
||||
for uploaded in request.httprequest.files.getlist('image_1920'):
|
||||
content = uploaded.read()
|
||||
if content:
|
||||
file_data = base64.b64encode(content)
|
||||
|
||||
if name and invoice_id and file_data:
|
||||
request.env['doc.closeddoc'].sudo().create({
|
||||
'name': name,
|
||||
'date_doc': datetime.date.today(),
|
||||
'invoice_id': int(invoice_id),
|
||||
'channel': 'scan',
|
||||
'file_inv': file_data,
|
||||
})
|
||||
return werkzeug.utils.redirect('/my/invoices')
|
||||
return werkzeug.utils.redirect(redirect_url)
|
||||
Reference in New Issue
Block a user