Skip to content

Commit

Permalink
Merge PR #2576 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by simahawk
  • Loading branch information
OCA-git-bot committed Oct 18, 2023
2 parents 5d73b16 + a9f2243 commit ca2e322
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions web_create_write_confirm/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"version": "14.0.1.0.0",
"depends": ["web"],
"author": "Smile, Odoo Community Association (OCA)",
"maintainers": ["ilyasProgrammer"],
"license": "AGPL-3",
"website": "https://github.com/OCA/web",
"category": "Tools",
Expand Down
7 changes: 3 additions & 4 deletions web_create_write_confirm/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
class BaseModel(models.AbstractModel):
_inherit = "base"

def get_message_informations(self, values=False):
def get_popup_message_info(self, values=False):
"""
This function gives us the possibility to know
if we display the message or not
Retrieve popup messages' data.
- In create self is empty
- In write self is not empty contains current ID
:param values:
Expand All @@ -22,7 +21,7 @@ def get_message_informations(self, values=False):
"""
return False

def execute_processing(self, values=False):
def process_popup_message(self, values=False):
"""
This function gives us the possibility to execute a
specific treatment after the confirmation of the message
Expand Down
4 changes: 2 additions & 2 deletions web_create_write_confirm/models/popup_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class PopupMessage(models.Model):
default="confirm",
selection=[("confirm", "Confirmation"), ("alert", "Alert")],
)
title = fields.Char(string="Title")
message = fields.Text(string="Message", required=True)
title = fields.Char(string="Title", translate=True)
message = fields.Text(string="Message", required=True, translate=True)
active = fields.Boolean(string="Active", default=True)

@api.depends("field_ids")
Expand Down
4 changes: 2 additions & 2 deletions web_create_write_confirm/readme/USAGE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Confirm res.partner change:
msg = self.env['popup.message'].create(
{
'model_id': self.env['ir.model'].search([('model', '=', 'res.partner')]).id,
'model_id': self.env['ir.model']._get_id('res.partner')
'field_ids': [(6, 0, self.env['ir.model.fields'].search([('model', '=', 'res.partner')]).ids)],
'popup_type': 'confirm',
'title': 'Warning',
Expand All @@ -24,7 +24,7 @@ Sale order alert:
msg = self.env['popup.message'].create(
{
'model_id': self.env['ir.model'].search([('model', '=', 'sale.order')]).id,
'model_id': self.env['ir.model']._get_id('sale.order'),
'field_ids': [(6, 0, self.env['ir.model.fields'].search([('model', '=', 'sale.order')]).ids)],
'popup_type': 'alert',
'title': 'Attention',
Expand Down
11 changes: 5 additions & 6 deletions web_create_write_confirm/static/src/js/pop_up_confirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ odoo.define("web_create_write_confirm.pop_up_confirmation", function (require) {
var changes = self.model.localData[self.handle]._changes;
self.getMessageInformation(
modelName,
"get_message_informations",
"get_popup_message_info",
record_id,
changes === null ? {} : changes
).then(function (results) {
this.display_popup(results, record, record_id, ev, changes, modelName);
self.display_popup(results, record, record_id, ev, changes, modelName);
});
},

Expand Down Expand Up @@ -76,11 +76,11 @@ odoo.define("web_create_write_confirm.pop_up_confirmation", function (require) {
} else if (popup_values.length === index) {
self.getMessageInformation(
modelName,
"execute_processing",
"process_popup_message",
record_id,
datas
);
this.save(ev);
this.save();
}
},
}).on("closed", null, resolve);
Expand All @@ -90,14 +90,13 @@ odoo.define("web_create_write_confirm.pop_up_confirmation", function (require) {
});
}
} else {
this.save(ev);
self.save();
}
});
},

save: function ev() {
var self = this;
ev.stopPropagation();
self._disableButtons();
self.saveRecord()
.then(self._enableButtons.bind(self))
Expand Down
4 changes: 2 additions & 2 deletions web_create_write_confirm/tests/test_base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_compute_field_name(self):

def test_get_message_informations(self):
"""Test correct flow of get_message_informations method"""
ret_value_of_method = self.base_model.get_message_informations()
ret_value_of_method = self.base_model.get_popup_message_info()
check_ret_value = False
if (ret_value_of_method is False) or isinstance(
ret_value_of_method, type(self.env["popup.message"])
Expand All @@ -51,5 +51,5 @@ def test_get_message_informations(self):
def test_execute_processing(self):
"""Test correct flow of execute_processing method"""
self.assertFalse(
self.base_model.execute_processing(), msg="Return value must be False"
self.base_model.process_popup_message(), msg="Return value must be False"
)

0 comments on commit ca2e322

Please sign in to comment.