i'm new with Odoo 8. I added a Button in my module (inherit sale order) to be able to execute the method calkulateEKNew. The function is calling how it should be, but it looks like that the button is doing more stuff in the background. After clicking the button it saves the sale order and calls the method calkulateEKNew.
Is it possible to trigger this button or to find the logic behind the button ?
Nice regards
Buttons are available to execute python methods on the Odoo server.
If you want to execute JavaScript code, you'll have to add a (client-side) widget, possibly a template and a JavaScript file to your module.
This URL points to further information about simple widgets:
https://www.odoo.com/documentation/8.0/howtos/web.html#widgets-basics
I need to add the send button twice to my form build using Orbeon Form builder; the first one should display 'Submit' and the other one should display 'Print and Submit'. But I see that the first label is getting replaced by the last one. Can some one please tell me how to add two different labels for the same button when when adding it twice to the form. This for a requirement where the form need to have two buttons. First one should submit the form to a rest service( I am using send button for this) and the second one should print and submit the form to rest service. Please help.Thank you.
As you have found out, you cannot put the same button twice. They have to be different buttons, which means that they have a different name. If a button is called send then the other one must have another name like send-and-print.
So create one button called send, the other one must be called something else. So you simply create a new button following Button and processes.
The open-rendered-format action is new in Orbeon Forms 2017.1. You don't say which version you are using though.
I would also properly format the process so that you can easily take out and add parts, and see which part(s) fail:
<property as="xs:string" name="oxf.fr.detail.process.send-and-print.*.*">
require-uploads
then require-valid
then save
then open-rendered-format(format = "pdf")
then save-final
then send(uri="http://192.168.25.18:8080/RestService/rest/xml", content="xml", replace="instance") then
navigate("http://192.168.25.18:8080/email-sent-virgin-ausi.html")
recover navigate("http://192.168.25.18:8080/email-fail-virgin-ausi.html")
</property>
So I would like to be able to have a print button for entries in our database so users can print an entry via a print friendly "form".
My thought was to create a separate page, add labels and have those labels pull the relevant information.
I know I can add the open widget information via this code:
app.datasources.ModelName.selectKey(widget.datasource.item._key);
app.showPage(app.pages.TestPrint);
But I'm running into a few problems:
I can't get the page to open in a new window. Is this possible?
window.open(app.pages.TestPrint);
Just gives me a blank page. Does the browser lose the widget source once the new window opens?
I can't get the print option (either onClick or onDataLoad) to print JUST the image (or widget). I run
window.print();
And it includes headers + scroll bars. Do I need to be running a client side script instead?
Any help would be appreciated. Thank you!
To get exactly what you'd want you'd have to do a lot of work.
Here is my suggested, simpler answer:
Don't open up a new tab. If you use showPage like you mention, and provide a "back" button on the page to go back to where you were, you'll get pretty much everything you need. If you don't want the back to show up when you print, then you can setVisibility(false) on the button before you print, then print, then setVisibility(true).
I'll give a quick summary of how you could do this with a new tab, but it's pretty involved so I can't go into details without trying it myself. The basic idea, is you want to open the page with a full URL, just like a user was navigating to it.
You can use #TestPrint to indicate which page you want to load. You also need the URL of your application, which as far as I can remember is only available in a server-side script using the Apps Script method: ScriptApp.getService().getUrl(). On top of this, you'll probably need to pass in the key so that your page knows what data to load.
So given this, you need to assemble a url by calling a server script, then appending the key property to it. In the end you want a url something like:
https://www.script.google.com/yourappaddress#TestPage?key=keyOfYourModel.
Then on TestPage you need to read the key, and load data for that key. (You can read the key using google.script.url).
Alternatively, I think there are some tricks you can play by opening a blank window and then writing directly to its DOM, but I've never tried that, and since Apps Script runs inside an iframe I'm not sure if it's possible. If I get a chance I'll play with it and update this answer, but for your own reference you could look here: create html page and print to new tab in javascript
I'm imagining something like that, except that your page an write it's html content. Something like:
var winPrint = window.open('', '_blank', 'left=0,top=0,width=800,height=600,toolbar=0,scrollbars=0,status=0');
winPrint.document.write(app.pages.TestPage.getElement().innerHTML);
winPrint.document.close();
winPrint.focus();
winPrint.print();
winPrint.close();
Hope one of those three options helps :)
So here is what I ended up doing. It isn't elegant, but it works.
I added a Print Button to a Page Fragment that pops up when a user edits a database entry.
Database Edit Button code:
app.datasources.ModelName.selectKey(widget.datasource.item._key);
app.showDialog(app.pageFragments.FragmentName);
That Print Button goes to a different (full) Page and closes the Fragment.
Print Button Code:
app.datasources.ModelName.selectKey(widget.datasource.item._key);
app.showPage(app.pages.ModelName_Print);
app.closeDialog();
I made sure to make the new Print Page was small enough so that Chrome fits it properly into a 8.5 x 11" page (728x975).
I then created a Panel that fills the page and populated the page with Labels
#datasource.item.FieldName
I then put the following into the onDataLoad for the Panel
window.print();
So now when the user presses the Print Button in the Fragment they are taken to this new page and after the data loads they automatically get a print dialog.
The only downside is that after printing the user has to use a back button I added to return to the database page.
1.
As far as I know, you cannot combine window.open with app.pages.*, because
window.open would require url parameter at least, while app.pages.* is essentially an internal routing mechanism provided by App Maker, and it returns page object back, suitable for for switching between pages, or opening dialogs.
2.
You would probably need to style your page first, so like it includes things you would like to have printed out. To do so please use #media print
ex: We have a button on the page and would like to hide it from print page
#media print {
.app-NewPage-Button1 {
display : none;
}
}
Hope it helps.
1. Here is how it is done, in a pop up window, without messing up the current page (client script):
function print(widget, title){
var content=widget.getElement().innerHTML;
var win = window.open('', 'printWindow', 'height=600,width=800');
win.document.write('<head><title>'+title+'/title></head>');
win.document.write('<body>'+content+'</body>');
win.document.close();
win.focus();
win.print();
win.close();
}
and the onclick handler for the button is:
print(widget.root.descendants.PageFragment1, 'test');
In this example, PageFragment1 is a page fragment on the current page, hidden by adding a style with namehidden with definition .hidden{display:none;} (this is different than visible which in App Maker seems to remove the item from the DOM). Works perfectly...
2. You cannot open pages from the app in another tab. In principle something like this would do it:
var w=window.parent.parent;
w.open(w.location.protocol+'//'+w.location.host+w.location.pathname+'#PrintPage', '_blank');
But since the app is running in frame nested two deep from the launching page, and with a different origin, you will not be able to access the url that you need (the above code results in a cross origin frame access error). So you would have to hard code the URL, which changes at deployment, so it gets ugly very fast. Not that you want to anyway, the load time of an app should discourage you from wanting to do that anyway.
I want to create simple HTML button which links to other page when user clicks on it. I am new to Drupal, I've seen that we can create fields from "Structure>Content Types>Article>Manage Fields>Add new field - Field types.."
Can we create button from this way or we have to write code to create it?
Thanks
There is a beta module called Button Field that works with the Rules module. I believe will do what you're looking for. You can add a button to any fieldable entity and define a rule for it when it's pressed.
See https://drupal.org/project/button_field and https://drupal.org/project/rules
Buttons typically have to be coded. The way you're talking about above is the process for creating form elements for creating new pieces of content. If you want a simple button on a page to link to another page, you can just code it as follows:
<input type="button" value="Visit Another Page" onclick="location.href='your/other/web/page'" />
You may need to install a WYSIWYG text editor to add HTML to a page, if you don't already have one.
Or just use the Field Button module:
https://drupal.org/project/button_field
and create the buttons as you create fields...
With the help of views or webform, block module can create a button with out writing code.
I'm working on an app that, from the Main.mxml, opens one or many Window.mxml instances. When it's done I want all windows to be chromeless so the custom controls need to work.
In Main I've added applicationComplete="init();" so the init function gets ran, which contains clickhandlers, which makes the buttons work.
However, this way of running an init function doesn't seem to be valid for an mx:Window.
I can cheat by not using a clickhandler for the minimize and close buttons with a click="this.minimize();", but I don't know of a way like this to make the move work because it's a MOUSE_DOWN event.
Question 1:
Is there a way to have such an init function in an mx:Window?
Question 2:
What's a good way to make the buttons on the Window instances all work?
ps. If you think question 2 needs a separate post please let me know, they're so closely related and seemingly simple I couldn't decide.
Example code:
Main.mxml - http://pastebin.com/0HHVpkb8
Window.mxml - http://pastebin.com/g5TWuLYk
Window doesn't have an applicationComplete event, but it does have windowComplete event. Perhaps that would work for you. There is a list if Window events here.