Skip to content

Commit

Permalink
[MIG] website_whatsapp: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ioans73 committed May 11, 2023
1 parent a3f1be6 commit d8f5935
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 38 deletions.
2 changes: 1 addition & 1 deletion website_whatsapp/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Website Whatsapp",
"summary": "Whatsapp integration",
"category": "Website",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"website": "https://github.com/OCA/website",
"author": "Studio73, Odoo Community Association (OCA)",
"maintainers": ["ioans73"],
Expand Down
35 changes: 26 additions & 9 deletions website_whatsapp/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
# Copyright 2022 Studio73 - Ioan Galan <ioan@studio73.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo import api, fields, models


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

whatsapp_number = fields.Char(string="WhatsApp number")
@api.depends("website_id.whatsapp_number")
def _compute_whatsapp_enabled(self):
for record in self:
record.update({"whatsapp_enabled": bool(record.whatsapp_number)})

def _inverse_whatsapp_enabled(self):
for record in self:
if not record.whatsapp_enabled:
record.website_id.update({"whatsapp_number": False})

whatsapp_number = fields.Char(
related="website_id.whatsapp_number",
readonly=False,
)
whatsapp_text = fields.Char(
"Default text for Whatsapp",
help="Default text to send as message",
related="website_id.whatsapp_text",
readonly=False,
)
whatsapp_track_url = fields.Boolean(
"Track URL",
help="Indicate in the user's message the URL of the page from which it "
"was sent",
related="website_id.whatsapp_track_url",
readonly=False,
)
whatsapp_enabled = fields.Boolean(
string="Use Whatsapp",
compute="_compute_whatsapp_enabled",
inverse="_inverse_whatsapp_enabled",
)
35 changes: 9 additions & 26 deletions website_whatsapp/models/website.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,19 @@
# Copyright 2022 Studio73 - Ioan Galan <ioan@studio73.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
from odoo import fields, models


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

@api.depends("website_id.whatsapp_number")
def _compute_whatsapp_enabled(self):
for record in self:
record.update({"whatsapp_enabled": bool(record.whatsapp_number)})

def _inverse_whatsapp_enabled(self):
for record in self:
if not record.whatsapp_enabled:
record.website_id.update({"whatsapp_number": False})

whatsapp_number = fields.Char(
related="website_id.whatsapp_number",
readonly=False,
)
whatsapp_number = fields.Char(string="WhatsApp number")
whatsapp_text = fields.Char(
related="website_id.whatsapp_text",
readonly=False,
"Default text for Whatsapp",
help="Default text to send as message",
)
whatsapp_track_url = fields.Boolean(
related="website_id.whatsapp_track_url",
readonly=False,
)
whatsapp_enabled = fields.Boolean(
string="Use Whatsapp",
compute="_compute_whatsapp_enabled",
inverse="_inverse_whatsapp_enabled",
"Track URL",
help="Indicate in the user's message the URL of the page from which it "
"was sent",
)
7 changes: 5 additions & 2 deletions website_whatsapp/views/res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="website.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='social_media_settings']" position="after">
<div class="col-12 col-lg-6 o_setting_box" id="website_setting">
<xpath expr="//div[@id='website_email_marketing']" position="inside">
<div
class="col-12 col-lg-6 o_setting_box"
id="website_whatsapp_setting"
>
<div class="o_setting_left_pane">
<field name="whatsapp_enabled" />
</div>
Expand Down

0 comments on commit d8f5935

Please sign in to comment.