how to display binary field data in website using a controller odoo 13 - odoo

I was creating a controller to gets information from custom module and wonted to display the pdf or image on the website how to get the url.
I was able to download it using this
return http.send_file(maybefiel, filename='sdsdds', as_attachment=False)
but I wonted to display it can you please help

You can access a binary field using the following path:
your_url/web/content/model_name/id/field_name
For example, the field name of a user's profile picture is called "image", so, the URL looks like something like this:
http://localhost:8069/web/content/res.users/1/image
Where 1 is the user id.

Related

How do I get a field in odoo 15 from res.partner module shown in account.move?

In odoo 15 I have created a PDF report for invoices using a custom layout via an external module. The address of the customer is specified at the top left of the first page of the PDF report. The content comes from the record that was created via "Customer" (res.partner) and selected via the field "partner_id". After the selection, the street and postal code as well as city are loaded in the edit view of an invoice and thus transferred to the PDF document.
How can I extend or overwrite the address field in my custom report layout to create an own address field that comes from the customer data (model res.partner)? I have created an additional field there via a module (address_suffix) that can store an address addition. I would like to be able to include this custom field of res.partner in the address field at account.move and in the end into the PDF report.
To illustrate it:
I want this field (address_suffix in res.partner)
can be seen here (account.move):
You can check the OCA partner_address_street3 module. It is similar to yours, it adds a third street field (street3) to store additional address information.
The module extends the address format, so it should automatically show on reports
On your report xm, I think you can try using t-field and using widget contact inside the t-options tag.
Example:
<span t-field="partner_id" t-options='{"widget": "contact", "fields": ["address"]}'/>

How to store URL in table and use as link on table?

I want to implement bookmark. I have problem with saving correct URL, when I store complete URL this link work till session is same as current.
I can store URL as:
'f?p=':APP_ID||':'||:APP_PAGE_ID
but what to store as a session? Pages are not public.
Don't reinvent the wheel - use APEX_PAGE.GET_URL instead. For example:
select APEX_PAGE.GET_URL (p_page => :APP_PAGE) as URL
from dual;
The result is then something like this:
f?p=12488:3:109743317382702:::::
Live screenshot from apex.oracle.com:

Access the image URL of a product

I am trying to get the image URL inside Edit Theme Files -> product.html
I already have some values like:
{{product.title}}, that gives me "Product name"
{{product.url}}, that gives me the URL
etc...
but no matter what i try, i can't get the URL.
The closest I got was using this: {{product.main_image.data}}
which gives me something like this:
https://cdn3.bigcommerce.com/s-8lxh1/images/stencil/%7B:size%7D/products/882/1700/RAM_VB_193_SW1__09586.1463668242.jpg?c=2
But that does not produce a image link.
Would appreciate any help or insights.
Thanks in advance!
The string that you're returning doesn't work because there's a "size" placeholder embedded in the URL. You can use Stencil's getImage Handlebars helper to specify the image dimensions and return a working URL:
{{getImage product.main_image.data "thumbnail"}}
The "thumbnail" string specifies an image size that exists in your theme settings. You can also specify a numeric size, like "200x200". Check out the docs here

Graph call Error When Getting User Page Information (Ruby on Rails)

I'm having some trouble making some graph calls with Koala.
Graph calls:
#graph_data = #api.get_object("me/books")
#account_data = #api.get_connections("me","accounts")
I have a do loop in my callback.html.erb that shows a table which displays the name of the user's favorite books.
(had to remove the html tags)
#graph.data.each do |data|
data["name"]
end
This code is fine, i get a table with all the book names.
The problem occurs when i want to display the #account_data object, this is supposed to hold the information of all the pages the user is an admin of.
I am expecting a table with the names of all the pages the user is subscribed to.
#account_data should have exactly two array elements since i am admin for two pages.
My understanding is that i should be getting an object that looks like this:
[{field1=>val1,field2=>val2,....}, {field1=>val1,field2=>val2,....}]
I tried using the Graph call #api.get_object("me/accounts") but same problem - blank screen.
Thanks in advance.

MVC user's full name in Url, how to handle duplicates

I want to setup the following url in my MVC4 website, using the user's full name in the url:
http://www.myapp.com/profile/steve-jones
I have setup the following route in Global.asax:
routeCollection.MapRoute(
"profile", "profile/{userName}",
new { controller = "myController", action = "profile", userName = string.Empty
});
And I can take the parameter 'steve-jones' and match it to a user with matching name. My only problem though is, what if there is more than one 'Steve Jones', how can I handle this?
Does anyone know of a workaround/solution to this so that I can use a user's full name as part of the url and still be able to retrieve the correct user in the controller method?
Am I forced into including the user's id with the url (something that I do not want to appear)?
The usual way of handling this is by appending a number when creating the profiles. So if "steve-jones" is already a name in the database, then make the user's display name "steve-jones2". You basically have to insist that all profile urls are unique, which includes updating any existing database and account creation code.
Alternatively (and/or additionally), if two same names are found then have the script reroute to a disambiguation page where the user is presented with links and snippet of profile info of the many existing Steve Joneseses so they can go to the full correct profile.
Another way of handling it is by giving all user profiles an additional numeric code on the end. At my university all logins are based on name, so they give everyone pseudo-random 3-digit extensions so that they are safe as long as they don't get 1000 people with the exact same names :)
Some people might be happier being steve-jones-342 if there is no steve-jones or steve-jones1, if you're concerned.