Template inheritance of the client-side in odoo 10 - odoo

I want add a link for download a demo file, in the template base_import. The original template is it as show below:
<t t-name="ImportView">
<t t-set="_id" t-value="_.uniqueId('export')"/>
<form action="" method="post" enctype="multipart/form-data" class="oe_import">
<input type="hidden" name="csrf_token" t-att-value="csrf_token"/>
<input type="hidden" name="session_id"
t-att-value="widget.session.session_id"/>
<input type="hidden" name="import_id"/>
<div class="oe_import_box col-sm-9">
<div class="col-sm-12">
<p>Select a CSV or Excel file to import. Help</p>
</div>
<div class="col-sm-10">
<div class="input-group">
<input type="text" class="oe_import_file_show form-control" placeholder="No file chosen..."/>
<span class="input-group-btn">
<label class="btn btn-primary" for="my-file-selector">
<input accept=".csv, .xls, .xlsx, .ods" id-attf-id="file_#{_id}"
name="file" id="my-file-selector" class="oe_import_file" type="file" style="display:none;"/>
Load File
</label>
</span>
<span class="input-group-btn">
<button type="button" class="btn btn-default oe_import_file_reload" disabled="disabled">Reload File</button>
</span>
</div>
</div>
<!-- More code -->
</div>
</form>
</t>
The code that i write for link add is:
<t t-name="BaseImportCustom" t-extend="ImportView">
<t t-jquery="form.oe_import" t-operation="append">
<p>Download Demo</p>
</t>
</t>
but this not show the link, Somebody know because not work? or if exist another way of do this

First, could you double check if xml file was already declared in __manifest__.py of your new module ?
Second, You shouldn't add t-name="BaseImportCustom" in your extend view, i believe the issue comes from t-name="BaseImportCustom", you can search all xml files in Odoo with the key "t-extend" and notice that there is no case that"t-extend" exist with "t-name". I hope this is OK (not test yet)
<t t-extend="ImportView">
<t t-jquery="form.oe_import" t-operation="append">
<p>Download Demo</p>
</t>
</t>

Related

asp- Tags are not highlighted in Blazor server side app

I have created a new server sided blazor app with no prebuild in authentication. Now I want to implement my own authentication with a custom AppDbContext.
The database is configured so far. Now I want to create a register page. I added a Razorpage to my Pages folder named Register.cshtml. I have already added the background C# logic and now I want to create a simple register form. But I have no clue why all asp- tags are not highlighted correctly as they do in a blank Blazor app with pre configured in app authentication.
Here is my form:
<form asp-route-returnUrl="#Model.ReturnUrl" method="post">
<h4>Account erstellen</h4>
<hr />
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-group">
<label asp-for="Input."></label>
<input asp-for="Input." class="form-control" />
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Input.Email"></label>
<input asp-for="Input.Email" class="form-control" />
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Input.Email"></label>
<input asp-for="Input.Email" class="form-control" />
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Input.Email"></label>
<input asp-for="Input.Email" class="form-control" />
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Input.Password"></label>
<input asp-for="Input.Password" class="form-control" />
<span asp-validation-for="Input.Password" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Input.ConfirmPassword"></label>
<input asp-for="Input.ConfirmPassword" class="form-control" />
<span asp-validation-for="Input.ConfirmPassword" class="text-danger"></span>
</div>
<button type="submit" class="btn btn-primary">Register</button>
</form>
In the prebuild app all asp- tags are bold in dark purple. In mine they look like default html tags. Moreover there is no Intellisense available.
Does anybody know what I did wrong here?
Also could someone explain me when I should create a rezor component instead of a razor page?
Thanks in advance!
Best
Marvin
I found a solution for the problem. I need to add
#addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
To my Razorpage file.

testcafe - Upload file

I need to test an upload screen, but I'm having a problem with the .setFilesToUpload. No file is being uploaded.
edit: If I debug, unlock page, click on upload file and select ANY other file, the field is filled with the script's file
I tried
.setFilesToUpload(Selector('input').withAttribute('type','file'), '../src/assets/logo.png')
and
.setFilesToUpload(Selector("#customInputFile"), "../src/assets/icon.png")
But in both cases, no file is being uploaded. The screen waits for it, but nothing happens.
<template>
<div>
<div class="file-container" v-if="!image">
<label>{{ label }}</label>
<div class="input-group">
<input
type="text"
#dragover="handleDragAndDrop"
#dragenter="handleDragAndDrop"
#dragleave="handleDragAndDrop($event, true)"
#drop="onFileChange"
v-bind:class="{ error: dataError }"
:placeholder="dataPlaceholder"
:value="dataFileName"
readonly
/>
<span class="input-group-btn">
<button class="file-button" type="button" #click="launchFilePicker">
SELECT A FILE
</button>
</span>
</div>
<input
type="file"
:value="filePayload"
#input="onFileChange"
ref="file"
id="customInputFile"
style="display: none"
/>
<span v-if="dataError" class="errorMessage">{{ dataErrorMessage }}</span>
</div>
<div class="file-container" v-else>
<img :src="image" />
<button #click="removeImage">Remove image</button>
</div>
</div>
</template>
I need to upload a file and pass the test.
I just need to add the onChange on my input, to call my script, that was only on input.
Thank you very much

Accessing template variable className properties in angular 2

I have the following form with name input field. I am trying to put validations on the field. When I print the name.className value it prints ng-valid, ng-pristine and other classes.
I want to use *ngIf to display the error message but it is not working.
I tried *ngIf="name.ng-invalid" also but it is not working. Can anyone suggest what is wrong here?
<form class="form-horizontal div-table" >
<!-- Name -->
<div class="form-group row-even">
<label class="col-md-4 control-label">Name:</label>
<div class="col-md-7">
<input id="name" name="name" type="text" class="form-control" [(ngModel)]="data.name" required minlength="3" maxlength="64" #name>
<small *ngIf="name.ng-invalid">
Name is required (minimum 3 characters).
</small>
<small>
Element {{ name.className }}
</small>
</div>
</div>
</form>
Try setting #name="ngModel" on the input.
Then remove "ng" from
<small *ngIf="name.ng-invalid">
like so
<small *ngIf="name.invalid">
Try this code
<form (ngSubmit)="onSubmit()" #myForm="ngForm">
...
<div [hidden]="name.valid || name.pristine"
class="alert alert-danger">
Name is required
</div>
...
</form>

upload a file using bootstrap uploader

I am using bootstrap file upload. My html code is give below
<div class="form-group">
<label>Video Name:</label>
<input class="form-control" placeholder="Video Name" id="vname" name="vname">
</div>
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Add files...</span>
<input type="file" name="files[]" id="fileupload1" multiple>
</span>
<button type="submit" class="btn btn-primary start">
<i class="glyphicon glyphicon-upload"></i>
<span>Start upload</span>
</button>
But when i look in Server side code in Request form there is vname value but files[] is empty. Please help how to get file data in server and save it on hard disk. Thanks
have you set the enctype attribute on the form to multipart/form-data?
<form enctype="multipart/form-data">

How to create an array of sub-forms with CForm?

I have an array of models, all of them being instances of one class. I need to create a form which contains subforms corresponding to the models from the array.
Have to use CForm, because i've made a nice small extension of it, which can render subforms in CJuiTabs. In the code used at the moment POST-parameter names are wrong, because they get prefixed by the name of the class of a model from the array.
Below you can see a snippet of HTML-code generated. See those YPageInfo[...] named inputs? That's the problem - only one set of inputs with this prefix gets received by the server.
<div style="visibility:hidden"><input type="hidden" value="1" name="yform_20bd4d2c" id="yform_20bd4d2c" /></div>
<div class="row field_name">
<label for="YPageRevision_name">Name</label>
<input name="YPageRevision[name]" id="YPageRevision_name" type="text" maxlength="45" />
</div>
<div class="row field_parent_id">
<label for="YPageRevision_parent_id">Parent Id</label>
<input id="YPageRevision_parent_id_hidden" name="YPageRevision[parent_id]" type="hidden" /><input id="YPageRevision_parent_id" type="text" value="" name="autocomplete-field" />
</div>
<div id="yw1">
<ul>
<li>en</li>
<li>ru</li>
</ul>
<div id="enSubFormTab"><div class="row field_title">
<label for="YPageInfo_title" class="required">Title <span class="required">*</span></label>
<input name="YPageInfo[title]" id="YPageInfo_title" type="text" maxlength="256" />
</div>
<div class="row field_content">
<label for="YPageInfo_content" class="required">Content <span class="required">*</span></label>
<textarea name="YPageInfo[content]" id="YPageInfo_content"></textarea>
</div>
</div>
<div id="ruSubFormTab"><div class="row field_title">
<label for="YPageInfo_title" class="required">Title <span class="required">*</span></label>
<input name="YPageInfo[title]" id="YPageInfo_title" type="text" maxlength="256" />
</div>
<div class="row field_content">
<label for="YPageInfo_content" class="required">Content <span class="required">*</span></label>
<textarea name="YPageInfo[content]" id="YPageInfo_content"></textarea>
</div>
</div>
</div>
<div class="row buttons"><input name="submit" type="submit" value="Create" />
</div>
I found one way to do what I needed.
In the elements property of the sub-form there are some inputs declared. Each standard input element declared there is an instance of CFormInputElement, so it has the attributes property. Here you can set any HTML attribute, which will be rendered in the resulting input tag. I put my custom name attribute here, and change it in a loop, where i create sub-forms configuration items for the main CForm.
Maybe there is a better way?