Browse Source

fixup! Add module custom_image

12.0-mig-module_prototyper_last
Patrick Tombez 5 years ago
parent
commit
a547d04701
  1. 1
      base_conditional_image/__init__.py
  2. 3
      base_conditional_image/__manifest__.py
  3. 1
      base_conditional_image/models/__init__.py
  4. 12
      base_conditional_image/models/abstract_image.py
  5. 11
      base_conditional_image/models/image.py

1
base_conditional_image/__init__.py

@ -1,2 +1 @@
# -*- coding: utf-8 -*-
from . import models from . import models

3
base_conditional_image/__manifest__.py

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Camptocamp SA
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
{ {

1
base_conditional_image/models/__init__.py

@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-
from . import image from . import image
from . import abstract_image from . import abstract_image

12
base_conditional_image/models/abstract_image.py

@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Camptocamp SA
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from openerp import fields, models
from openerp.tools.safe_eval import safe_eval
from odoo import fields, models
from odoo.tools.safe_eval import safe_eval
class AbstractImageStorage(models.AbstractModel):
class AbstractConditionalImage(models.AbstractModel):
_name = 'abstract.conditional.image' _name = 'abstract.conditional.image'
image = fields.Binary( image = fields.Binary(
@ -32,7 +31,8 @@ class AbstractImageStorage(models.AbstractModel):
def _compute_selector_test_with_company(image_selector, record): def _compute_selector_test_with_company(image_selector, record):
if (image_selector.company_id == record.company_id or if (image_selector.company_id == record.company_id or
record.company_id and not image_selector.company_id): record.company_id and not image_selector.company_id):
return AbstractImageStorage._compute_selector_test_without_company(
return AbstractConditionalImage\
._compute_selector_test_without_company(
image_selector, record image_selector, record
) )
return False return False

11
base_conditional_image/models/image.py

@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Camptocamp SA
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from openerp import api, fields, models, tools, _
from openerp.exceptions import ValidationError
from odoo import api, fields, models, tools, _
from odoo.exceptions import ValidationError
class Image(models.Model): class Image(models.Model):
@ -56,9 +55,9 @@ class Image(models.Model):
@api.model @api.model
def create(self, vals): def create(self, vals):
self._process_images(vals, required=True) self._process_images(vals, required=True)
return super(Image, self).create(vals)
return super().create(vals)
@api.multi @api.multi
def write(self, vals): def write(self, vals):
self._process_images(vals) self._process_images(vals)
return super(Image, self).write(vals)
return super().write(vals)
Loading…
Cancel
Save