Skip to content

Commit

Permalink
Add scripts and model data
Browse files Browse the repository at this point in the history
  • Loading branch information
Lanhild committed Sep 6, 2024
1 parent 5284528 commit 9e653c9
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 220 deletions.
1 change: 1 addition & 0 deletions website_cookieconsent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

Check notice on line 3 in website_cookieconsent/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

website_cookieconsent/__init__.py#L3

'.models' imported but unused (F401)
4 changes: 2 additions & 2 deletions website_cookieconsent/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"name": "Website CookieConsent",
"summary": "CookieConsent integration",
"category": "Website",
"version": "14.0.1.0.0",
"version": "14.0.1.1.0",
"author": "Numigi",
"license": "AGPL-3",
"depends": ["website_cookiefirst"],
"depends": ["website"],
"data": [
"views/assets.xml",
"views/res_config_settings_views.xml",
Expand Down
98 changes: 0 additions & 98 deletions website_cookieconsent/i18n/en.json

This file was deleted.

98 changes: 0 additions & 98 deletions website_cookieconsent/i18n/fr.json

This file was deleted.

2 changes: 2 additions & 0 deletions website_cookieconsent/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import res_config_settings

Check notice on line 1 in website_cookieconsent/models/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

website_cookieconsent/models/__init__.py#L1

'.res_config_settings' imported but unused (F401)
from . import website

Check notice on line 2 in website_cookieconsent/models/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

website_cookieconsent/models/__init__.py#L2

'.website' imported but unused (F401)
20 changes: 20 additions & 0 deletions website_cookieconsent/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from odoo import api, fields, models

class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

@api.depends("website_id.cookieconsent_enabled")
def _compute_cookieconsent_enabled(self):
for record in self:
record.update({"cookieconsent_enabled": True})

def _inverse_cookieconsent_enabled(self):
for record in self:
record.website_id.update({"cookieconsent_enabled": False})

website_cookieconsent_enabled = fields.Boolean(
related="website_id.cookieconsent_enabled",
string="Use CookieConsent",
compute="_compute_cookieconsent_enabled",
inverse="_inverse_cookieconsent_enabled",
)
9 changes: 9 additions & 0 deletions website_cookieconsent/models/website.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import fields, models

class Website(models.Model):
_inherit = "website"

cookieconsent_enabled = fields.Boolean(
string="Use CookieConsent",
help="Display a cookie banner on your website."
)
31 changes: 15 additions & 16 deletions website_cookieconsent/views/assets.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<template id="assets_frontend">
<xpath expr="//script[last()]" position="after">
<script
type="module"
src="/website_cookieconsent/static/src/js/config.js"
/>
</xpath>
</template>

<template id="head" inherit_id="website.layout">
<template id="layout" inherit_id="website.layout">
<xpath expr="//head">
<link
rel="stylesheet"
href="/website_cookieconsent/static/src/css/style.css"
/>
<t t-if="website.cookieconsent_enabled">
<link
rel="stylesheet"
href="/website_cookieconsent/static/src/css/style.css"
/>
</t>
</xpath>
<xpath expr="//script[last()]" position="after">
<t t-if="website.cookieconsent_enabled">
<script
type="module"
src="/website_cookieconsent/static/src/js/config.js"
/>
</t>
</xpath>
</template>

</odoo>
22 changes: 16 additions & 6 deletions website_cookieconsent/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="website_cookiefirst.res_config_settings_view_form" />
<field name="inherit_id" ref="website.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='website_cookies_bar_setting']/div/div[hasclass('text-muted')]" position="replace">
<div class="text-muted">
Add CookieConsent functionality
<xpath expr="//div[@id='website_cookies_bar_setting']" position="inside">
<div class="o_setting_left_pane">
<field name="website_cookieconsent_enabled" />
</div>
<div class="o_setting_right_pane">
<label for="website_cookieconsent_enabled" />
<div class="text-muted">
Display a cookie banner on your website
</div>
<div
class="content-group"
attrs="{'invisible': [('website_cookieconsent_enabled', '=', False)]}"
id="cookieconsent_fields"
>
</div>
</div>
</xpath>
</field>
</record>

</odoo>

0 comments on commit 9e653c9

Please sign in to comment.