MuK IT GmbH
6 years ago
6 changed files with 101 additions and 7 deletions
-
23muk_web_client_refresh/__init__.py
-
4muk_web_client_refresh/__manifest__.py
-
5muk_web_client_refresh/doc/changelog.rst
-
1muk_web_client_refresh/models/__init__.py
-
62muk_web_client_refresh/models/base_automation.py
-
13muk_web_client_refresh/static/description/index.html
@ -0,0 +1,62 @@ |
|||||
|
################################################################################### |
||||
|
# |
||||
|
# Copyright (C) 2018 MuK IT GmbH |
||||
|
# |
||||
|
# This program is free software: you can redistribute it and/or modify |
||||
|
# it under the terms of the GNU Affero General Public License as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU Affero General Public License for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU Affero General Public License |
||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################### |
||||
|
|
||||
|
import logging |
||||
|
|
||||
|
from odoo import api, models, fields |
||||
|
|
||||
|
_logger = logging.getLogger(__name__) |
||||
|
|
||||
|
class BaseAutomation(models.Model): |
||||
|
|
||||
|
_inherit = 'base.automation' |
||||
|
|
||||
|
#---------------------------------------------------------- |
||||
|
# Functions |
||||
|
#---------------------------------------------------------- |
||||
|
|
||||
|
@api.model |
||||
|
def create_refresh_rules(self, model_name): |
||||
|
model = self.env['ir.model'].search( |
||||
|
[('model', '=', model_name)], limit=1) |
||||
|
if model_name in self.env and model.exists(): |
||||
|
triggers = [ |
||||
|
('on_create', 'Creation'), |
||||
|
('on_write', 'Update'), |
||||
|
('on_unlink', 'Deletion') |
||||
|
] |
||||
|
for trigger in triggers: |
||||
|
refresh_rules = self.search([ |
||||
|
('model_id', '=', model.id), |
||||
|
('trigger', '=', trigger[0]) |
||||
|
], limit=1) |
||||
|
if refresh_rules.exists(): |
||||
|
refresh_rules.write({ |
||||
|
'active': True |
||||
|
}) |
||||
|
else: |
||||
|
self.create({ |
||||
|
'trigger': trigger[0], |
||||
|
'state': 'refresh', |
||||
|
'model_id': model.id, |
||||
|
'name': "Refresh %s on %s" % ( |
||||
|
model.name, |
||||
|
trigger[1] |
||||
|
) |
||||
|
}) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue