Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d57c6a90bb | |||
| f4b4dedb70 |
22
.gitignore
vendored
Normal file
22
.gitignore
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Python
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# Odoo
|
||||||
|
*.log
|
||||||
|
.env
|
||||||
|
.venv/
|
||||||
|
venv/
|
||||||
|
*.pot
|
||||||
|
*.po~
|
||||||
|
|
||||||
|
# VSCode
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
@ -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',
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -6,14 +6,14 @@ from PIL import Image
|
|||||||
|
|
||||||
from odoo import http
|
from odoo import http
|
||||||
from odoo.http import request
|
from odoo.http import request
|
||||||
from odoo.tools import image_process
|
from odoo.tools.image import image_process
|
||||||
from odoo.addons.sign.controllers.main import Sign
|
from odoo.addons.sign.controllers.main import Sign
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class SignController(Sign):
|
class SignController(Sign):
|
||||||
|
|
||||||
@http.route(['/sign/sign/<int:request_id>/<token>'], type='json', auth='public')
|
@http.route(['/sign/sign/<int:request_id>/<token>'], type='jsonrpc', auth='public')
|
||||||
def sign_document(self, request_id, token, signature=None, items=None, **kwargs):
|
def sign_document(self, request_id, token, signature=None, items=None, **kwargs):
|
||||||
if items:
|
if items:
|
||||||
# Filter items that look like images (base64)
|
# Filter items that look like images (base64)
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -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