fix error on odoo 19
This commit is contained in:
parent
f4b4dedb70
commit
d57c6a90bb
@ -15,11 +15,6 @@ This module extends the Odoo Sign module to allow users to upload images as a fi
|
|||||||
'data/sign_item_type_data.xml',
|
'data/sign_item_type_data.xml',
|
||||||
],
|
],
|
||||||
'assets': {
|
'assets': {
|
||||||
'web.assets_frontend': [
|
|
||||||
'sign_image_field/static/src/css/sign_image_field.css',
|
|
||||||
'sign_image_field/static/src/js/sign_image_upload.js',
|
|
||||||
'sign_image_field/static/src/xml/sign_items_image.xml',
|
|
||||||
],
|
|
||||||
'web.assets_backend': [
|
'web.assets_backend': [
|
||||||
'sign_image_field/static/src/css/sign_image_field.css',
|
'sign_image_field/static/src/css/sign_image_field.css',
|
||||||
'sign_image_field/static/src/js/sign_image_upload.js',
|
'sign_image_field/static/src/js/sign_image_upload.js',
|
||||||
|
|||||||
@ -8,3 +8,9 @@ class SignItemType(models.Model):
|
|||||||
_inherit = "sign.item.type"
|
_inherit = "sign.item.type"
|
||||||
|
|
||||||
item_type = fields.Selection(selection_add=[('image', "Image")], ondelete={'image': 'cascade'})
|
item_type = fields.Selection(selection_add=[('image', "Image")], ondelete={'image': 'cascade'})
|
||||||
|
|
||||||
|
def _compute_dimensions(self):
|
||||||
|
super(SignItemType, self.filtered(lambda r: r.item_type != 'image'))._compute_dimensions()
|
||||||
|
for record in self.filtered(lambda r: r.item_type == 'image'):
|
||||||
|
record.default_width = 0.2
|
||||||
|
record.default_height = 0.05
|
||||||
|
|||||||
1
tests/__init__.py
Normal file
1
tests/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
from . import test_sign_item_type
|
||||||
31
tests/test_sign_item_type.py
Normal file
31
tests/test_sign_item_type.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from odoo.tests.common import TransactionCase
|
||||||
|
|
||||||
|
class TestSignItemType(TransactionCase):
|
||||||
|
|
||||||
|
def test_image_item_type_dimensions(self):
|
||||||
|
""" Test that creating a sign item type of type 'image' computes dimensions correctly without error """
|
||||||
|
image_type = self.env['sign.item.type'].create({
|
||||||
|
'name': 'Test Image Field',
|
||||||
|
'item_type': 'image',
|
||||||
|
'field_size': 'regular_text', # Should be ignored for non-text types but required
|
||||||
|
})
|
||||||
|
|
||||||
|
# Trigger computation if not already done
|
||||||
|
image_type._compute_dimensions()
|
||||||
|
|
||||||
|
self.assertEqual(image_type.default_width, 0.2, "Default width for image should be 0.2")
|
||||||
|
self.assertEqual(image_type.default_height, 0.05, "Default height for image should be 0.05")
|
||||||
|
|
||||||
|
def test_other_item_type_dimensions(self):
|
||||||
|
""" Ensure standard types still work as expected """
|
||||||
|
signature_type = self.env['sign.item.type'].create({
|
||||||
|
'name': 'Test Signature',
|
||||||
|
'item_type': 'signature',
|
||||||
|
'field_size': 'regular_text',
|
||||||
|
})
|
||||||
|
signature_type._compute_dimensions() # Should rely on super
|
||||||
|
|
||||||
|
# Values from standard Odoo: 'signature': [0.2, 0.05]
|
||||||
|
self.assertEqual(signature_type.default_width, 0.2)
|
||||||
|
self.assertEqual(signature_type.default_height, 0.05)
|
||||||
Loading…
Reference in New Issue
Block a user