AttributeError 'get_frontend_session_info' odoo - odoo-15

I have a project in odoo15 running and created database, but after to try to open login page i have this error. Someone can help me please.
Error when render the template
AttributeError: 'ir.http' object has no attribute 'get_frontend_session_info'
Template: web.frontend_layout
Path: /t/html/head/script[2]/t
Node: <t t-out="json.dumps(request.env['ir.http'].get_frontend_session_info())"/>;
if (!/(^|;\s)tz=/.test(document.cookie)) {
const userTZ = Intl.DateTimeFormat().resolvedOptions().timeZone;
document.cookie = `tz=${userTZ}; path=/`;
} - - -

Go to your list databases ../web/database/manager and delete the database created.
Install the package qrcode
sudo pip install qrcode
Create again your database in ../web/database/manager
This work for me, I hope it helps you

For me the solution for this is go in the .../odoo/odoo/addons/base/models/ir_http.py and in this file adding the following script:
#api.model
def get_frontend_session_info(self):
return {
"is_admin": self.env.user._is_admin(),
"is_system": self.env.user._is_system(),
"is_website_user": self.env.user._is_public(),
"user_id": self.env.user.id,
"is_frontend": True,
}

Related

No tests found. Cypress could not detect tests in this file

I am working with Cypress and the cucumber plugin. When I try to run Cypress I keep getting
No tests found.
Cypress could not detect tests in this file
I am referencing another question regarding this error, but it was going into a missing a spec file which is not the problem here. I've imported the correct step definitions as per docs but it's not pointing to that either.
For now here is my file structure.
cypress -
-integrations
-BDD
-ecommerce
-ecommerce.spec.js
- ecommerce.feature
In my cypress.json file
"testFiles": "**/*.js",
"baseUrl": "https://localhost:17843/GfmAdminConsole/",
"env":{
"url":"https://rahulshettyacademy.com"
},
"reporter": "mochawesome"
}
and here is the code I am trying to run
import {Given,When,Then,And} from 'cypress-cucumber-preprocessor/steps'
import HomePage from "./HomePage"
import ProductPage from "./ProductPage"
import CheckOutPg from "./CheckOutPg"
/// <reference types="Cypress" />
Given('I open ECommerce Page',()=>{
cy.visit("https://rahulshettyacademy.com/angularpractice/")
})
//When using hook to load data, use non-es6 syntax for a function.....might need to check if this was updated in later releases
When('I add items to Cart',function(){
const homePage = new HomePage()
const productPage = new ProductPage()
homePage.getShopTab().click()
testData.productName.forEach((product)=>{
cy.selectProduct(product)
})
productPage.getCheckoutBtn().click()
})
And('Validate the total price of the items selected',()=>{
let sum = 0
let total;
const checkOut = new CheckOutPg()
checkOut.getItemPrices().each(($el,index,$list)=>{
let price = $el.text().split(' ')[1].trim()
sum = Number(sum) + Number(price);
}).then(()=>{
cy.log(sum)
})
checkOut.getTotal().then((el)=> {
total = el.text().split(' ')[1].trim()
expect(Number(total)).to.eq(sum)
})
})
Then('Select the country submit and verify Thank you',()=>{
cy.get(':nth-child(6) > :nth-child(5) > .btn').click()
cy.get('#country').type('United States')
cy.wait(6000)
cy.get('.suggestions > ul > li > a').click()
cy.get('input[type="checkbox"]').check({force:true})
cy.get('.ng-untouched > .btn').click()
cy.get('.alert').then((el)=>{
const text = el.text()
expect(text.includes('Success')).to.be.true
})
})
EDIT:
ecommerce.feature file
Feature: End to end Ecommerce validation
application Regression test
#focus
Scenario: Ecommerce products delivery
Given I open ecommerce page
When I add items to cart
And Validate the total prices
Then select the country submit and verify Thankyou
Any guidance would be appreciated and thank you in advance.
Check your cypress.json according to https://github.com/TheBrainFamily/cypress-cucumber-preprocessor#cypress-configuration there should be
"testFiles": "**/*.feature"
No tests found.
Cypress could not detect tests in this file
I also got this error. I did 2 things to resolve it.
I added "testFiles": "**/*.feature" to my cypress.json file, just like #lojza mentioned in their answer. Thanks, #lojza!
I added a Scenario to my .feature file. Now my .feature file has this structure:
Feature: My awesome feature
Background: Background name: Login to my awesome site
Given I login to my awesome site
Scenario: Add cool stuff. Then logout.
Then I logout

How to configure Create-react-app less module with customize-cra(2.x)?

I used create-react-app(typescripts) to build a project, and added antd#3.26.13 with customize-cra as the website I was following told me.
I would like use the module.css, and I want to use module.less, like css, but encountered some error messages:
./src/layout/basic.module.less (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-8-1!./node_modules/postcss-loader/src??postcss!./node_modules/less-loader/dist/cjs.js??ref--6-oneOf-8-3!./src/layout/basic.module.less)
ValidationError: Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
- options has an unknown property 'localIdentName'. These properties are valid:
object { url?, import?, modules?, sourceMap?, importLoaders?, localsConvention?, onlyLocals?, esModule? }
My code follows:
const {
override,
addWebpackAlias,
fixBabelImports,
addLessLoader,
addDecoratorsLegacy
} = require('customize-cra');
module.exports = override(
addWebpackAlias({
"#":require('path').resolve(__dirname,"src")
}),
fixBabelImports('import',{
libraryName:'antd',
libraryDirectory:'es',
style:true
}),
addLessLoader({
javascriptEnabled:true,
modifyVars:{'#primary-color':'#1DA57A'},
}),
addDecoratorsLegacy()
);
The current version of customize-cra isn't compatible with the latest version of create-react-app, to be precise with css-loader. Try to install customize-cra#next to get alpha version. They fixed that issue there.

Vue CLI 3 Nightwatch page object configuration

I'm using Vue CLI 3 version 3.0.5.
In project configuration, I use Nightwatch as e2e test tool.
I try to use page objects, so I had nightwatch.config.js file in project root, and add page_objects_path inside like below:
{
page_objects_path : "/tests/e2e/page-objects"
}
Then I create page-objects folder as this path: /tests/e2e/page-objects.
Then I setup a page object Entry.js under that folder and try to use it in test:
/tests/e2e/page-objects/Entry.js
vmodule.exports = {
'Test Page Object': browser => {
browser
.url(process.env.VUE_DEV_SERVER_URL)
.waitForElementVisible('#app', 5000)
browser.page.Entry().sayHello()
browser.end()
}
}
And the error message shows:
Cannot read property 'Entry' of undefined .
It looks like my page object setup is not correct...
Could anyone help providing a correct implementation of NightWatch page object in Vue CLI v3.0.5 ? Thanks...
Ah, I know why it won't work.
Because nightwatch.config.js is a javascript file, I should export it first, then the plugin can read it.
module.export = {
page_objects_path : "/tests/e2e/page-objects"
}
Sorry for the dumb question.

Keystonejs 4.0 File system storage adapter image preview

How do I get an image preview for a Types.File field in the admin UI.
It says "The FS adapter supports all the default Keystone file schema fields. It also additionally supports and enables the filename path (required)." However when I try (doc):
format: function(item, file){
return '<img src="/files/'+file.filename+'" style="max-width: 300px">'
}
Nothing appears in the UI
The format function hasn't been working for a while as far as I can tell from the Keystone GitHub. I don't know if the function exists in Keystone 4.0. Reference here.
You could fork the current beta and patch the function yourself if you need this immediately.
You can find it at https://github.com/keystonejs/keystone/blob/v4.0.0-beta.5/fields/types/file/FileType.js#L81
Doesn't seem right to me, though. I hope they will fix it before releasing 4.0, along with the missing File Array type.
Image previews are now possible in the latest master branch of keystone (see https://github.com/keystonejs/keystone/pull/4509). At the moment you need to depend on the git version of keystone, so put this in your package.json and run npm install:
"keystone": "https://github.com/keystonejs/keystone.git"
In your model, specify thumb: true on the image field in question. You also need the url property in the schema. For example:
const storage = new keystone.Storage({
adapter: keystone.Storage.Adapters.FS,
fs: {
path: keystone.expandPath('./uploads/images'),
publicPath: '/images/'
},
schema: {
url: true,
}
})
ImageUpload.add({
name: { type: Types.Key, index: true },
image: {
type: Types.File,
storage: myStorage,
thumb: true
},
createdTimeStamp: { type: String }
});
The admin UI should now show a small preview of the image and a link to it.

Lithium/Apache on Mac : can't access to the view

I have installed Lithium and tested on Mac.
I can't access to the views that i defined. I can only access to the index file.
My simple project is firstLithium. I set it in /Library/Webserver/Documents
In this project, i create 1 view named posts. Here after is the content of my MVC.
models/Posts.php :
<?php
namespace app\models;
class Posts extends \lithium\data\Model {
}
?>
views/posts/index.html.php :
Lithium is less dense than ium.
controllers/PostsController.php
<?php
namespace app\controllers;
class PostsController extends \lithium\action\Controller {
public function index() {
return array('foo' => 'bar', 'title' => 'Posts');
}
public function add() {
}
}
?>
From web browser :
localhost/firstLithium : it works well
localhost/firstLithium/posts : it doesn't work
Not Found
The requested URL /firstLithium/posts was not found on this server.
The same example can run on ubuntu, but not on Mac. Can i help you to run it on Mac. Thank you in advance.
Definitely looks like a problem with your web server settings, and not Lithium.
Try this guide and if the problem persist, feel free to ping me in #li3 IRC channel.
Also, make sure you have mod_rewrite enabled, for Apache. I'm not sure what the command is, for a Mac, but on Linux, it's:
sudo a2enmod rewrite