[14.0][ADD] web_create_write_confirm

This commit is contained in:
Ilyas
2023-04-25 09:48:29 +02:00
parent 320099cc10
commit 55ba3aab3b
18 changed files with 405 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
# (C) 2020 Smile (<https://www.smile.eu>)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from . import base
from . import popup_message

View File

@@ -0,0 +1,36 @@
# (C) 2020 Smile (<https://www.smile.eu>)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from odoo import models
class BaseModel(models.AbstractModel):
_inherit = "base"
def get_message_informations(self, values=False):
"""
This function gives us the possibility to know
if we display the message or not
- In create self is empty
- In write self is not empty contains current ID
:param values:
- In create dictionary contains all recording
information self is False
- In write we find only values changed
:type values: dict
:return: return dict object popup.message
(self.env['popup.message'].read())
"""
return False
def execute_processing(self, values=False):
"""
This function gives us the possibility to execute a
specific treatment after the confirmation of the message
- In create self is empty
- In write self is not empty contains current ID
:param values : a list of dictionaries:
{'name': field, 'value': value of field}
:type dictionary list
:return boolean
"""
return False

View File

@@ -0,0 +1,30 @@
from odoo import api, fields, models
class PopupMessage(models.Model):
_name = "popup.message"
_rec_name = "title"
_description = "Popup message"
model_id = fields.Many2one(
comodel_name="ir.model", string="Model", required=True, ondelete="cascade"
)
model = fields.Char(related="model_id.model")
field_ids = fields.Many2many(
comodel_name="ir.model.fields", required=True, string="Fields"
)
field_name = fields.Char(compute="_compute_field_name")
popup_type = fields.Selection(
string="Type",
required=True,
default="confirm",
selection=[("confirm", "Confirmation"), ("alert", "Alert")],
)
title = fields.Char(string="Title")
message = fields.Text(string="Message", required=True)
active = fields.Boolean(string="Active", default=True)
@api.depends("field_ids")
def _compute_field_name(self):
for message in self:
message.field_name = ",".join(f.name for f in message.field_ids)