mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
update common
This commit is contained in:
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': "Sunpop Odooapp Common Func",
|
'name': "Sunpop Odooapp Common Func",
|
||||||
'version': '13.21.08.21',
|
'version': '13.21.08.26',
|
||||||
'author': 'Sunpop.cn',
|
'author': 'Sunpop.cn',
|
||||||
'category': 'Base',
|
'category': 'Base',
|
||||||
'website': 'https://www.sunpop.cn',
|
'website': 'https://www.sunpop.cn',
|
||||||
|
|||||||
@@ -1,31 +1,14 @@
|
|||||||
# Translation of Odoo Server.
|
# Translation of Odoo Server.
|
||||||
# This file contains the translation of the following modules:
|
|
||||||
# * app_common
|
|
||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Odoo Server 13.0+e\n"
|
"Project-Id-Version: Odoo Server 10.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2021-08-19 09:28+0000\n"
|
"POT-Creation-Date: 2018-01-08 14:28+0000\n"
|
||||||
"PO-Revision-Date: 2021-08-19 09:28+0000\n"
|
"PO-Revision-Date: 2018-01-08 14:28+0000\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: <>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: \n"
|
"Content-Transfer-Encoding: \n"
|
||||||
"Plural-Forms: \n"
|
"Plural-Forms: \n"
|
||||||
|
|
||||||
#. module: app_common
|
|
||||||
#: model:ir.model.fields,field_description:app_common.field_ir_cron__trigger_user_id
|
|
||||||
msgid "Last Trigger User"
|
|
||||||
msgstr "手动运行用户"
|
|
||||||
|
|
||||||
#. module: app_common
|
|
||||||
#: model:ir.model,name:app_common.model_ir_cron
|
|
||||||
msgid "Scheduled Actions"
|
|
||||||
msgstr "安排的动作"
|
|
||||||
|
|
||||||
#. module: app_common
|
|
||||||
#: model:ir.model,name:app_common.model_ir_ui_view
|
|
||||||
msgid "View"
|
|
||||||
msgstr "查看"
|
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
|
|
||||||
from . import base
|
from . import base
|
||||||
from . import fields
|
from . import fields
|
||||||
from . import view_validation
|
# from . import validator
|
||||||
from . import ir_ui_view
|
from . import ir_ui_view
|
||||||
from . import ir_cron
|
from . import res_users
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,56 +9,9 @@ from io import BytesIO
|
|||||||
from datetime import date, datetime, time
|
from datetime import date, datetime, time
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
# 常规的排除的fields
|
|
||||||
EXCLU_FIELDS = [
|
|
||||||
'__last_update',
|
|
||||||
'access_token',
|
|
||||||
'access_url',
|
|
||||||
'access_warning',
|
|
||||||
'activity_date_deadline',
|
|
||||||
'activity_exception_decoration',
|
|
||||||
'activity_exception_icon',
|
|
||||||
'activity_ids',
|
|
||||||
'activity_state',
|
|
||||||
'activity_summary',
|
|
||||||
'activity_type_id',
|
|
||||||
'activity_user_id',
|
|
||||||
'display_name',
|
|
||||||
'message_attachment_count',
|
|
||||||
'message_channel_ids',
|
|
||||||
'message_follower_ids',
|
|
||||||
'message_has_error',
|
|
||||||
'message_has_error_counter',
|
|
||||||
'message_has_sms_error',
|
|
||||||
'message_ids',
|
|
||||||
'message_is_follower',
|
|
||||||
'message_main_attachment_id',
|
|
||||||
'message_needaction',
|
|
||||||
'message_needaction_counter',
|
|
||||||
'message_partner_ids',
|
|
||||||
'message_unread',
|
|
||||||
'message_unread_counter',
|
|
||||||
'website_message_ids',
|
|
||||||
'write_date',
|
|
||||||
'write_uid',
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class Base(models.AbstractModel):
|
class Base(models.AbstractModel):
|
||||||
_inherit = 'base'
|
_inherit = 'base'
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _get_normal_fields(self):
|
|
||||||
f_list = []
|
|
||||||
for k, v in self._fields.items():
|
|
||||||
if k not in EXCLU_FIELDS:
|
|
||||||
f_list.append(k)
|
|
||||||
return f_list
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _app_get_m2o_default(self, fieldname, domain=[]):
|
def _app_get_m2o_default(self, fieldname, domain=[]):
|
||||||
if hasattr(self, fieldname) and self._fields[fieldname].type == 'many2one':
|
if hasattr(self, fieldname) and self._fields[fieldname].type == 'many2one':
|
||||||
@@ -71,17 +24,16 @@ class Base(models.AbstractModel):
|
|||||||
|
|
||||||
def _app_dt2local(self, value, return_format=DEFAULT_SERVER_DATETIME_FORMAT):
|
def _app_dt2local(self, value, return_format=DEFAULT_SERVER_DATETIME_FORMAT):
|
||||||
"""
|
"""
|
||||||
将value中时间,按格式转为用户本地时间.注意只处理in str为字符串类型,如果是时间类型直接用 datetime.now(tz)
|
将value中时间,按格式转为用户本地时间
|
||||||
"""
|
"""
|
||||||
if not value:
|
if not value:
|
||||||
return value
|
return value
|
||||||
if isinstance(value, datetime):
|
if isinstance(value, datetime):
|
||||||
value = value.strftime(return_format)
|
value = value.strftime(return_format)
|
||||||
dt = datetime.strptime(value, return_format)
|
dt = datetime.strptime(value, return_format)
|
||||||
user_tz = pytz.timezone(self.env.user.tz or 'Etc/GMT-8')
|
pytz_timezone = pytz.timezone(self.env.user.tz or 'Etc/GMT-8')
|
||||||
_logger.warning('============= user2 tz: %s' % user_tz)
|
|
||||||
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(pytz_timezone).strftime(return_format)
|
||||||
|
|
||||||
def _app_dt2utc(self, value, return_format=DEFAULT_SERVER_DATETIME_FORMAT):
|
def _app_dt2utc(self, value, return_format=DEFAULT_SERVER_DATETIME_FORMAT):
|
||||||
"""
|
"""
|
||||||
@@ -92,9 +44,9 @@ class Base(models.AbstractModel):
|
|||||||
if isinstance(value, datetime):
|
if isinstance(value, datetime):
|
||||||
value = value.strftime(return_format)
|
value = value.strftime(return_format)
|
||||||
dt = datetime.strptime(value, return_format)
|
dt = datetime.strptime(value, return_format)
|
||||||
pytz_timezone = pytz.timezone('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(pytz_timezone).strftime(return_format)
|
return dt.astimezone(user_tz).strftime(return_format)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def get_image_from_url(self, url):
|
def get_image_from_url(self, url):
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ def app_relaxng(view_type):
|
|||||||
""" Return a validator for the given view type, or None. """
|
""" Return a validator for the given view type, or None. """
|
||||||
if view_type not in _relaxng_cache:
|
if view_type not in _relaxng_cache:
|
||||||
# tree, search 特殊
|
# tree, search 特殊
|
||||||
if view_type in ['tree', 'search', 'pivot']:
|
if view_type in ['tree', 'search']:
|
||||||
_file = get_resource_path('app_common', 'rng', '%s_view.rng' % view_type)
|
_file = get_resource_path('app_common', 'rng', '%s_view.rng' % view_type)
|
||||||
else:
|
else:
|
||||||
_file = get_resource_path('base', 'rng', '%s_view.rng' % view_type)
|
_file = get_resource_path('base', 'rng', '%s_view.rng' % view_type)
|
||||||
|
|||||||
10
app_common/models/res_users.py
Normal file
10
app_common/models/res_users.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from odoo import api, fields, models, tools, _
|
||||||
|
|
||||||
|
|
||||||
|
class ResUsers(models.Model):
|
||||||
|
_inherit = 'res.users'
|
||||||
|
|
||||||
|
login = fields.Char(index=True)
|
||||||
@@ -268,7 +268,6 @@
|
|||||||
<rng:optional><rng:attribute name="write_field" /></rng:optional>
|
<rng:optional><rng:attribute name="write_field" /></rng:optional>
|
||||||
<rng:optional><rng:attribute name="text" /></rng:optional>
|
<rng:optional><rng:attribute name="text" /></rng:optional>
|
||||||
<rng:optional><rng:attribute name="optional" /></rng:optional>
|
<rng:optional><rng:attribute name="optional" /></rng:optional>
|
||||||
<rng:optional><rng:attribute name="kanban_view_ref" /></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="decoration-bf"/></rng:optional>
|
<rng:optional><rng:attribute name="decoration-bf"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="decoration-it"/></rng:optional>
|
<rng:optional><rng:attribute name="decoration-it"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="decoration-danger"/></rng:optional>
|
<rng:optional><rng:attribute name="decoration-danger"/></rng:optional>
|
||||||
@@ -277,16 +276,7 @@
|
|||||||
<rng:optional><rng:attribute name="decoration-primary"/></rng:optional>
|
<rng:optional><rng:attribute name="decoration-primary"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="decoration-success"/></rng:optional>
|
<rng:optional><rng:attribute name="decoration-success"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="decoration-warning"/></rng:optional>
|
<rng:optional><rng:attribute name="decoration-warning"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="decoration-black"/></rng:optional>
|
<rng:optional><rng:attribute name="kanban_view_ref" /></rng:optional>
|
||||||
<rng:optional><rng:attribute name="decoration-white"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-danger"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-info"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-muted"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-primary"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-success"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-warning"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-black"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-white"/></rng:optional>
|
|
||||||
<rng:optional>
|
<rng:optional>
|
||||||
<rng:attribute name="force_save">
|
<rng:attribute name="force_save">
|
||||||
<rng:choice>
|
<rng:choice>
|
||||||
|
|||||||
@@ -46,16 +46,6 @@
|
|||||||
<rng:optional><rng:attribute name="decoration-primary"/></rng:optional>
|
<rng:optional><rng:attribute name="decoration-primary"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="decoration-success"/></rng:optional>
|
<rng:optional><rng:attribute name="decoration-success"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="decoration-warning"/></rng:optional>
|
<rng:optional><rng:attribute name="decoration-warning"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="decoration-black"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="decoration-white"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-danger"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-info"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-muted"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-primary"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-success"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-warning"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-black"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="bg-white"/></rng:optional>
|
|
||||||
<rng:optional><rng:attribute name="banner_route"/></rng:optional>
|
<rng:optional><rng:attribute name="banner_route"/></rng:optional>
|
||||||
<rng:optional><rng:attribute name="sample"/></rng:optional>
|
<rng:optional><rng:attribute name="sample"/></rng:optional>
|
||||||
<rng:optional>
|
<rng:optional>
|
||||||
|
|||||||
Reference in New Issue
Block a user