8000 [14.0] [ADD] Module web_responsive_company_color by anusriNPS · Pull Request #2861 · OCA/web · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[14.0] [ADD] Module web_responsive_company_color #2861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions setup/web_responsive_company_color/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
5 changes: 3 additions & 2 deletions web_company_color/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
class ResCompany(models.Model):
_inherit = "res.company"

SCSS_TEMPLATE = """
def _get_scss_template(self):
return """
.o_main_navbar {
background-color: %(color_navbar_bg)s !important;
color: %(color_navbar_text)s !important;
Expand Down Expand Up @@ -205,7 +206,7 @@ def _scss_generate_content(self):
# 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()
return self._get_scss_template() % self._scss_get_sanitized_values()

def scss_get_url(self):
self.ensure_one()
Expand Down
87 changes: 87 additions & 0 deletions web_responsive_company_color/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
============================
Web Responsive Company Color
============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:95f3f27e763cdc5439f6171ba4f43af70f47d1cac864b762727d1e64dda9cc69
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/14.0/web_responsive_company_color
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-14-0/web-14-0-web_responsive_company_color
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module bridges web_company_color with web_responsive.

With this module, elements introduced or modified by web_responsive can be styled with the same logic as web_company_color.

**Table of contents**

.. contents::
:local:

Usage
=====

Simply install the app. See web_company_color for instructions on how to customize colors.

If new elements are included for customization under scss_template, one needs to reinstall the app to view customized colors.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_responsive_company_color%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Anusri Veerappan Prakasam

Contributors
~~~~~~~~~~~~

* PyTech SRL
* Alessandro Uffreduzzi <alessandro.uffreduzzi@pytech.it>
* Anusri Veerappan Prakasam <aprakhasam@nps100.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/web <https://github.com/OCA/web/tree/14.0/web_responsive_company_color>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions web_responsive_company_color/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .hooks import post_init_hook
17 changes: 17 additions & 0 deletions web_responsive_company_color/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "Web Responsive Company Color",
"summary": "Styling hooks for web_responsive elements",
"license": "AGPL-3",
"author": "Anusri Veerappan Prakasam, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"category": "Web",
"version": "14.0.1.0.0",
"depends": [
"web_company_color",
"web_responsive",
],
"data": [],
"post_init_hook": "post_init_hook",
"installable": True,
"application": False,
}
6 changes: 6 additions & 0 deletions web_responsive_company_color/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from odoo import SUPERUSER_ID, api


def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
env["res.company"].search([]).scss_create_or_update_attachment()
2 changes: 2 additions & 0 deletions web_responsive_company_color/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import res_company
from . import ir_module
17 changes: 17 additions & 0 deletions web_responsive_company_color/models/ir_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from odoo import models


class IrModule(models.Model):
_inherit = "ir.module.module"

def button_install(self):
res = super().button_install()
self.env["res.company"].search([]).scss_create_or_update_attachment()
return res

Check warning on line 10 in web_responsive_company_color/models/ir_module.py

View check run for this annotation

Codecov / codecov/patch

web_responsive_company_color/models/ir_module.py#L8-L10

Added lines #L8 - L10 were not covered by tests

def button_uninstall(self):
res = super().button_uninstall()
self.env["res.company"].search([]).with_context(

Check warning on line 14 in web_responsive_company_color/models/ir_module.py

View check run for this annotation

Codecov / codecov/patch

web_responsive_company_color/models/ir_module.py#L13-L14

Added lines #L13 - L14 were not covered by tests
uninstall_scss=True
).scss_create_or_update_attachment()
return res

Check warning on line 17 in web_responsive_company_color/models/ir_module.py

View check run for this annotation

Codecov / codecov/patch

web_responsive_company_color/models/ir_module.py#L17

Added line #L17 was not covered by tests
27 changes: 27 additions & 0 deletions web_responsive_company_color/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from odoo import models


class ResCompany(models.Model):
_inherit = "res.company"

# One need to reinstall web_responsive_company_color module
# to see customization takes effect when new elements added
# to _get_scss_template
def _get_scss_template(self):
uninstall_scss = self._context.get("uninstall_scss", False)

Check warning on line 11 in web_responsive_company_color/models/res_company.py

View check run for this annotation

Codecov / codecov/patch

web_responsive_company_color/models/res_company.py#L11

Added line #L11 was not covered by tests
if not uninstall_scss:
return (

Check warning on line 13 in web_responsive_company_color/models/res_company.py

View check run for this annotation

Codecov / codecov/patch

web_responsive_company_color/models/res_company.py#L13

Added line #L13 was not covered by tests
super()._get_scss_template()
+ """
.o_menu_apps .dropdown-menu {
background: url('/web_responsive/static/img/home-menu-bg-overlay.svg'),
linear-gradient(
to bottom,
%(color_navbar_bg)s,
desaturate(lighten(%(color_navbar_bg)s, 20%%), 15)
);
}
"""
)
else:
return super()._get_scss_template()

Check warning on line 27 in web_responsive_company_color/models/res_company.py

View check run for this annotation

Codecov / codecov/patch

web_responsive_company_color/models/res_company.py#L27

Added line #L27 was not covered by tests
3 changes: 3 additions & 0 deletions web_responsive_company_color/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* PyTech SRL
* Alessandro Uffreduzzi <alessandro.uffreduzzi@pytech.it>
* Anusri Veerappan Prakasam <aprakhasam@nps100.com>
3 changes: 3 additions & 0 deletions web_responsive_company_color/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module bridges web_company_color with web_responsive.

With this module, elements introduced or modified by web_responsive can be styled with the same logic as web_company_color.
Empty file.
3 changes: 3 additions & 0 deletions web_responsive_company_color/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Simply install the app. See web_company_color for instructions on how to customize colors.

If new elements are included for customization under scss_template, one needs to reinstall the app to view customized colors.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
0