mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
update paid
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from . import models
|
|
||||||
from . import controllers
|
from . import controllers
|
||||||
|
from . import models
|
||||||
from .hooks import pre_init_hook
|
from .hooks import pre_init_hook
|
||||||
from .hooks import post_init_hook
|
from .hooks import post_init_hook
|
||||||
from .hooks import uninstall_hook
|
from .hooks import uninstall_hook
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# from . import main
|
from . import main
|
||||||
19
app_common/controllers/main.py
Normal file
19
app_common/controllers/main.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import base64
|
||||||
|
from io import BytesIO
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from odoo import api, http, SUPERUSER_ID, _
|
||||||
|
|
||||||
|
class ImageController(http.Controller):
|
||||||
|
|
||||||
|
def get_image_from_url(self, url):
|
||||||
|
if not url:
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
response = requests.get(url) # 将这个图片保存在内存
|
||||||
|
except Exception as e:
|
||||||
|
return None
|
||||||
|
# 返回这个图片的base64编码
|
||||||
|
return base64.b64encode(BytesIO(response.content).read())
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
||||||
|
|
||||||
|
from ..controllers import main as imgc
|
||||||
|
|
||||||
from datetime import date, datetime, time
|
from datetime import date, datetime, time
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
@@ -43,3 +45,8 @@ class Base(models.AbstractModel):
|
|||||||
user_tz = pytz.timezone(self.env.user.tz or 'Etc/GMT+8')
|
user_tz = pytz.timezone(self.env.user.tz or 'Etc/GMT+8')
|
||||||
dt = dt.replace(tzinfo=pytz.timezone('UTC'))
|
dt = dt.replace(tzinfo=pytz.timezone('UTC'))
|
||||||
return dt.astimezone(user_tz).strftime(return_format)
|
return dt.astimezone(user_tz).strftime(return_format)
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def get_image_from_url(self, url):
|
||||||
|
res = imgc.ImageController.get_image_from_url(url)
|
||||||
|
return res
|
||||||
Reference in New Issue
Block a user