diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2024-01-25 13:47:05 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2024-01-25 13:47:05 +0700 |
| commit | 0afeff9478a7aea67fbf3abed936390571aae788 (patch) | |
| tree | cf0f6e59721b173c56b3e457a7e8f9e28a51b3e7 /indoteknik_api/controllers/controller.py | |
| parent | 10eaf6d0c0a0ebf02030fe0854ca51f22fd3795e (diff) | |
Add model with watermark on image api
Diffstat (limited to 'indoteknik_api/controllers/controller.py')
| -rw-r--r-- | indoteknik_api/controllers/controller.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/indoteknik_api/controllers/controller.py b/indoteknik_api/controllers/controller.py index a3fb6fcb..7ceebbe3 100644 --- a/indoteknik_api/controllers/controller.py +++ b/indoteknik_api/controllers/controller.py @@ -186,11 +186,14 @@ class Controller(http.Controller): @http.route('/api/image/<model>/<field>/<id>', auth='public', methods=['GET']) def get_image(self, model, field, id, **kw): + model_name = model + model = request.env[model].sudo().search([('id', '=', id)], limit=1) image = model[field] if model[field] else '' + model_with_watermark = ['product.template', 'product.product'] watermark = kw.get('watermark', '') - if watermark.lower() == 'true': + if watermark.lower() == 'true' or model_name in model_with_watermark: image = self.add_watermark_to_image(image) response_headers = [ |
