how show a preview of binary.fields in odoo 11 - odoo-11

I am beginner, my questions is... how show a binary.fields preview in new tab or pop-up?, my version is odoo-11, the files is any upload (docs, image, etc..) i see in module mail something but i not understand code.
i see more question for this, but in v11 don't work for me.
my code is simple:
.py:
fpath = fields.Binary(string='upload', attachment=True)
view.xml
<field name="fpath" filename="name" widget='binary'/>
thanks for you answers!!!

try this:
<field name="fpath" widget="image"/>

Related

Xpath, div with multiple classes

I feel really stupid: I just read this question How to get html elements with multiple css classes and the answer was very clear and straightforward but when I try to apply it on this HTML
<div class="header group">
I am completely unable to make it work.
Here are some of the variations I have tried
//*[contains (#class, ’header’) and contains (#class, ‘group’)]
//div[contains (#class, ’header’) and contains (#class, ‘group’)]
//div[contains (#class, ’header’)]
What am I missing here? Should be straightforward, shouldn't it?
Testing in Chrome Canary.
Updates
The invalid typographical apostrophes above happened when I copy-pasted into this form. I was using ' in the actual console.
I was playing around on an archived version of the page at the Wayback Machine (WM) and nothing worked. However, when trying on the live version, everything worked as expected (the problem with the live version was that the final element I was "aiming" at currently is missing but will return later on, therefore I used WM). Any ideas why // seems broken on WM? Even if WM adds a few levels of divs, // should be transparent about that, shouldn't it?
Just use this xpath.
//div[#class='header group']
you should use something like this
<xpath expr="//div[hasclass('header') and hasclass('group')]" position="replace">
<t>
xxxxxx
</t>
</xpath>

Show file upload progress in Essence framework

So I have a simple upload file form and I want to use essence-progress as a loading spinner while the file is being uploaded. I use XMLHttpRequest2 so I can track my progress and I get in real time the percent left.
Can essence-progress display that percentage number?
I'm thinking something like this:
<FileUpload>
<Progress progress={'progress'} type={'circle'} />
</FileUpload>
Thanks in advance!
Looking into the source code of essence-progress I don't think there is a direct way of doing this. However, you could maybe build a new component, something like this:
<FileUpload>
<Progress type={'circle'} />
<Percentage value={'progress'} />
</FileUpload>
as a quick way to solve this issue. And with CSS you position it on top of the progress bar.
I hope this helps. Keep me posted :)

How to use "editor" field type in joomla "repeatable" form field?

I am developing a module for Joomla 3.3.6. I want to use "editor" field type in "repeatable" field in the xml file. The code I am using is as follows:
<field
name="fpssibtos_img1subs"
type="Repeatable"
icon="list"
label="GLOBAL_SUBS"
description="GLOBAL_SUBS_DESC"
default="{'fpssibtos_img1sub':['test']}">
<fields name="params">
<fieldset hidden="true" name="fpssibtos_img1subs_modal" repeat="true">
<field
name="fpssibtos_img1sub"
default="test"
type="editor"
label="GLOBAL_SUB"
description="GLOBAL_SUB_DESC"
filter="safehtml"/>
</fieldset>
</fields>
</field>
The problem is the editor is not editable, I mean you cannot type anything in it.
I am using CKEditor, I changed it to TinyMCE and others ,but the problem persists. I know that repeatable form field is still buggy ,but I thought some of you guys might know the fix to this particular problem.
In case anyone else comes across this problem, the repeatable form fields only support simple field types. This is apparently due to Joomla not having a simple way for scripts to interact.
Comment on the issue from one of the devs here and here.

Joomla 2.5 'Alternative Menu Items' and 'Category Blog' (Multiple template layout overrides for the same component)

I've come across a very strange problem relating to 'Alternative Menu Items', the usage is described here:
http://docs.joomla.org/Layout_Overrides_in_Joomla_1.6
The following files are located in: templates/testtemplate/html/com_content/category and these are the steps I took:
These files:
blog.php, blog.xml, blog_children.php, blog_item.php, blog_links.php
Have been changed to:
bloggal.php, bloggal.xml, bloggal_children.php, bloggal_item.php, bloggal_links.php
For file bloggal.xml – I changed this part:
<layout title="COM_CONTENT_CATEGORY_VIEW_BLOG_TITLE"
To:
<layout title="Blog Gallery"
Then added sub headings to bloggal.php and bloggal_item.php so I can see if the child items are in effect.
Now the interesting part is bloggal.php works fine but the child items drawn from bloggal_item.php do not come up.
I've done this test with the same template on multiple Joomla installs, on one of them it seems to work and the rest it does not.
The only thing I can think of is Joomla may have had a regression since the working one was an updated install and the rest are more recent versions.
Any ideas?
Starting Joomla 1.6 you can choose an alternate layout for each category. Including those you have overrides for. No need to select an alternate layout when configuring menu items ;)
Sorry I should've posted this sooner. I figured out the issue, I renamed:
<field name="layout_type"
type="hidden"
default="blog"
/>
To:
<field name="layout_type"
type="hidden"
default="bloggal"
/>
Essentially looking for a model that doesn't exist.
If you did this, do the following to fix it:
Rename default="whatever" back to default="blog"
In your database go to _menu table
Look for your menu item via the title column
Head over to the params and change {"layout_type":"bloggal"... to {"layout_type":"blog"...

Form Submit differences in Firefox and Google Chrome (ColdFusion)

A few days ago i've made a little Coldfusion 9 script, but somehow after submitting the form the query won't run in Firefox. Everything works well in Google Chrome, but not in Firefox.
I've tried to Google it, but i can't find anything that relates to this problem. If something is unclear for you after reading this - just ask and i'll try to explain it better to you.
The script can be found on: http://pastebin.com/Bic28B3L
Kind regards,
You can leave your script as it is and replace
<cfif IsDefined('form.submit')>
with
<cfif CGI.REQUEST_METHOD IS "POST">
to check if the form was submitted.
My guess would be that FF and Chrome are handling the form element generated by this line differently:
<cfinput type='image' src='http://linehotel.org/c_images/bot_buy.png' name='submit' value='Koop deze badge nu'>
it looks like your code is checking that form.submit exists, so I would look at the source that this tag generates.
The other thing to try would be to install and run Fiddler and use it capture the submissions made by Chrome and FF and compare the two, particularly look at the WebForms tab on the request section. There'll be a difference there if it's browser-related.
The culprit is two-folds:
<cfinput type='image'...>
And
<cfif IsDefined('form.submit')>
Coldfusion will generate the HTML for your CFINPUT like this:
<input type="image"...
And Firefox will generate a form post like this:
submit.x: mouseclick x coords.
submit.y: mouseclick y coords.
Firefox will not return the name of the image in the form post. It will only return the X and Y values of the image map. What you will probably have to do is replace the <CFINPUT> TAG with an HTML <INPUT type="submit"> button and use CSS to apply an image to it. You may even consider checking for some other form variable in lieu of the submit button.
Looking at your code, you may also want to look at the cfqueryparam tag to help protect against sql injections and you may want to do your calculations outside the cfquery rather than in it... for example:
<cfquery name = "pay" datasource = "#DSN#">
UPDATE users
SET bots=#user.bots#-1
WHERE id=#user.id#
</cfquery>
may be better like this:
<Cfset xBots=user.bots-1>
<cfquery name = "pay" datasource = "#DSN#">
UPDATE users
SET bots=<cfqueryparam cfsqltype="cf_sql_integer" value="#xBots#">
WHERE id=<cfqueryparam cfsqltype="cf_sql_integer" value="#user.id#">
</cfquery

Resources