From 5dc8b7bdd8ea8a760d1929333cd8461047e5b4e6 Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Tue, 14 Jul 2020 14:32:37 +0000 Subject: [IMP] *: replace default_get overrides by default attribute on fields. Leave the generic management of fields default to the orm as much as possible. * Default method is not called unless necessary. * Default values are correctly post-processed by the orm when necessary. --- addons/website/wizard/website_robots.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'addons/website') diff --git a/addons/website/wizard/website_robots.py b/addons/website/wizard/website_robots.py index 7172a3aa6b1..1d68aa4f22a 100644 --- a/addons/website/wizard/website_robots.py +++ b/addons/website/wizard/website_robots.py @@ -7,14 +7,7 @@ class WebsiteRobots(models.TransientModel): _name = "website.robots" _description = "Robots.txt Editor" - content = fields.Text() - - @api.model - def default_get(self, fields): - defaults = super(WebsiteRobots, self).default_get(fields) - if 'content' in fields: - defaults['content'] = self.env['website'].get_current_website().robots_txt - return defaults + content = fields.Text(default=lambda s: s.env['website'].get_current_website().robots_txt) def action_save(self): self.env['website'].get_current_website().robots_txt = self.content -- cgit v1.2.3