Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to Odoo 13 #13

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# sphinx build directories
_build/

# dotfiles
.*
!.gitignore
!.mailmap
# compiled python files
*.py[co]
__pycache__/
# setup.py egg_info
*.egg-info
# emacs backup files
*~
# hg stuff
*.orig
status
# odoo filestore
odoo/filestore
# maintenance migration scripts
odoo/addons/base/maintenance

# generated for windows installer?
install/win32/*.bat
install/win32/meta.py

# needed only when building for win32
setup/win32/static/less/
setup/win32/static/wkhtmltopdf/
setup/win32/static/postgresql*.exe

# various virtualenv
/bin/
/build/
/dist/
/include/
/lib/
/man/
/share/
/src/
10 changes: 2 additions & 8 deletions formio/controllers/portal.py
Original file line number Diff line number Diff line change
@@ -76,19 +76,12 @@ def _formio_form_get_page_view_values(self, form, **kwargs):
request.env.cr.execute(query)
builder_lang_ids = [r[0] for r in request.env.cr.fetchall()]

# Always include english (en_US).
domain = ['|', ('id', 'in', builder_lang_ids), ('code', 'in', [request.env.user.lang, 'en_US'])]
languages = request.env['res.lang'].with_context(active_test=False).search(domain, order='name asc')
languages = languages.filtered(lambda r: r.id in builder_lang_ids or r.code == 'en_US')

values = {
'languages': [], # initialize, otherwise template/view crashes.
'languages': request.env['res.lang'].get_available(), # initialize, otherwise template/view crashes.
'user': request.env.user,
'form': form,
'page_name': 'formio',
}
if len(languages) > 1:
values['languages'] = languages

return self._get_page_view_values(form, False, values, 'my_formio', False, **kwargs)

@@ -130,6 +123,7 @@ def portal_form(self, uuid, **kwargs):
return request.redirect("/")

values = self._formio_form_get_page_view_values(form, **kwargs)
print(values)
return request.render("formio.portal_my_formio_edit", values)

@http.route(['/my/formio/create/<string:name>'], type='http', auth="user", method=['GET'], website=True)
49 changes: 24 additions & 25 deletions formio/models/formio_builder.py
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ class Builder(models.Model):
forms = fields.One2many('formio.form', 'builder_id', string='Forms')
portal = fields.Boolean("Portal", track_visibility='onchange', help="Form is accessible by assigned portal user")
view_as_html = fields.Boolean("View as HTML", track_visibility='onchange', help="View submission as a HTML view instead of disabled webform.")
wizard = fields.Boolean("Wizard", track_visibility='onchange')
# wizard = fields.Boolean("Wizard", track_visibility='onchange')
submit_done_url = fields.Char()
portal_submit_done_url = fields.Char()
translations = fields.One2many('formio.builder.translation', 'builder_id', string='Translations')
@@ -86,7 +86,7 @@ def constaint_check_name(self):
if re.search(r"[^a-zA-Z0-9_-]", self.name) is not None:
raise ValidationError('Name is invalid. Use ASCII letters, digits, "-" or "_".')

@api.one

@api.constrains("name", "state")
def constraint_one_current(self):
""" Per name there can be only 1 record with state current at
@@ -101,7 +101,7 @@ def constraint_one_current(self):
name=self.name)
raise ValidationError(msg)

@api.one

@api.constrains("name", "version")
def constraint_one_version(self):
""" Per name there can be only 1 record with same version at a
@@ -129,20 +129,20 @@ def _decode_schema(self, schema):
schema = ast.literal_eval(schema)
return schema

@api.onchange('wizard')
def _onchange_wizard(self):
if self.wizard:
if self.schema:
schema = self._decode_schema(self.schema)
schema['display'] = '"wizard"'
self.schema = json.dumps(schema)
else:
self.schema = '{"display": "wizard"}'
else:
if self.schema:
schema = self._decode_schema(self.schema)
del schema['display']
self.schema = json.dumps(schema)
# @api.onchange('wizard')
# def _onchange_wizard(self):
# if self.wizard:
# if self.schema:
# schema = self._decode_schema(self.schema)
# schema['display'] = '"wizard"'
# self.schema = json.dumps(schema)
# else:
# self.schema = '{"display": "wizard"}'
# else:
# if self.schema:
# schema = self._decode_schema(self.schema)
# del schema['display']
# self.schema = json.dumps(schema)

@api.depends('formio_res_model_id')
def _compute_res_model_id(self):
@@ -178,38 +178,38 @@ def _compute_act_window_url(self):
action=action.id)
r.act_window_url = url

@api.multi

def action_formio_builder(self):
return {
'type': 'ir.actions.act_url',
'url': self.edit_url,
'target': 'self',
}

@api.multi

def action_client_formio_builder(self):
return {
'type': 'ir.actions.client',
'tag': 'formio_builder',
'target': 'main',
}

@api.multi

def action_draft(self):
self.ensure_one()
self.write({'state': STATE_DRAFT})

@api.multi

def action_current(self):
self.ensure_one()
self.write({'state': STATE_CURRENT})

@api.multi

def action_obsolete(self):
self.ensure_one()
self.write({'state': STATE_OBSOLETE})

@api.multi

@api.returns('self', lambda value: value)
def copy_as_new_version(self):
"""Get last version for builder-forms by traversing-up on parent_id"""
@@ -229,7 +229,7 @@ def copy_as_new_version(self):
res = super(Builder, self).copy(alter)
return res

@api.multi

def action_new_builder_version(self):
self.ensure_one()
res = self.copy_as_new_version()
@@ -246,7 +246,6 @@ def action_new_builder_version(self):
"name": self.name,
"type": "ir.actions.act_window",
"res_model": "formio.builder",
"view_type": "form",
"view_mode": "form, tree",
"views": [
[form_view.id, "form"],
1 change: 0 additions & 1 deletion formio/models/formio_builder_translation.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@ class BuilderTranslation(models.Model):
source = fields.Text(string='Source Term', required=True)
value = fields.Text(string='Translated Value', required=True)

@api.multi
@api.depends('lang_id', 'source', 'value')
def name_get(self):
res = []
22 changes: 12 additions & 10 deletions formio/models/formio_form.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
import uuid

from odoo import api, fields, models, _
from odoo.exceptions import AccessError
from odoo.exceptions import AccessError, UserError

from ..utils import get_field_selection_label

@@ -73,7 +73,7 @@ class Form(models.Model):
portal_submit_done_url = fields.Char(related='builder_id.portal_submit_done_url')
allow_unlink = fields.Boolean("Allow delete", compute='_compute_access')

@api.multi

@api.depends('state')
def _compute_kanban_group_state(self):
for r in self:
@@ -114,15 +114,15 @@ def _decode_data(self, data):
data = ast.literal_eval(data)
return data

@api.multi

def action_client_formio_form(self):
return {
'type': 'ir.actions.client',
'tag': 'formio_form',
'target': 'main',
}

@api.multi

def action_draft(self):
self.ensure_one()
vals = {'state': STATE_DRAFT}
@@ -133,17 +133,17 @@ def action_draft(self):

self.write(vals)

@api.multi

def action_complete(self):
self.ensure_one()
self.write({'state': STATE_COMPLETE})

@api.multi

def action_cancel(self):
self.ensure_one()
self.write({'state': STATE_CANCEL})

@api.multi

def action_send_invitation_mail(self):
self.ensure_one()

@@ -162,7 +162,7 @@ def action_send_invitation_mail(self):
)
return {
'type': 'ir.actions.act_window',
'view_type': 'form',
# 'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'view_id': compose_form_id,
@@ -222,23 +222,25 @@ def _compute_act_window_url(self):
id=r.id,
model=r._name,
action=action.id)
# raise UserError(url)
r.act_window_url = url
r.act_window_multi_url = url

def _compute_res_fields(self):
for r in self:
r.res_act_window_url = False
r.res_name = False
r.res_info = False

@api.multi

def action_formio(self):
return {
'type': 'ir.actions.act_url',
'url': self.url,
'target': 'self',
}

@api.multi

def action_open_res_act_window(self):
raise NotImplementedError

2 changes: 1 addition & 1 deletion formio/models/formio_res_model.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ class ResModel(models.Model):
ir_model_id = fields.Many2one('ir.model', string='Model')
module_dependency = fields.Boolean(readonly=True)

@api.multi

def unlink(self):
if not self.module_dependency:
return super(ResModel, self).unlink()
2 changes: 1 addition & 1 deletion formio/models/formio_translation.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ class Translation(models.Model):
property = fields.Text(related='source_id.property', string='Property', readonly=True)
value = fields.Text(string='Translation Value', required=True)

@api.multi

@api.depends('lang_id', 'source_id', 'value')
def name_get(self):
res = []
1 change: 1 addition & 0 deletions formio/static/lib/bootstrap/4.1.3/bootstrap.min.css.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions formio/static/lib/iframe-resizer/iframeResizer.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions formio/static/src/js/formio_form.js
Original file line number Diff line number Diff line change
@@ -15,8 +15,7 @@ odoo.define('formio.formio_form_embed', ['web.ajax'], function (require) {
options_url = '/formio/form/options/' + uuid,
submission_url = '/formio/form/submission/' + uuid,
submit_url = '/formio/form/submit/' + uuid,
schema = {},
options = {};
schema = {};

ajax.jsonRpc(schema_url, 'call', {}).then(function(result) {
if (!$.isEmptyObject(result)) {
@@ -68,4 +67,4 @@ odoo.define('formio.formio_form_embed', ['web.ajax'], function (require) {
}
});
});
});
});
7 changes: 7 additions & 0 deletions formio/static/src/js/formio_form_portal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright Nova Code (http://www.novacode.nl)
// See LICENSE file for full licensing details.

$(document).ready(function() {
// var uuid = document.getElementById('form_uuid');
iFrameResize({}, '#formio_form_embed')
});
11 changes: 2 additions & 9 deletions formio/static/src/xml/formio.xml
Original file line number Diff line number Diff line change
@@ -52,17 +52,10 @@
</h1>
</div>
<div class="col-sm-4 col-md-4 formio_actions">
<button id="fullscreen_formio" class="pull-right">Fullscreen (Exit with ESC)</button>
<!-- <button id="fullscreen_formio" class="pull-right">Fullscreen (Exit with ESC)</button> -->
</div>
</div>
<iframe t-attf-src="/formio/builder/embed/#{widget.builder.id}" id="formio_builder_embed" allowfullscreen="true"></iframe>
<script>
var fullscreen = document.getElementById('fullscreen_formio');
var iframe = document.getElementById('formio_builder_embed');
fullscreen.addEventListener('click', (function () {
iframe.requestFullscreen();
}));
</script>
<iframe t-attf-src="/formio/builder/embed/#{widget.builder.id}" id="formio_builder_embed" allowfullscreen="false"></iframe>
</div>
</div>
</t>
8 changes: 4 additions & 4 deletions formio/views/formio_builder_views.xml
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ See LICENSE file for full licensing details. -->
<group>
<group name="form_settings" string="Form.io">
<field name="formio_version_id" placeholder="Select latest version only to try new form components." attrs="{'readonly': [('state', '!=', 'DRAFT')]}"/>
<field name="wizard" groups="formio.group_formio_admin" attrs="{'readonly': [('state', '!=', 'DRAFT')]}"/>
<!-- <field name="wizard" groups="formio.group_formio_admin" attrs="{'readonly': [('state', '!=', 'DRAFT')]}"/> -->
<field name="view_as_html" groups="formio.group_formio_admin"/>
</group>
<group name="integration_settings" string="Integration">
@@ -145,10 +145,10 @@ See LICENSE file for full licensing details. -->
<filter string="Not Portal" name="not_portal"
domain="[('portal', '=', False)]"/>
<separator/>
<filter string="Wizard" name="wizard"
<!-- <filter string="Wizard" name="wizard"
domain="[('wizard', '=', True)]"/>
<filter string="Not Wizard" name="not_portal"
domain="[('wizard', '=', False)]"/>
domain="[('wizard', '=', False)]"/> -->
<group expand="0" string="Group By">
<filter string="Name" name="name" domain="[]" context="{'group_by':'name'}"/>
<filter string="Assigned User" name="user" domain="[]" context="{'group_by':'user_id'}"/>
@@ -167,7 +167,7 @@ See LICENSE file for full licensing details. -->
<record id="action_formio_builder" model="ir.actions.act_window">
<field name="name">Form Builders</field>
<field name="res_model">formio.builder</field>
<field name="view_type">form</field>
<!-- <field name="view_type">form</field> -->
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_formio_builder_tree"/>
</record>
Loading