-
-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] website_whatsapp: Migration to 16.0
- Loading branch information
Showing
4 changed files
with
41 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters