size
int64 0
304k
| ext
stringclasses 1
value | lang
stringclasses 1
value | branch
stringclasses 1
value | content
stringlengths 0
304k
| avg_line_length
float64 0
238
| max_line_length
int64 0
304k
|
---|---|---|---|---|---|---|
2,975 | py | PYTHON | 15.0 | # Copyright 2016-2017 LasLabs Inc.
# Copyright 2017-2018 Tecnativa - Jairo Llopis
# Copyright 2018-2019 Tecnativa - Alexandre Díaz
# Copyright 2021 ITerra - Sergey Shebanin
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": "Web Responsive",
"summary": "Responsive web client, community-supported",
"version": "15.0.1.1.10",
"category": "Website",
"website": "https://github.com/OCA/web",
"author": "LasLabs, Tecnativa, ITerra, " "Odoo Community Association (OCA)",
"license": "LGPL-3",
"installable": True,
"depends": ["web", "mail"],
"development_status": "Production/Stable",
"maintainers": ["Yajo", "Tardo", "SplashS"],
"excludes": ["web_enterprise"],
"data": ["views/res_users.xml", "views/web.xml"],
"assets": {
"web.assets_frontend": [
"/web_responsive/static/src/legacy/js/website_apps_menu.js",
"/web_responsive/static/src/legacy/scss/website_apps_menu.scss",
],
"web.assets_backend": [
"/web_responsive/static/src/legacy/scss/web_responsive.scss",
"/web_responsive/static/src/legacy/js/web_responsive.js",
"/web_responsive/static/src/legacy/scss/kanban_view_mobile.scss",
"/web_responsive/static/src/legacy/js/kanban_renderer_mobile.js",
"/web_responsive/static/src/components/ui_context.esm.js",
"/web_responsive/static/src/components/apps_menu/apps_menu.scss",
"/web_responsive/static/src/components/apps_menu/apps_menu.esm.js",
"/web_responsive/static/src/components/navbar/main_navbar.scss",
"/web_responsive/static/src/components/control_panel/control_panel.scss",
"/web_responsive/static/src/components/control_panel/control_panel.esm.js",
"/web_responsive/static/src/components/search_panel/search_panel.scss",
"/web_responsive/static/src/components/search_panel/search_panel.esm.js",
"/web_responsive/static/src/components/attachment_viewer/attachment_viewer.scss",
"/web_responsive/static/src/components/attachment_viewer/attachment_viewer.esm.js",
"/web_responsive/static/src/components/hotkey/hotkey.scss",
],
"web.assets_qweb": [
"/web_responsive/static/src/legacy/xml/form_buttons.xml",
"/web_responsive/static/src/components/apps_menu/apps_menu.xml",
"/web_responsive/static/src/components/control_panel/control_panel.xml",
"/web_responsive/static/src/components/navbar/main_navbar.xml",
"/web_responsive/static/src/components/search_panel/search_panel.xml",
"/web_responsive/static/src/components/attachment_viewer/attachment_viewer.xml",
"/web_responsive/static/src/components/hotkey/hotkey.xml",
],
"web.assets_tests": [
"/web_responsive/static/tests/test_patch.js",
],
},
"sequence": 1,
}
| 52.175439 | 2,974 |
519 | py | PYTHON | 15.0 | # Copyright 2018 Alexandre Díaz
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo.tests import common
class TestResUsers(common.TransactionCase):
def test_chatter_position_wr(self):
user_public = self.env.ref("base.public_user")
user_public = user_public.with_user(user_public)
self.assertEqual(user_public.chatter_position, "sided")
user_public.write({"chatter_position": "normal"})
self.assertEqual(user_public.chatter_position, "normal")
| 37 | 518 |
733 | py | PYTHON | 15.0 | # Copyright 2018-2019 Alexandre Díaz
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResUsers(models.Model):
_inherit = "res.users"
chatter_position = fields.Selection(
[("normal", "Normal"), ("sided", "Sided")],
default="sided",
)
"""Override to add access rights.
Access rights are disabled by default, but allowed on some specific
fields defined in self.SELF_{READ/WRITE}ABLE_FIELDS.
"""
@property
def SELF_READABLE_FIELDS(self):
return super().SELF_READABLE_FIELDS + ["chatter_position"]
@property
def SELF_WRITEABLE_FIELDS(self):
return super().SELF_WRITEABLE_FIELDS + ["chatter_position"]
| 28.153846 | 732 |
603 | py | PYTHON | 15.0 | # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Web Sheet Full Width",
"version": "15.0.1.0.1",
"author": "Therp BV, Sudokeys, GRAP, Métal Sartigan, "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"license": "AGPL-3",
"summary": "Use the whole available screen width when displaying sheets",
"category": "Tools",
"depends": ["web"],
"assets": {
"web.assets_common": [
"web_sheet_full_width/static/src/scss/web_sheet_full_width.scss",
],
},
"installable": True,
}
| 33.444444 | 602 |
724 | py | PYTHON | 15.0 | # Copyright 2017 - 2018 Modoolar <[email protected]>
# Copyright 2018 Brainbean Apps
# Copyright 2020 CorporateHub (https://corporatehub.eu)
# License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).
{
"name": "Web Actions View Reload",
"summary": "Enables reload of the current view via ActionManager",
"category": "Web",
"version": "15.0.1.0.0",
"license": "LGPL-3",
"author": "Modoolar, CorporateHub, Ryan Cole, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"depends": ["web"],
"installable": True,
"assets": {
"web.assets_backend": [
"web_ir_actions_act_view_reload/static/src/**/*.esm.js",
],
},
}
| 34.47619 | 724 |
180 | py | PYTHON | 15.0 | from odoo import models
class IrActionsActViewReload(models.Model):
_name = "ir.actions.act_view_reload"
_inherit = "ir.actions.actions"
_description = "View Reload"
| 25.714286 | 180 |
1,024 | py | PYTHON | 15.0 | # Copyright 2022 Hynsys Technologies
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Chatter Position",
"summary": "Add an option to change the chatter position",
"version": "15.0.1.0.0",
"author": "Hynsys Technologies, Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"license": "LGPL-3",
"category": "Extra Tools",
"images": ["static/description/images/web_chatter_position.png"],
"depends": ["web", "mail"],
"data": ["views/res_users.xml", "views/web.xml"],
"assets": {
"web.assets_backend": [
"/web_chatter_position/static/src/scss/chatter_position.scss",
"/web_chatter_position/static/src/scss/attachment_viewer.scss",
"/web_chatter_position/static/src/js/form_chatter_position.js",
],
"web.assets_qweb": [
"/web_chatter_position/static/src/xml/form_buttons.xml",
],
},
"installable": True,
"auto_install": False,
}
| 37.925926 | 1,024 |
628 | py | PYTHON | 15.0 | # Copyright 2022 Hynsys Technologies
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo import fields, models
class ResUsers(models.Model):
_inherit = "res.users"
chatter_position = fields.Selection(
[("bottom", "Bottom"), ("sided", "Sided")],
default="sided",
)
# Override so that the user can change the chatter_position field
@property
def SELF_READABLE_FIELDS(self):
return super().SELF_READABLE_FIELDS + ["chatter_position"]
@property
def SELF_WRITEABLE_FIELDS(self):
return super().SELF_WRITEABLE_FIELDS + ["chatter_position"]
| 27.304348 | 628 |
510 | py | PYTHON | 15.0 | # Copyright 2019 Alexandre Díaz <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import SUPERUSER_ID, api
from .models.res_company import URL_BASE
def uninstall_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
env["ir.attachment"].search([("url", "=like", "%s%%" % URL_BASE)]).unlink()
def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
env["res.company"].search([]).scss_create_or_update_attachment()
| 33.933333 | 509 |
621 | py | PYTHON | 15.0 | # Odoo, Open Source Web Company Color
# Copyright (C) 2019 Alexandre Díaz <[email protected]>
#
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).#
{
"name": "Web Company Color",
"category": "web",
"version": "15.0.1.1.0",
"author": "Alexandre Díaz, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"depends": ["web", "base_sparse_field"],
"data": ["view/assets.xml", "view/res_company.xml"],
"uninstall_hook": "uninstall_hook",
"post_init_hook": "post_init_hook",
"license": "AGPL-3",
"auto_install": False,
"installable": True,
}
| 34.388889 | 619 |
1,266 | py | PYTHON | 15.0 | # Copyright 2019 Alexandre Díaz <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import base64
import math
from io import BytesIO
from PIL import Image
def n_rgb_to_hex(_r, _g, _b):
return "#{:02x}{:02x}{:02x}".format(int(255 * _r), int(255 * _g), int(255 * _b))
def convert_to_image(field_binary):
return Image.open(BytesIO(base64.b64decode(field_binary)))
def image_to_rgb(img):
def normalize_vec3(vec3):
_l = 1.0 / math.sqrt(vec3[0] * vec3[0] + vec3[1] * vec3[1] + vec3[2] * vec3[2])
return (vec3[0] * _l, vec3[1] * _l, vec3[2] * _l)
# Force Alpha Channel
if img.mode != "RGBA":
img = img.convert("RGBA")
width, height = img.size
# Reduce pixels
width, height = (max(1, int(width / 4)), max(1, int(height / 4)))
img = img.resize((width, height))
rgb_sum = [0, 0, 0]
# Mix. image colors using addition method
RGBA_WHITE = (255, 255, 255, 255)
for i in range(0, height * width):
rgba = img.getpixel((i % width, i / width))
if rgba[3] > 128 and rgba != RGBA_WHITE:
rgb_sum[0] += rgba[0]
rgb_sum[1] += rgba[1]
rgb_sum[2] += rgba[2]
_r, _g, _b = normalize_vec3(rgb_sum)
return (_r, _g, _b)
| 31.625 | 1,265 |
3,082 | py | PYTHON | 15.0 | # Copyright 2019 Alexandre Díaz <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests import common
from ..models.res_company import URL_BASE
class TestResCompany(common.TransactionCase):
IMG_GREEN = (
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUl"
+ "EQVR42mNk+M/wHwAEBgIApD5fRAAAAABJRU5ErkJggg=="
)
def _test_scss_attachment(self):
num_scss = self.env["ir.attachment"].search_count(
[("url", "ilike", "%s%%" % URL_BASE)]
)
num_companies = self.env["res.company"].search_count([])
self.assertEqual(num_scss, num_companies, "Invalid scss attachments")
def test_create_unlink_company(self):
company_id = self.env["res.company"].create({"name": "Company Test"})
self.assertEqual(
company_id.color_navbar_bg, False, "Invalid Navbar Background Color"
)
self._test_scss_attachment()
company_id.sudo().write({"logo": self.IMG_GREEN})
company_id.button_compute_color()
self.assertEqual(
company_id.color_navbar_bg, "#00ff00", "Invalid Navbar Background Color"
)
# TODO: We can't remove companies if they have attached data, like
# warehouse when we have stock module installed
# company_id.sudo().unlink()
# self._test_scss_attachment()
def test_change_logo(self):
company_id = self.env["res.company"].search([], limit=1)
company_id.sudo().write({"logo": self.IMG_GREEN})
company_id.button_compute_color()
self.assertEqual(
company_id.color_navbar_bg, "#00ff00", "Invalid Navbar Background Color"
)
def test_scss_sanitized_values(self):
company_id = self.env["res.company"].search([], limit=1)
company_id.sudo().write({"color_navbar_bg": False})
values = company_id.sudo()._scss_get_sanitized_values()
self.assertEqual(
values["color_navbar_bg"],
"$o-brand-odoo",
"Invalid Navbar Background Color",
)
company_id.sudo().write({"color_navbar_bg": "#DEAD00"})
values = company_id.sudo()._scss_get_sanitized_values()
self.assertEqual(
values["color_navbar_bg"], "#DEAD00", "Invalid Navbar Background Color"
)
def test_change_color(self):
company_id = self.env["res.company"].search([], limit=1)
company_id.sudo().write({"color_navbar_bg": "#DEAD00"})
self.assertEqual(
company_id.color_navbar_bg, "#DEAD00", "Invalid Navbar Background Color"
)
self.assertEqual(
company_id.company_colors["color_navbar_bg"],
"#DEAD00",
"Invalid Navbar Background Color",
)
company_id.sudo().write({"color_navbar_bg": False})
self.assertFalse(company_id.color_navbar_bg, "Invalid Navbar Background Color")
self.assertNotIn(
"color_navbar_bg",
company_id.company_colors,
"Invalid Navbar Background Color",
)
| 40.012987 | 3,081 |
5,591 | py | PYTHON | 15.0 | # Copyright 2019 Alexandre Díaz <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import base64
from colorsys import hls_to_rgb, rgb_to_hls
from odoo import api, fields, models
from ..utils import convert_to_image, image_to_rgb, n_rgb_to_hex
URL_BASE = "/web_company_color/static/src/scss/"
URL_SCSS_GEN_TEMPLATE = URL_BASE + "custom_colors.%d.gen.scss"
class ResCompany(models.Model):
_inherit = "res.company"
SCSS_TEMPLATE = """
.o_main_navbar {
background-color: %(color_navbar_bg)s !important;
color: %(color_navbar_text)s !important;
> .o_menu_brand {
color: %(color_navbar_text)s !important;
&:hover, &:focus, &:active, &:focus:active {
background-color: %(color_navbar_bg_hover)s !important;
}
}
.show {
.dropdown-toggle {
background-color: %(color_navbar_bg_hover)s !important;
}
}
> ul {
> li {
> a, > label {
color: %(color_navbar_text)s !important;
&:hover, &:focus, &:active, &:focus:active {
background-color: %(color_navbar_bg_hover)s !important;
}
}
}
}
}
"""
company_colors = fields.Serialized()
color_navbar_bg = fields.Char("Navbar Background Color", sparse="company_colors")
color_navbar_bg_hover = fields.Char(
"Navbar Background Color Hover", sparse="company_colors"
)
color_navbar_text = fields.Char("Navbar Text Color", sparse="company_colors")
@api.model_create_multi
def create(self, vals_list):
records = super().create(vals_list)
records.scss_create_or_update_attachment()
return records
def unlink(self):
IrAttachmentObj = self.env["ir.attachment"]
for record in self:
IrAttachmentObj.sudo().search(
[("url", "=", record.scss_get_url()), ("company_id", "=", record.id)]
).sudo().unlink()
return super().unlink()
def write(self, values):
if not self.env.context.get("ignore_company_color", False):
fields_to_check = (
"color_navbar_bg",
"color_navbar_bg_hover",
"color_navbar_text",
)
result = super().write(values)
if any([field in values for field in fields_to_check]):
self.scss_create_or_update_attachment()
else:
result = super().write(values)
return result
def button_compute_color(self):
self.ensure_one()
values = self.default_get(
["color_navbar_bg", "color_navbar_bg_hover", "color_navbar_text"]
)
if self.logo:
_r, _g, _b = image_to_rgb(convert_to_image(self.logo))
# Make color 10% darker
_h, _l, _s = rgb_to_hls(_r, _g, _b)
_l = max(0, _l - 0.1)
_rd, _gd, _bd = hls_to_rgb(_h, _l, _s)
# Calc. optimal text color (b/w)
# Grayscale human vision perception (Rec. 709 values)
_a = 1 - (0.2126 * _r + 0.7152 * _g + 0.0722 * _b)
values.update(
{
"color_navbar_bg": n_rgb_to_hex(_r, _g, _b),
"color_navbar_bg_hover": n_rgb_to_hex(_rd, _gd, _bd),
"color_navbar_text": "#000" if _a < 0.5 else "#fff",
}
)
self.write(values)
def _scss_get_sanitized_values(self):
self.ensure_one()
# Clone company_color as dictionary to avoid ORM operations
# This allow extend company_colors and only sanitize selected fields
# or add custom values
values = dict(self.company_colors or {})
values.update(
{
"color_navbar_bg": (values.get("color_navbar_bg") or "$o-brand-odoo"),
"color_navbar_bg_hover": (
values.get("color_navbar_bg_hover")
or "$o-navbar-inverse-link-hover-bg"
),
"color_navbar_text": (values.get("color_navbar_text") or "#FFF"),
}
)
return values
def _scss_generate_content(self):
self.ensure_one()
# ir.attachment need files with content to work
if not self.company_colors:
return "// No Web Company Color SCSS Content\n"
return self.SCSS_TEMPLATE % self._scss_get_sanitized_values()
def scss_get_url(self):
self.ensure_one()
return URL_SCSS_GEN_TEMPLATE % self.id
def scss_create_or_update_attachment(self):
IrAttachmentObj = self.env["ir.attachment"]
for record in self:
datas = base64.b64encode(record._scss_generate_content().encode("utf-8"))
custom_url = record.scss_get_url()
custom_attachment = IrAttachmentObj.sudo().search(
[("url", "=", custom_url), ("company_id", "=", record.id)]
)
values = {
"datas": datas,
"db_datas": datas,
"url": custom_url,
"name": custom_url,
"company_id": record.id,
}
if custom_attachment:
custom_attachment.sudo().write(values)
else:
values.update({"type": "binary", "mimetype": "text/scss"})
IrAttachmentObj.sudo().create(values)
self.env["ir.qweb"].sudo().clear_caches()
| 35.833333 | 5,590 |
1,252 | py | PYTHON | 15.0 | # Copyright 2020 Alexandre Díaz <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
from .assetsbundle import AssetsBundleCompanyColor
class QWeb(models.AbstractModel):
_inherit = "ir.qweb"
def _generate_asset_nodes_cache(
self,
bundle,
css=True,
js=True,
debug=False,
async_load=False,
defer_load=False,
lazy_load=False,
media=None,
):
res = super()._generate_asset_nodes(
bundle, css, js, debug, async_load, defer_load, lazy_load, media
)
if bundle == "web_company_color.company_color_assets":
asset = AssetsBundleCompanyColor(
bundle, [], env=self.env, css=True, js=True
)
res += [asset.get_company_color_asset_node()]
return res
def _get_asset_content(
self, bundle, nodeAttrs=None, defer_load=False, lazy_load=False
):
"""Handle 'special' web_company_color bundle"""
if bundle == "web_company_color.company_color_assets":
return [], []
return super()._get_asset_content(
bundle, nodeAttrs, defer_load=defer_load, lazy_load=lazy_load
)
| 31.275 | 1,251 |
901 | py | PYTHON | 15.0 | # Copyright 2020 Alexandre Díaz <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.http import request
from odoo.addons.base.models.assetsbundle import AssetsBundle, ScssStylesheetAsset
class AssetsBundleCompanyColor(AssetsBundle):
def get_company_color_asset_node(self):
"""Process the user active company scss and returns the node to inject"""
try:
active_company_id = int(
request.httprequest.cookies.get("cids", "").split(",")[0]
)
except Exception:
active_company_id = False
company_id = (
self.env["res.company"].browse(active_company_id) or self.env.company
)
asset = ScssStylesheetAsset(self, url=company_id.scss_get_url())
compiled = self.compile_css(asset.compile, asset.get_source())
return "style", {}, compiled
| 40.909091 | 900 |
712 | py | PYTHON | 15.0 | # Copyright (C) 2018 DynApps <http://www.dynapps.be>
# @author Stefan Rijnhart <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Show confirmation dialogue before copying records",
"version": "15.0.1.0.0",
"author": "Dynapps,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"license": "AGPL-3",
"category": "Tools",
"depends": [
"web",
],
"assets": {
"web.assets_backend": [
"web_copy_confirm/static/src/js/web_copy_confirm.js",
],
"web.qunit_suite_tests": [
"web_copy_confirm/static/tests/**/*",
],
},
"installable": True,
}
| 30.956522 | 712 |
846 | py | PYTHON | 15.0 | # Copyright 2016 Onestein (<http://www.onestein.eu>)
# Copyright 2018 Tecnativa - David Vidal
# Copyright 2018 Tecnativa - João Marques
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Web Disable Export Group",
"version": "15.0.2.0.0",
"license": "AGPL-3",
"author": "Onestein, Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"category": "Web",
"depends": ["web"],
"data": [
"security/groups.xml",
"security/ir.model.access.csv",
],
"installable": True,
"assets": {
"web.assets_backend": ["/web_disable_export_group/static/src/js/*.js"],
"web.assets_tests": ["/web_disable_export_group/static/src/tours/*.js"],
"web.assets_qweb": ["/web_disable_export_group/static/src/xml/**/*"],
},
}
| 36.73913 | 845 |
1,144 | py | PYTHON | 15.0 | # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2020 Tecnativa - João Marques
# Copyright 2022 Tecnativa - Víctor Martínez
import odoo.tests
from odoo.tests import new_test_user
@odoo.tests.tagged("post_install", "-at_install")
class TestTour(odoo.tests.HttpCase):
def setUp(self):
super().setUp()
new_test_user(
self.env,
login="user_not_export",
password="user_not_export",
groups="base.group_user,base.group_system",
)
new_test_user(
self.env,
login="user_export_xlsx",
password="user_export_xlsx",
groups="base.group_user,base.group_system,%s"
% ("web_disable_export_group.group_export_xlsx_data"),
)
def test_admin(self):
self.start_tour("/web", "export_tour_xlsx_button_ok", login="admin")
def test_user_not_export(self):
self.start_tour("/web", "export_tour_xlsx_button_ko", login="user_not_export")
def test_user_export_xlsx(self):
self.start_tour("/web", "export_tour_xlsx_button_ok", login="user_export_xlsx")
| 34.575758 | 1,141 |
535 | py | PYTHON | 15.0 | # Copyright 2018 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
from odoo.http import request
class Http(models.AbstractModel):
_inherit = "ir.http"
def session_info(self):
res = super().session_info()
user = request.env.user
res.update(
{
"group_xlsx_export_data": user
and user.has_group("web_disable_export_group.group_export_xlsx_data"),
}
)
return res
| 26.75 | 535 |
855 | py | PYTHON | 15.0 | # Copyright 2023 Tecnativa - David Vidal
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from odoo import models
class Base(models.AbstractModel):
_inherit = "base"
def export_data(self, fields_to_export):
"""Export fields for selected objects
:param fields_to_export: list of fields
:param raw_data: True to return value in native Python type
:rtype: dictionary with a *datas* matrix
This method is used when exporting data via client menu
"""
if self.env.user.has_group("web_disable_export_group.group_export_xlsx_data"):
fields_to_export = [
models.fix_import_export_id_paths(f) for f in fields_to_export
]
return {"datas": self._export_rows(fields_to_export)}
return super().export_data(fields_to_export)
| 37.173913 | 855 |
730 | py | PYTHON | 15.0 | # Copyright 2017 Therp BV, ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Client side message boxes",
"version": "15.0.1.0.0",
"author": "Therp BV, " "ACSONE SA/NV, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"license": "AGPL-3",
"category": "Hidden/Dependency",
"summary": "Show a message box to users",
"depends": ["web"],
"data": ["security/ir.model.access.csv"],
"assets": {
"web.assets_backend": [
"web_ir_actions_act_window_message/static/src/**/**.esm.js",
],
"web.assets_qweb": [
"web_ir_actions_act_window_message/static/src/**/**.xml",
],
},
}
| 34.761905 | 730 |
600 | py | PYTHON | 15.0 | # Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class IrActionsActWindowMessage(models.Model):
_name = "ir.actions.act_window.message"
_description = "Action Window Message"
_inherit = "ir.actions.actions"
_table = "ir_actions"
type = fields.Char(default="ir.actions.act_window.message")
def _get_readable_fields(self):
return super()._get_readable_fields() | {
"title",
"buttons",
"close_button_title",
"message",
"is_html_message",
}
| 28.571429 | 600 |
973 | py | PYTHON | 15.0 | # Copyright 2013 Therp BV (<http://therp.nl>).
# Copyright 2015 Pedro M. Baeza <[email protected]>
# Copyright 2015 Antonio Espinosa <[email protected]>
# Copyright 2017 Sodexis <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Clickable many2one fields for tree views",
"summary": "Open the linked resource when clicking on their name",
"version": "15.0.1.0.0",
"category": "Hidden",
"website": "https://github.com/OCA/web",
"author": "Therp BV, "
"Tecnativa, "
"Camptocamp, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": ["web"],
"data": [],
"assets": {
"web.assets_backend": [
"web_tree_many2one_clickable/static/src/js/*.js",
],
"web.assets_common": [
"web_tree_many2one_clickable/static/src/css/web_tree_many2one_clickable.scss",
],
},
}
| 33.551724 | 973 |
831 | py | PYTHON | 15.0 | # Copyright 2015 Francesco OpenCode Apruzzese <[email protected]>
# Copyright 2016 Antonio Espinosa <[email protected]>
# Copyright 2017 Thomas Binsfeld <[email protected]>
# Copyright 2017 Xavier Jiménez <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Web Environment Ribbon",
"version": "15.0.1.0.0",
"category": "Web",
"author": "Francesco OpenCode Apruzzese, "
"Tecnativa, "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"license": "AGPL-3",
"depends": ["web"],
"data": [
"data/ribbon_data.xml",
],
"auto_install": False,
"installable": True,
"assets": {
"web.assets_common": [
"web_environment_ribbon/static/**/*",
],
},
}
| 30.740741 | 830 |
1,043 | py | PYTHON | 15.0 | # Copyright 2019 Eric Lembregts
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests import common
class TestEnvironmentRibbonData(common.TransactionCase):
@classmethod
def setUpClass(cls):
super(TestEnvironmentRibbonData, cls).setUpClass()
cls.env["ir.config_parameter"].set_param("ribbon.name", "Test Ribbon {db_name}")
cls.env["ir.config_parameter"].set_param("ribbon.color", "#000000")
cls.env["ir.config_parameter"].set_param("ribbon.background.color", "#FFFFFF")
def test_environment_ribbon(self):
"""This test confirms that the data that is fetched by the javascript
code is the right title and colors."""
ribbon = self.env["web.environment.ribbon.backend"].get_environment_ribbon()
expected_ribbon = {
"name": "Test Ribbon {db_name}".format(db_name=self.env.cr.dbname),
"color": "#000000",
"background_color": "#FFFFFF",
}
self.assertDictEqual(ribbon, expected_ribbon)
| 40.115385 | 1,043 |
1,164 | py | PYTHON | 15.0 | # Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models
class WebEnvironmentRibbonBackend(models.AbstractModel):
_name = "web.environment.ribbon.backend"
_description = "Web Environment Ribbon Backend"
@api.model
def _prepare_ribbon_format_vals(self):
return {"db_name": self.env.cr.dbname}
@api.model
def _prepare_ribbon_name(self):
name_tmpl = self.env["ir.config_parameter"].sudo().get_param("ribbon.name")
vals = self._prepare_ribbon_format_vals()
return name_tmpl and name_tmpl.format(**vals) or name_tmpl
@api.model
def get_environment_ribbon(self):
"""
This method returns the ribbon data from ir config parameters
:return: dictionary
"""
ir_config_model = self.env["ir.config_parameter"]
name = self._prepare_ribbon_name()
return {
"name": name,
"color": ir_config_model.sudo().get_param("ribbon.color"),
"background_color": ir_config_model.sudo().get_param(
"ribbon.background.color"
),
}
| 32.333333 | 1,164 |
485 | py | PYTHON | 15.0 | # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "web_action_conditionable",
"version": "15.0.1.0.0",
"depends": ["base", "web"],
"data": [],
"author": "Cristian Salamea,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"license": "AGPL-3",
"assets": {
"web.assets_backend": [
"web_action_conditionable/static/src/js/field_one2many.js",
],
},
"installable": True,
}
| 30.3125 | 485 |
636 | py | PYTHON | 15.0 | # Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Web Domain Field",
"summary": """
Use computed field as domain""",
"version": "15.0.1.0.1",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"depends": ["web"],
"data": [],
"assets": {
"web.assets_backend": [
"/web_domain_field/static/lib/js/*.js",
],
"web.qunit_suite_tests": [
"/web_domain_field/static/tests/**/*.js",
],
},
"installable": True,
}
| 27.652174 | 636 |
474 | py | PYTHON | 15.0 | # Copyright 2022 Camptocamp SA (https://www.camptocamp.com).
# @author Iván Todorovich <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.tests import HttpCase, tagged
@tagged("-at_install", "post_install")
class TestQunit(HttpCase):
def test_qunit(self):
self.browser_js(
"/web/tests?module=web_domain_field&failfast",
"",
"",
login="admin",
)
| 29.5625 | 473 |
594 | py | PYTHON | 15.0 | # Copyright 2019 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Web Widget Domain Editor Dialog",
"summary": "Recovers the Domain Editor Dialog functionality",
"version": "15.0.1.0.0",
"category": "Web",
"author": "Tecnativa," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"license": "AGPL-3",
"depends": ["web"],
"assets": {
"web.assets_backend": [
"/web_widget_domain_editor_dialog/static/src/js/*.js",
],
},
"installable": True,
}
| 33 | 594 |
787 | py | PYTHON | 15.0 | # Copyright 2020 ForgeFlow, S.L.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Web Widget mpld3 Chart",
"category": "Hidden",
"summary": "This widget allows to display charts using MPLD3 library.",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"version": "15.0.1.0.0",
"website": "https://github.com/OCA/web",
"depends": ["web"],
"data": [],
"external_dependencies": {"python": ["mpld3==0.5.7", "beautifulsoup4"]},
"auto_install": False,
"development_status": "Beta",
"maintainers": ["JordiBForgeFlow", "ChrisOForgeFlow"],
"license": "LGPL-3",
"assets": {
"web.assets_backend": [
"web_widget_mpld3_chart/static/src/js/web_widget_mpld3_chart.esm.js",
],
},
}
| 34.217391 | 787 |
886 | py | PYTHON | 15.0 | # Copyright 2022 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import json
import logging
from odoo import api, models
_logger = logging.getLogger(__name__)
try:
import mpld3
from bs4 import BeautifulSoup
except (ImportError, IOError) as err:
_logger.debug(err)
class AbstractMpld3Parser(models.AbstractModel):
_name = "abstract.mpld3.parser"
_description = "Utility to parse ploot figure to json data for widget Mpld3"
@api.model
def convert_figure_to_json(self, figure):
html_string = mpld3.fig_to_html(figure, no_extras=True, include_libraries=False)
soup = BeautifulSoup(html_string, "lxml")
json_data = {
"style": soup.style.decode(),
"div": soup.div.get("id"),
"script": soup.script.decode_contents(),
}
return json.dumps(json_data)
| 26.848485 | 886 |
973 | py | PYTHON | 15.0 | # Copyright 2014 Therp BV (<http://therp.nl>).
# Copyright 2015 Leonardo Donelli @ MONKSoftware
# Copyright 2013 Marcel van der Boom <[email protected]>
# Copyright 2016 - TODAY Serpent Consulting Services Pvt. Ltd.
# (<http://www.serpentcs.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Show images in tree views via tooltip",
"version": "15.0.1.1.0",
"author": "Therp BV, "
"MONK Software, "
"Odoo Community Association (OCA), "
"Serpent Consulting Services Pvt. Ltd.",
"website": "https://github.com/OCA/web",
"license": "AGPL-3",
"category": "Web",
"depends": ["web"],
"data": [],
"demo": [
"demo/view_res_users.xml",
],
"assets": {
"web.assets_backend": [
"web_tree_image_tooltip/static/src/scss/common.scss",
"web_tree_image_tooltip/static/src/js/tooltip.js",
],
},
"installable": True,
}
| 32.433333 | 973 |
785 | py | PYTHON | 15.0 | # Copyright 2015 Therp BV <http://therp.nl>
# Copyright 2017 Tecnativa - Vicent Cubells
# Copyright 2018 Tecnativa - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Advanced search",
"summary": "Easier and more powerful searching tools",
"version": "15.0.1.1.2",
"author": "Therp BV, Tecnativa, Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"maintainers": ["ivantodorovich"],
"license": "AGPL-3",
"category": "Usability",
"depends": ["web"],
"assets": {
"web.assets_backend": [
"web_advanced_search/static/src/js/**/*.js",
],
"web.assets_qweb": [
"web_advanced_search/static/src/xml/**/*.xml",
],
},
}
| 32.708333 | 785 |
1,315 | py | PYTHON | 15.0 | # Copyright 2015 Holger Brunn <[email protected]>
# Copyright 2016 Pedro M. Baeza <[email protected]>
# Copyright 2018 Simone Orsi <[email protected]>
# Copyright 2020 CorporateHub (https://corporatehub.eu)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "2D matrix for x2many fields",
"version": "15.0.1.0.2",
"maintainers": ["ChrisOForgeFlow"],
"development_status": "Production/Stable",
"author": (
"Therp BV, "
"Tecnativa, "
"Camptocamp, "
"CorporateHub, "
"Odoo Community Association (OCA)"
),
"website": "https://github.com/OCA/web",
"license": "AGPL-3",
"category": "Hidden/Dependency",
"summary": "Show list fields as a matrix",
"depends": ["web"],
"data": [],
"installable": True,
"assets": {
"web.assets_backend": [
"web_widget_x2many_2d_matrix/static/src/scss/web_widget_x2many_2d_matrix.scss",
"web_widget_x2many_2d_matrix/static/src/js/2d_matrix_renderer.js",
"web_widget_x2many_2d_matrix/static/src/js/2d_matrix_view.js",
"web_widget_x2many_2d_matrix/static/src/js/abstract_view_matrix_limit_extend.js",
"web_widget_x2many_2d_matrix/static/src/js/widget_x2many_2d_matrix.js",
],
},
}
| 38.676471 | 1,315 |
799 | py | PYTHON | 15.0 | # Copyright 2016 Flavio Corpa <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Web Widget - Image Download",
"summary": "Allows to download any image from its widget",
"version": "15.0.1.0.0",
"category": "web",
"website": "https://github.com/OCA/web",
"author": "Tecnativa, Odoo Community Association (OCA), Kaushal Prajapati",
"license": "LGPL-3",
"application": False,
"installable": True,
"depends": ["web"],
"assets": {
"web.assets_backend": [
"web_widget_image_download/static/src/js/**/*",
"web_widget_image_download/static/src/scss/**/*",
],
"web.assets_qweb": [
"web_widget_image_download/static/src/xml/**/*",
],
},
}
| 34.73913 | 799 |
688 | py | PYTHON | 15.0 | # Copyright 2021 Tecnativa - Jairo Llopis
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
{
"name": "Calendar slot duration",
"summary": "Customizable calendar slot durations",
"version": "15.0.1.0.0",
"development_status": "Production/Stable",
"category": "Extra Tools",
"website": "https://github.com/OCA/web",
"author": "Tecnativa, Odoo Community Association (OCA)",
"maintainers": ["Yajo"],
"license": "LGPL-3",
"application": False,
"installable": True,
"assets": {
"web.assets_backend": [
"web_calendar_slot_duration/static/src/js/calendar_model.esm.js"
]
},
"depends": ["web"],
}
| 32.761905 | 688 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
3,252 | py | PYTHON | 15.0 | import setuptools
with open('VERSION.txt', 'r') as f:
version = f.read().strip()
setuptools.setup(
name="odoo-addons-oca-web",
description="Meta package for oca-web Odoo addons",
version=version,
install_requires=[
'odoo-addon-web_action_conditionable>=15.0dev,<15.1dev',
'odoo-addon-web_advanced_search>=15.0dev,<15.1dev',
'odoo-addon-web_calendar_slot_duration>=15.0dev,<15.1dev',
'odoo-addon-web_chatter_position>=15.0dev,<15.1dev',
'odoo-addon-web_company_color>=15.0dev,<15.1dev',
'odoo-addon-web_copy_confirm>=15.0dev,<15.1dev',
'odoo-addon-web_dialog_size>=15.0dev,<15.1dev',
'odoo-addon-web_disable_export_group>=15.0dev,<15.1dev',
'odoo-addon-web_domain_field>=15.0dev,<15.1dev',
'odoo-addon-web_drop_target>=15.0dev,<15.1dev',
'odoo-addon-web_environment_ribbon>=15.0dev,<15.1dev',
'odoo-addon-web_group_expand>=15.0dev,<15.1dev',
'odoo-addon-web_ir_actions_act_multi>=15.0dev,<15.1dev',
'odoo-addon-web_ir_actions_act_view_reload>=15.0dev,<15.1dev',
'odoo-addon-web_ir_actions_act_window_message>=15.0dev,<15.1dev',
'odoo-addon-web_listview_range_select>=15.0dev,<15.1dev',
'odoo-addon-web_m2x_options>=15.0dev,<15.1dev',
'odoo-addon-web_m2x_options_manager>=15.0dev,<15.1dev',
'odoo-addon-web_no_bubble>=15.0dev,<15.1dev',
'odoo-addon-web_notify>=15.0dev,<15.1dev',
'odoo-addon-web_pivot_computed_measure>=15.0dev,<15.1dev',
'odoo-addon-web_pwa_oca>=15.0dev,<15.1dev',
'odoo-addon-web_refresher>=15.0dev,<15.1dev',
'odoo-addon-web_remember_tree_column_width>=15.0dev,<15.1dev',
'odoo-addon-web_responsive>=15.0dev,<15.1dev',
'odoo-addon-web_search_with_and>=15.0dev,<15.1dev',
'odoo-addon-web_send_message_popup>=15.0dev,<15.1dev',
'odoo-addon-web_sheet_full_width>=15.0dev,<15.1dev',
'odoo-addon-web_time_range_menu_custom>=15.0dev,<15.1dev',
'odoo-addon-web_timeline>=15.0dev,<15.1dev',
'odoo-addon-web_tree_dynamic_colored_field>=15.0dev,<15.1dev',
'odoo-addon-web_tree_image_tooltip>=15.0dev,<15.1dev',
'odoo-addon-web_tree_many2one_clickable>=15.0dev,<15.1dev',
'odoo-addon-web_view_calendar_list>=15.0dev,<15.1dev',
'odoo-addon-web_widget_bokeh_chart>=15.0dev,<15.1dev',
'odoo-addon-web_widget_child_selector>=15.0dev,<15.1dev',
'odoo-addon-web_widget_domain_editor_dialog>=15.0dev,<15.1dev',
'odoo-addon-web_widget_dropdown_dynamic>=15.0dev,<15.1dev',
'odoo-addon-web_widget_image_download>=15.0dev,<15.1dev',
'odoo-addon-web_widget_json_graph>=15.0dev,<15.1dev',
'odoo-addon-web_widget_many2one_simple>=15.0dev,<15.1dev',
'odoo-addon-web_widget_mpld3_chart>=15.0dev,<15.1dev',
'odoo-addon-web_widget_numeric_step>=15.0dev,<15.1dev',
'odoo-addon-web_widget_open_tab>=15.0dev,<15.1dev',
'odoo-addon-web_widget_url_advanced>=15.0dev,<15.1dev',
'odoo-addon-web_widget_x2many_2d_matrix>=15.0dev,<15.1dev',
],
classifiers=[
'Programming Language :: Python',
'Framework :: Odoo',
'Framework :: Odoo :: 15.0',
]
)
| 51.619048 | 3,252 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=["setuptools-odoo"],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
106 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=["setuptools-odoo"],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=["setuptools-odoo"],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
100 | py | PYTHON | 15.0 | import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
| 16.666667 | 100 |
681 | py | PYTHON | 15.0 | # Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Web M2X Options Manager",
"summary": 'Adds an interface to manage the "Create" and'
' "Create and Edit" options for specific models and'
" fields.",
"version": "15.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Web",
"data": [
"security/ir.model.access.csv",
"views/ir_model.xml",
],
"demo": [
"demo/res_partner_demo_view.xml",
],
"depends": ["base", "web_m2x_options"],
"website": "https://github.com/OCA/web",
"installable": True,
}
| 29.608696 | 681 |
5,219 | py | PYTHON | 15.0 | # Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from lxml import etree
from odoo.exceptions import ValidationError
from odoo.tests.common import TransactionCase
from odoo.tools.safe_eval import safe_eval
class TestM2xCreateEditOption(TransactionCase):
def setUp(self):
super(TestM2xCreateEditOption, self).setUp()
ref = self.env.ref
# View to be used
self.view = ref("web_m2x_options_manager.res_partner_demo_form_view")
# res.partner model and fields
self.res_partner_model = ref("base.model_res_partner")
self.categ_field = ref("base.field_res_partner__category_id")
self.title_field = ref("base.field_res_partner__title")
self.users_field = ref("base.field_res_partner__user_ids")
# res.users model and fields
self.res_users_model = ref("base.model_res_users")
self.company_field = ref("base.field_res_users__company_id")
# Options setup
self.title_opt = self.env["m2x.create.edit.option"].create(
{
"field_id": self.title_field.id,
"model_id": self.res_partner_model.id,
"option_create": "set_true",
"option_create_edit": "set_true",
"option_create_edit_wizard": True,
}
)
self.categories_opt = self.env["m2x.create.edit.option"].create(
{
"field_id": self.categ_field.id,
"model_id": self.res_partner_model.id,
"option_create": "set_true",
"option_create_edit": "set_true",
"option_create_edit_wizard": True,
}
)
self.company_opt = self.env["m2x.create.edit.option"].create(
{
"field_id": self.company_field.id,
"model_id": self.res_users_model.id,
"option_create": "force_true",
"option_create_edit": "set_true",
"option_create_edit_wizard": False,
}
)
def test_errors(self):
with self.assertRaises(ValidationError):
# Fails ``_check_field_in_model``: model is res.partner, field is
# res.users's company_id
self.env["m2x.create.edit.option"].create(
{
"field_id": self.company_field.id,
"model_id": self.res_partner_model.id,
"option_create": "set_true",
"option_create_edit": "set_true",
}
)
with self.assertRaises(ValidationError):
# Fails ``_check_field_type``: users_field is a One2many
self.env["m2x.create.edit.option"].create(
{
"field_id": self.users_field.id,
"model_id": self.res_partner_model.id,
"option_create": "set_true",
"option_create_edit": "set_true",
}
)
def test_apply_options(self):
res = self.env["res.partner"].fields_view_get(self.view.id)
# Check fields on res.partner form view
form_arch = res["arch"]
form_doc = etree.XML(form_arch)
title_node = form_doc.xpath("//field[@name='title']")[0]
self.assertEqual(
safe_eval(title_node.attrib.get("options"), nocopy=True),
{"create": True, "create_edit": True},
)
self.assertEqual(
(
title_node.attrib.get("can_create"),
title_node.attrib.get("can_write"),
),
("true", "true"),
)
categ_node = form_doc.xpath("//field[@name='category_id']")[0]
self.assertEqual(
safe_eval(categ_node.attrib.get("options"), nocopy=True),
{"create": False, "create_edit": True},
)
self.assertEqual(
(
categ_node.attrib.get("can_create"),
categ_node.attrib.get("can_write"),
),
("true", "true"),
)
# Check fields on res.users tree view (contained in ``user_ids`` field)
tree_arch = res["fields"]["user_ids"]["views"]["tree"]["arch"]
tree_doc = etree.XML(tree_arch)
company_node = tree_doc.xpath("//field[@name='company_id']")[0]
self.assertEqual(
safe_eval(company_node.attrib.get("options"), nocopy=True),
{"create": True, "create_edit": True},
)
self.assertEqual(
(
company_node.attrib.get("can_create"),
company_node.attrib.get("can_write"),
),
("false", "false"),
)
# Update options, check that node has been updated too
self.title_opt.option_create_edit = "force_false"
res = self.env["res.partner"].fields_view_get(self.view.id)
form_arch = res["arch"]
form_doc = etree.XML(form_arch)
title_node = form_doc.xpath("//field[@name='title']")[0]
self.assertEqual(
safe_eval(title_node.attrib.get("options"), nocopy=True),
{"create": True, "create_edit": False},
)
| 39.240602 | 5,219 |
1,801 | py | PYTHON | 15.0 | # Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class IrModel(models.Model):
_inherit = "ir.model"
m2x_create_edit_option_ids = fields.One2many(
"m2x.create.edit.option",
"model_id",
)
def button_empty(self):
for ir_model in self:
ir_model._empty_m2x_create_edit_option()
def button_fill(self):
for ir_model in self:
ir_model._fill_m2x_create_edit_option()
def _empty_m2x_create_edit_option(self):
"""Removes every option for model ``self``"""
self.ensure_one()
self.m2x_create_edit_option_ids.unlink()
def _fill_m2x_create_edit_option(self):
"""Adds every missing field option for model ``self``"""
self.ensure_one()
existing = self.m2x_create_edit_option_ids.mapped("field_id")
valid = self.field_id.filtered(lambda f: f.ttype in ("many2many", "many2one"))
vals = [(0, 0, {"field_id": f.id}) for f in valid - existing]
self.write({"m2x_create_edit_option_ids": vals})
class IrModelFields(models.Model):
_inherit = "ir.model.fields"
@api.model
def name_search(self, name="", args=None, operator="ilike", limit=100):
res = super().name_search(name, args, operator, limit)
if not (name and self.env.context.get("search_by_technical_name")):
return res
domain = list(args or []) + [("name", operator, name)]
new_fids = self.search(domain, limit=limit).ids
for fid in [x[0] for x in res]:
if fid not in new_fids:
new_fids.append(fid)
if limit and limit > 0:
new_fids = new_fids[:limit]
return self.browse(new_fids).sudo().name_get()
| 34.634615 | 1,801 |
732 | py | PYTHON | 15.0 | # Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
class IrUiView(models.Model):
_inherit = "ir.ui.view"
def _postprocess_tag_field(self, node, name_manager, node_info):
res = super()._postprocess_tag_field(node, name_manager, node_info)
if node.tag == "field":
mname = name_manager.model._name
fname = node.attrib["name"]
field = self.env[mname]._fields.get(fname)
if field and field.type in ("many2many", "many2one"):
rec = self.env["m2x.create.edit.option"].get(mname, field.name)
if rec:
rec._apply_options(node)
return res
| 36.6 | 732 |
6,326 | py | PYTHON | 15.0 | # Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.tools.cache import ormcache
from odoo.tools.safe_eval import safe_eval
class M2xCreateEditOption(models.Model):
_name = "m2x.create.edit.option"
_description = "Manage Options 'Create/Edit' For Fields"
field_id = fields.Many2one(
"ir.model.fields",
domain=[("ttype", "in", ("many2many", "many2one"))],
ondelete="cascade",
required=True,
string="Field",
)
field_name = fields.Char(
related="field_id.name",
store=True,
string="Field Name",
)
model_id = fields.Many2one(
"ir.model",
ondelete="cascade",
required=True,
string="Model",
)
model_name = fields.Char(
compute="_compute_model_name",
inverse="_inverse_model_name",
store=True,
)
option_create = fields.Selection(
[
("none", "Do nothing"),
("set_true", "Add"),
("force_true", "Force Add"),
("set_false", "Remove"),
("force_false", "Force Remove"),
],
default="set_false",
help="Defines behaviour for 'Create' option:\n"
"* Do nothing: nothing is done\n"
"* Add/Remove: option 'Create' is set to True/False only if not"
" already present in view definition\n"
"* Force Add/Remove: option 'Create' is always set to True/False,"
" overriding any pre-existing option",
required=True,
string="Create Option",
)
option_create_edit = fields.Selection(
[
("none", "Do nothing"),
("set_true", "Add"),
("force_true", "Force Add"),
("set_false", "Remove"),
("force_false", "Force Remove"),
],
default="set_false",
help="Defines behaviour for 'Create & Edit' option:\n"
"* Do nothing: nothing is done\n"
"* Add/Remove: option 'Create & Edit' is set to True/False only if not"
" already present in view definition\n"
"* Force Add/Remove: option 'Create & Edit' is always set to"
" True/False, overriding any pre-existing option",
required=True,
string="Create & Edit Option",
)
option_create_edit_wizard = fields.Boolean(
default=True,
help="Defines behaviour for 'Create & Edit' Wizard\n"
"Set to False to prevent 'Create & Edit' Wizard to pop up",
string="Create & Edit Wizard",
)
_sql_constraints = [
(
"model_field_uniqueness",
"unique(field_id,model_id)",
"Options must be unique for each model/field couple!",
),
]
@api.model_create_multi
def create(self, vals_list):
# Clear cache to avoid misbehavior from cached :meth:`_get()`
type(self)._get.clear_cache(self.browse())
return super().create(vals_list)
def write(self, vals):
# Clear cache to avoid misbehavior from cached :meth:`_get()`
type(self)._get.clear_cache(self.browse())
return super().write(vals)
def unlink(self):
# Clear cache to avoid misbehavior from cached :meth:`_get()`
type(self)._get.clear_cache(self.browse())
return super().unlink()
@api.depends("model_id")
def _compute_model_name(self):
for opt in self:
opt.model_name = opt.model_id.model
def _inverse_model_name(self):
getter = self.env["ir.model"]._get
for opt in self:
# This also works as a constrain: if ``model_name`` is not a
# valid model name, then ``model_id`` will be emptied, but it's
# a required field!
opt.model_id = getter(opt.model_name)
@api.constrains("model_id", "field_id")
def _check_field_in_model(self):
for opt in self:
if opt.field_id.model_id != opt.model_id:
msg = _(
"%(field)s is not a valid field for model %(model)s!",
field=opt.field_name,
model=opt.model_name,
)
raise ValidationError(msg)
@api.constrains("field_id")
def _check_field_type(self):
ttypes = ("many2many", "many2one")
if any(o.field_id.ttype not in ttypes for o in self):
msg = _("Only Many2many and Many2one fields can be chosen!")
raise ValidationError(msg)
def _apply_options(self, node):
"""Applies options ``self`` to ``node``"""
self.ensure_one()
options = node.attrib.get("options") or {}
if isinstance(options, str):
options = safe_eval(options, dict(self.env.context or [])) or {}
for k in ("create", "create_edit"):
opt = self["option_%s" % k]
if opt == "none":
continue
mode, val = opt.split("_")
if mode == "force" or k not in options:
options[k] = val == "true"
node.set("options", str(options))
if not self.option_create_edit_wizard:
node.set("can_create", "false")
node.set("can_write", "false")
@api.model
def get(self, model_name, field_name):
"""Returns specific record for ``field_name`` in ``model_name``
:param str model_name: technical model name (i.e. "sale.order")
:param str field_name: technical field name (i.e. "partner_id")
"""
return self.browse(self._get(model_name, field_name))
@api.model
@ormcache("model_name", "field_name")
def _get(self, model_name, field_name):
"""Inner implementation of ``get``.
An ID is returned to allow caching (see :class:`ormcache`); :meth:`get`
will then convert it to a proper record.
:param str model_name: technical model name (i.e. "sale.order")
:param str field_name: technical field name (i.e. "partner_id")
"""
dom = [
("model_name", "=", model_name),
("field_name", "=", field_name),
]
# `_check_field_model_uniqueness()` grants uniqueness if existing
return self.search(dom, limit=1).id
| 34.568306 | 6,326 |
498 | py | PYTHON | 15.0 | # Copyright 2014-2021 Camptocamp SA
# License AGPL-3.0 or later (http://gnu.org/licenses/agpl).
{
"name": "Web Send Message as Popup",
"version": "15.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainer": "Camptocamp",
"license": "AGPL-3",
"category": "Hidden",
"depends": ["web", "mail"],
"website": "https://github.com/OCA/web",
"assets": {
"web.assets_backend": ["web_send_message_popup/static/src/models/**/*.js"]
},
}
| 33.2 | 498 |
925 | py | PYTHON | 15.0 | # Copyright 2020 Lorenzo Battistini @ TAKOBI
# Copyright 2020 Tecnativa - Alexandre D. Díaz
# Copyright 2020 Tecnativa - João Marques
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
{
"name": "Progressive web application",
"summary": "Make Odoo a PWA",
"version": "15.0.1.0.0",
"development_status": "Beta",
"category": "Website",
"website": "https://github.com/OCA/web",
"author": "TAKOBI, Tecnativa, Odoo Community Association (OCA)",
"maintainers": ["eLBati"],
"license": "LGPL-3",
"application": True,
"installable": True,
"depends": ["web", "mail"],
"data": ["templates/assets.xml", "views/res_config_settings_views.xml"],
"assets": {
"web.assets_backend": [
"/web_pwa_oca/static/src/js/pwa_manager.js",
"/web_pwa_oca/static/src/js/webclient.js",
]
},
"images": ["static/description/pwa.png"],
}
| 34.185185 | 923 |
4,948 | py | PYTHON | 15.0 | # Copyright 2020 João Marques
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
import base64
import json
import odoo.tests
from odoo import exceptions
from odoo.modules.module import get_resource_path
class TestUi(odoo.tests.HttpCase):
def setUp(self):
super().setUp()
self.user = self.env.ref("base.user_admin")
self.res_config_settings_obj = (
self.env["res.config.settings"].with_user(self.user).create({})
)
def test_manifest_valid_json(self):
# Call the manifest controller
manifest_data = self.url_open("/web_pwa_oca/manifest.webmanifest")
# should be valid json
manifest_content_str = manifest_data.content.decode("utf-8")
json.loads(manifest_content_str)
def test_manifest_correct_paramenters(self):
# Set PWA parameters in settings
self.res_config_settings_obj.pwa_name = "Test PWA"
self.res_config_settings_obj.pwa_short_name = "Test"
# icon should remain the default one
self.res_config_settings_obj.pwa_icon = False
self.res_config_settings_obj.set_values()
# Call the manifest controller
manifest_data = self.url_open("/web_pwa_oca/manifest.webmanifest")
manifest_content_str = manifest_data.content.decode("utf-8")
manifest_content = json.loads(manifest_content_str)
self.assertEqual(manifest_content["name"], "Test PWA")
self.assertEqual(manifest_content["short_name"], "Test")
# icon should remain the default one
self.assertEqual(
manifest_content["icons"][0]["src"],
"/web_pwa_oca/static/img/icons/icon-128x128.png",
)
self.assertEqual(manifest_content["icons"][0]["sizes"], "128x128")
self.assertTrue(manifest_content["icons"][0]["type"].startswith("image/png"))
def test_manifest_logo_upload(self):
with open(
"%s/static/img/icons/odoo_logo.svg" % get_resource_path("web_pwa_oca"), "rb"
) as fi:
icon_to_send = base64.b64encode(fi.read())
# Set PWA icon in settings
self.res_config_settings_obj.pwa_icon = icon_to_send
self.res_config_settings_obj.set_values()
# Call the manifest controller
manifest_data = self.url_open("/web_pwa_oca/manifest.webmanifest")
manifest_content_str = manifest_data.content.decode("utf-8")
manifest_content = json.loads(manifest_content_str)
self.assertEqual(manifest_content["icons"][0]["src"], "/web_pwa_oca/icon.svg")
self.assertTrue(manifest_content["icons"][0]["type"].startswith("image/svg"))
self.assertEqual(
manifest_content["icons"][0]["sizes"],
"128x128 144x144 152x152 192x192 256x256 512x512",
)
# Get the icon and compare it
icon_data = self.url_open("/web_pwa_oca/icon.svg")
icon_data_bytes = base64.b64encode(icon_data.content)
self.assertEqual(icon_data_bytes, icon_to_send)
def test_png_logo_upload(self):
with open(
"%s/static/img/icons/icon-512x512.png" % get_resource_path("web_pwa_oca"),
"rb",
) as fi:
icon_to_send = base64.b64encode(fi.read())
# Set PWA icon in settings
self.res_config_settings_obj.pwa_icon = icon_to_send
self.res_config_settings_obj.set_values()
# Call the manifest controller
manifest_data = self.url_open("/web_pwa_oca/manifest.webmanifest")
manifest_content_str = manifest_data.content.decode("utf-8")
manifest_content = json.loads(manifest_content_str)
expected_vals = {
"src": "/web_pwa_oca/icon512x512.png",
"sizes": "512x512",
"type": "image/png",
}
self.assertTrue(expected_vals in manifest_content["icons"])
def test_manifest_logo_upload_big(self):
# Set PWA icon in settings
with self.assertRaises(exceptions.UserError):
# Image with more than 2MB
self.res_config_settings_obj.pwa_icon = b"a" * 3000000
self.res_config_settings_obj.set_values()
def test_manifest_logo_upload_extension(self):
with self.assertRaises(exceptions.UserError):
# Image that is not SVG or PNG
self.res_config_settings_obj.pwa_icon = b"a" * 1000
self.res_config_settings_obj.set_values()
def test_manifest_logo_upload_small(self):
icon_to_send = None
with open(
"%s/static/img/icons/icon-128x128.png" % get_resource_path("web_pwa_oca"),
"rb",
) as fi:
icon_to_send = base64.b64encode(fi.read())
# Set PWA icon in settings
with self.assertRaises(exceptions.UserError):
# Image smaller than 512X512
self.res_config_settings_obj.pwa_icon = icon_to_send
self.res_config_settings_obj.set_values()
| 39.895161 | 4,947 |
6,116 | py | PYTHON | 15.0 | # Copyright 2020 Tecnativa - João Marques
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
import base64
import io
import sys
from PIL import Image
from odoo import _, api, exceptions, fields, models
from odoo.tools.mimetypes import guess_mimetype
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
_pwa_icon_url_base = "/web_pwa_oca/icon"
pwa_name = fields.Char(
"Progressive Web App Name", help="Name of the Progressive Web Application"
)
pwa_short_name = fields.Char(
"Progressive Web App Short Name",
help="Short Name of the Progressive Web Application",
)
pwa_icon = fields.Binary("Icon", readonly=False)
pwa_background_color = fields.Char("Background Color")
pwa_theme_color = fields.Char("Theme Color")
@api.model
def get_values(self):
config_parameter_obj_sudo = self.env["ir.config_parameter"].sudo()
res = super(ResConfigSettings, self).get_values()
res["pwa_name"] = config_parameter_obj_sudo.get_param(
"pwa.manifest.name", default="Odoo PWA"
)
res["pwa_short_name"] = config_parameter_obj_sudo.get_param(
"pwa.manifest.short_name", default="Odoo"
)
pwa_icon_ir_attachment = (
self.env["ir.attachment"]
.sudo()
.search([("url", "like", self._pwa_icon_url_base + ".")])
)
res["pwa_icon"] = (
pwa_icon_ir_attachment.datas if pwa_icon_ir_attachment else False
)
res["pwa_background_color"] = config_parameter_obj_sudo.get_param(
"pwa.manifest.background_color", default="#2E69B5"
)
res["pwa_theme_color"] = config_parameter_obj_sudo.get_param(
"pwa.manifest.theme_color", default="#2E69B5"
)
return res
def _unpack_icon(self, icon):
# Wrap decoded_icon in BytesIO object
decoded_icon = base64.b64decode(icon)
icon_bytes = io.BytesIO(decoded_icon)
return Image.open(icon_bytes)
def _write_icon_to_attachment(self, extension, mimetype, size=None):
url = self._pwa_icon_url_base + extension
icon = self.pwa_icon
# Resize image
if size:
image = self._unpack_icon(icon)
resized_image = image.resize(size)
icon_bytes_output = io.BytesIO()
resized_image.save(icon_bytes_output, format=extension.lstrip(".").upper())
icon = base64.b64encode(icon_bytes_output.getvalue())
url = "{}{}x{}{}".format(
self._pwa_icon_url_base,
str(size[0]),
str(size[1]),
extension,
)
# Retreive existing attachment
existing_attachment = (
self.env["ir.attachment"].sudo().search([("url", "like", url)])
)
# Write values to ir_attachment
values = {
"datas": icon,
"db_datas": icon,
"url": url,
"name": url,
"type": "binary",
"mimetype": mimetype,
}
# Rewrite if exists, else create
if existing_attachment:
existing_attachment.sudo().write(values)
else:
self.env["ir.attachment"].sudo().create(values)
@api.model
def set_values(self):
config_parameter_obj_sudo = self.env["ir.config_parameter"].sudo()
res = super(ResConfigSettings, self).set_values()
config_parameter_obj_sudo.set_param("pwa.manifest.name", self.pwa_name)
config_parameter_obj_sudo.set_param(
"pwa.manifest.short_name", self.pwa_short_name
)
config_parameter_obj_sudo.set_param(
"pwa.manifest.background_color", self.pwa_background_color
)
config_parameter_obj_sudo.set_param(
"pwa.manifest.theme_color", self.pwa_theme_color
)
# Retrieve previous value for pwa_icon from ir_attachment
pwa_icon_ir_attachments = (
self.env["ir.attachment"]
.sudo()
.search([("url", "like", self._pwa_icon_url_base)])
)
# Delete or ignore if no icon provided
if not self.pwa_icon:
if pwa_icon_ir_attachments:
pwa_icon_ir_attachments.unlink()
return res
# Fail if icon provided is larger than 2mb
if sys.getsizeof(self.pwa_icon) > 2196608:
raise exceptions.UserError(
_("You can't upload a file with more than 2 MB.")
)
# Confirm if the pwa_icon binary content is an SVG or PNG
# and process accordingly
decoded_pwa_icon = base64.b64decode(self.pwa_icon)
# Full mimetype detection
pwa_icon_mimetype = guess_mimetype(decoded_pwa_icon)
pwa_icon_extension = "." + pwa_icon_mimetype.split("/")[-1].split("+")[0]
if not pwa_icon_mimetype.startswith(
"image/svg"
) and not pwa_icon_mimetype.startswith("image/png"):
raise exceptions.UserError(
_("You can only upload SVG or PNG files. Found: %s.")
% pwa_icon_mimetype
)
# Delete all previous records if we are writting new ones
if pwa_icon_ir_attachments:
pwa_icon_ir_attachments.unlink()
self._write_icon_to_attachment(pwa_icon_extension, pwa_icon_mimetype)
# write multiple sizes if not SVG
if pwa_icon_extension != ".svg":
# Fail if provided PNG is smaller than 512x512
if self._unpack_icon(self.pwa_icon).size < (512, 512):
raise exceptions.UserError(
_("You can only upload PNG files bigger than 512x512")
)
for size in [
(128, 128),
(144, 144),
(152, 152),
(192, 192),
(256, 256),
(512, 512),
]:
self._write_icon_to_attachment(
pwa_icon_extension, pwa_icon_mimetype, size=size
)
| 38.459119 | 6,115 |
3,237 | py | PYTHON | 15.0 | # Copyright 2021 Tecnativa - Alexandre D. Díaz
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from odoo.http import request, route
from .main import PWA
class ServiceWorker(PWA):
JS_PWA_CORE_EVENT_INSTALL = """
self.addEventListener('install', evt => {{
console.log('[ServiceWorker] Installing...');
{}
}});
"""
JS_PWA_CORE_EVENT_FETCH = """
self.addEventListener('fetch', evt => {{
{}
}});
"""
JS_PWA_CORE_EVENT_ACTIVATE = """
self.addEventListener('activate', evt => {{
{}
}});
"""
JS_PWA_MAIN = """
self.importScripts(...{pwa_scripts});
odoo.define("web_pwa_oca.ServiceWorker", function (require) {{
"use strict";
{pwa_requires}
{pwa_init}
{pwa_core_event_install}
{pwa_core_event_activate}
{pwa_core_event_fetch}
}});
"""
def _get_js_pwa_requires(self):
return """
const PWA = require('web_pwa_oca.PWA');
"""
def _get_js_pwa_init(self):
return """
let promise_start = Promise.resolve();
if (typeof self.oca_pwa === "undefined") {{
self.oca_pwa = new PWA({});
promise_start = self.oca_pwa.start();
if (self.serviceWorker.state === "activated") {{
promise_start = promise_start.then(
() => self.oca_pwa.activateWorker(true));
}}
}}
""".format(
self._get_pwa_params()
)
def _get_js_pwa_core_event_install_impl(self):
return """
evt.waitUntil(oca_pwa.installWorker());
self.skipWaiting();
"""
def _get_js_pwa_core_event_activate_impl(self):
return """
console.log('[ServiceWorker] Activating...');
evt.waitUntil(oca_pwa.activateWorker());
self.clients.claim();
"""
def _get_js_pwa_core_event_fetch_impl(self):
return ""
@route("/service-worker.js", type="http", auth="public")
def render_service_worker(self):
"""Route to register the service worker in the 'main' scope ('/')"""
sw_code = self.JS_PWA_MAIN.format(
**{
"pwa_scripts": self._get_pwa_scripts(),
"pwa_requires": self._get_js_pwa_requires(),
"pwa_init": self._get_js_pwa_init(),
"pwa_core_event_install": self.JS_PWA_CORE_EVENT_INSTALL.format(
self._get_js_pwa_core_event_install_impl()
),
"pwa_core_event_activate": self.JS_PWA_CORE_EVENT_ACTIVATE.format(
self._get_js_pwa_core_event_activate_impl()
),
"pwa_core_event_fetch": self.JS_PWA_CORE_EVENT_FETCH.format(
self._get_js_pwa_core_event_fetch_impl()
),
}
)
return request.make_response(
sw_code,
[
("Content-Type", "text/javascript;charset=utf-8"),
("Content-Length", len(sw_code)),
],
)
| 30.528302 | 3,236 |
4,454 | py | PYTHON | 15.0 | # Copyright 2020 Lorenzo Battistini @ TAKOBI
# Copyright 2020 Tecnativa - Alexandre D. Díaz
# Copyright 2020 Tecnativa - João Marques
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
import json
from odoo.http import Controller, request, route
class PWA(Controller):
def _get_pwa_scripts(self):
"""Scripts to be imported in the service worker (Order is important)"""
return [
"/web/static/lib/underscore/underscore.js",
"/web_pwa_oca/static/src/js/worker/jquery-sw-compat.js",
"/web/static/src/legacy/js/promise_extension.js",
"/web/static/src/boot.js",
"/web/static/src/legacy/js/core/class.js",
"/web_pwa_oca/static/src/js/worker/pwa.js",
]
@route("/service-worker.js", type="http", auth="public")
def render_service_worker(self):
"""Route to register the service worker in the 'main' scope ('/')"""
return request.render(
"web_pwa_oca.service_worker",
{
"pwa_scripts": self._get_pwa_scripts(),
"pwa_params": self._get_pwa_params(),
},
headers=[("Content-Type", "text/javascript;charset=utf-8")],
)
def _get_pwa_params(self):
"""Get javascript PWA class initialzation params"""
return {}
def _get_pwa_manifest_icons(self, pwa_icon):
icons = []
if not pwa_icon:
for size in [
(128, 128),
(144, 144),
(152, 152),
(192, 192),
(256, 256),
(512, 512),
]:
icons.append(
{
"src": "/web_pwa_oca/static/img/icons/icon-%sx%s.png"
% (str(size[0]), str(size[1])),
"sizes": "{}x{}".format(str(size[0]), str(size[1])),
"type": "image/png",
"purpose": "any maskable",
}
)
elif not pwa_icon.mimetype.startswith("image/svg"):
all_icons = (
request.env["ir.attachment"]
.sudo()
.search(
[
("url", "like", "/web_pwa_oca/icon"),
(
"url",
"not like",
"/web_pwa_oca/icon.",
), # Get only resized icons
]
)
)
for icon in all_icons:
icon_size_name = icon.url.split("/")[-1].lstrip("icon").split(".")[0]
icons.append(
{"src": icon.url, "sizes": icon_size_name, "type": icon.mimetype}
)
else:
icons = [
{
"src": pwa_icon.url,
"sizes": "128x128 144x144 152x152 192x192 256x256 512x512",
"type": pwa_icon.mimetype,
}
]
return icons
def _get_pwa_manifest(self):
"""Webapp manifest"""
config_param_sudo = request.env["ir.config_parameter"].sudo()
pwa_name = config_param_sudo.get_param("pwa.manifest.name", "Odoo PWA")
pwa_short_name = config_param_sudo.get_param(
"pwa.manifest.short_name", "Odoo PWA"
)
pwa_icon = (
request.env["ir.attachment"]
.sudo()
.search([("url", "like", "/web_pwa_oca/icon.")])
)
background_color = config_param_sudo.get_param(
"pwa.manifest.background_color", "#2E69B5"
)
theme_color = config_param_sudo.get_param("pwa.manifest.theme_color", "#2E69B5")
return {
"name": pwa_name,
"short_name": pwa_short_name,
"icons": self._get_pwa_manifest_icons(pwa_icon),
"start_url": "/web",
"display": "standalone",
"background_color": background_color,
"theme_color": theme_color,
}
@route("/web_pwa_oca/manifest.webmanifest", type="http", auth="public")
def pwa_manifest(self):
"""Returns the manifest used to install the page as app"""
return request.make_response(
json.dumps(self._get_pwa_manifest()),
headers=[("Content-Type", "application/json;charset=utf-8")],
)
| 37.1 | 4,452 |
654 | py | PYTHON | 15.0 | # Copyright 2016 Savoir-faire Linux
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Web No Bubble",
"version": "15.0.1.0.0",
"author": "Savoir-faire Linux, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"license": "AGPL-3",
"category": "Web",
"summary": "Remove the bubbles from the web interface",
"depends": ["web"],
"installable": True,
"application": False,
"assets": {
"web.assets_backend": ["web_no_bubble/static/src/css/web_no_bubble.scss"],
"web.assets_frontend": ["web_no_bubble/static/src/css/web_no_bubble.scss"],
},
}
| 34.421053 | 654 |
745 | py | PYTHON | 15.0 | {
"name": "Web Widget JSON Graph",
"version": "15.0.1.0.0",
"author": "Vauxoo, Odoo Community Association (OCA)",
"license": "LGPL-3",
"category": "Hidden/Dependency",
"website": "https://github.com/OCA/web",
"maintainers": [
"luisg123v",
"frahikLV",
],
"summary": "Draw json fields with graphs.",
"depends": [
"web",
],
"data": [],
"assets": {
"web.assets_backend": [
"web_widget_json_graph/static/src/js/web_widget_json_graph.js",
],
"web.assets_qweb": [
"web_widget_json_graph/static/src/xml/web_widget_json_graph.xml",
],
},
"auto_install": False,
"installable": True,
"application": False,
}
| 26.607143 | 745 |
761 | py | PYTHON | 15.0 | # Copyright 2018 Therp BV <https://therp.nl>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": "Drop target support",
"version": "15.0.1.0.1",
"author": "Therp BV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"license": "LGPL-3",
"category": "Usability",
"summary": "Allows to drag files into Odoo",
"depends": ["web"],
"data": [],
"assets": {
"web.assets_backend": [
"web_drop_target/static/lib/base64js.min.js",
"web_drop_target/static/src/js/web_drop_target.js",
"web_drop_target/static/src/scss/web_drop_target.scss",
],
"web.assets_qweb": ["web_drop_target/static/src/xml/widgets.xml"],
},
}
| 36.238095 | 761 |
671 | py | PYTHON | 15.0 | {
"name": "Web Remember Tree Column Width",
"summary": "Remember the tree columns' widths across sessions.",
"author": "Vauxoo, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"license": "LGPL-3",
"category": "Extra Tools",
"version": "15.0.1.0.1",
"maintainers": [
"frahikLV",
"luisg123v",
],
"depends": [
"web",
],
"data": [],
"assets": {
"web.assets_backend": [
"web_remember_tree_column_width/static/src/js/list_renderer.js",
"web_remember_tree_column_width/static/src/scss/main.scss",
],
},
"installable": True,
}
| 27.958333 | 671 |
794 | py | PYTHON | 15.0 | # Copyright 2020 Tecnativa - Alexandre D. Díaz
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Simple many2one widget",
"version": "15.0.1.1.0",
"license": "AGPL-3",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"depends": ["web"],
"installable": True,
"maintainers": ["Tardo"],
"demo": [
"demo/res_partner_view.xml",
],
"assets": {
"web.assets_backend": [
"web_widget_many2one_simple/static/src/css/many2one_simple.scss",
"web_widget_many2one_simple/static/src/js/many2one_simple_field.js",
],
"web.assets_qweb": [
"web_widget_many2one_simple/static/src/xml/many2one_simple.xml",
],
},
}
| 31.72 | 793 |