My ticket has many comments and I created a view for my comment and make a One2Many field in ticket model. But it is not displaying my desired view. Here is my model
class Ticket(model.Model):
_name = 'Tickets'
comment_ids = fields.One2many('comments', 'comment_id')
Here my second model
class Comments(models.Model):
_name = 'comments'
comment = fields.Text(string="Comment")
comment_id = fields.Char(string='Comment Id')
Here is my Ticket's View:
<notebook>
<page name="body" string="Body">
<field name="comment_ids" />
</page>
</notebook>
Here is my Comment's Form View:
<form>
<div class="form-group">
<label name="comment">Comment:</label>
<textarea class="form-control" rows="5" />
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
Here is my Comment's Tree View:
<tree>
<field name = 'comment_id'/>
<field name = 'comment'/>
</tree>
If your comment model have more than one tree view or form view, if you don't specify
witch view you want to display Odoo will compute the one with the highest priority:
so just specify the id of the tree view in your one2many field
<field name="comment_ids" context="{'tree_view_ref': 'your_app.tree_view_xml_id', 'form_view_ref': 'your_app.form_view_xml_id'}"/>
Or you can use embedded view:
<field name="comment_ids">
<tree>
<field name = 'comment_id'/>
<field name = 'comment'/>
</tree>
<form>
<div class="form-group">
<label name="comment">Comment:</label>
<textarea class="form-control" rows="5" />
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</field>
Note: if you have only this two views this means that Odoo didn't load this views so check if the XML file is in the manifest file and make sure you upgrade your module.
Related
I added one aura component to Opportunity lightening page. when doInit method start then That aura component will display popup component. I added some visibility filter conditions to that aura component so when conditions are met then component will display.
if i open opportunity record page in edit page mode then aura popup component is displaying.
Question : what is the best way to disable popup in page edit mode only.
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction"
access="global"
controller='CustomerProductRequirementsController'>
<aura:attribute name="isOpen" type="boolean" default="false" />
<aura:attribute name="areThereCPReqs" type="boolean" default="false" />
<aura:attribute name="disablebutton" type="boolean" default="false" />
<aura:attribute name="toggleSpinner" type="boolean" default="false"/>
<!--aura:attribute name="test" type="string" default="nothing"/-->
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<!--h1>info-{!v.test} </h1-->
<aura:if isTrue="{!v.isOpen}" >
<div style="height:640px">
<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<div class="slds-modal__content slds-p-around_medium" style="width:80%" id="modal-content-id-1">
<span class="slds-m-left_xx-large"><b>Are there customer product requirements? </b></span>
<lightning:button label="Yes" class="slds-button slds-button_brand slds-m-left_medium" onclick="{!c.handleYesORNoAction}" name="YES" disabled="{!v.disablebutton}"/>
<lightning:button label="No" class="slds-button slds-button_brand slds-m-left_small" onclick="{!c.handleYesORNoAction}" name="NO" disabled="{!v.disablebutton}"/>
<aura:if isTrue="{!v.toggleSpinner}">
<div class="slds-spinner slds-spinner_xx-small " role="alert" style="position:absolute;top:50%;left:5%;" aura:id="toggleSpinner" >
<lightning:spinner alternativeText="Loading" size="small" />
</div>
</aura:if>
</div>
</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</div>
</aura:if>
</aura:component>
**controller.js **
({
doInit: function(component, event, helper) {
component.set("v.isOpen", true);
},
handleYesORNoAction: function(component, event, helper) {
helper.Helper_CreateGCSRRecords(component,event);
component.set("v.disablebutton",true);
component.set("v.toggleSpinner", true);
},
})
I am trying to get the value of a textbox on a zul page by using some kind of getValue method. I should handle this on the zul page, not on a controller. I need to assign a listbox cell (which is the first cell of the list box below) with a value coming from the textbox.
<listcell>
<label value="" />
</listcell>
<listcell>
<toolbarbutton visible="true"
image="/resources/images/icons/1616/page_text.gif" />
</listcell>
<listcell>
<label value="#{file.name}" />
</listcell>
<listcell>
<toolbarbutton forward="onClick=onRemoveMultipleFiles"
visible="true" id="newFileAndCommentRemove" image="/resources/images/icons/1616/delete.png" />
</listcell>
</listitem>
If what you want is that after the textbox is filled then the first cell will fill with its value you can do it like this:
put an id into the label in the cell
put an onChange operation in the textbox so when the textbox change you can put its value into the cell
like this:
<textbox id="textbox" onChange="label.setValue(self.getValue())"/>
<listbox id="newFileAndComment">
<listhead>
<listheader label="1" width="30px" />
</listhead>
<listitem self="#{each=file}">
<listcell>
<label id="label"/>
</listcell>
</listitem>
I'm trying to create a JQM survey with branching questions--i.e. in a survey with questions 1-3, if you choose a particular answer on question 1, a question is dynamically added between questions 1 and 2.
UPDATE: I made an attempt ( https://dl.dropbox.com/u/17841063/site2/index-c1.html#page2 ) that works by matching the value of a radio button to the name of a hidden div--if there's a match, it unhides the div. The problem right now is that if you change your answer back to an option that wouldn't trigger the conditional question, it doesn't re-hide. For example, clicking No or Unsure in question A1 causes question A2 to appear, but if you then click Yes in A1, A2 still remains...
<script type="text/javascript">
// Place in this array the ID of the element you want to hide
var hide=['A2','A4'];
function setOpt()
{
resetOpt(); // Call the resetOpt function. Hide some elements in the "hide" array.
for(var i=0,sel=document.getElementsByTagName('input');i<sel.length;i++)
{
sel[i].onchange=function()
{
if(this.parentNode.tagName.toLowerCase()!='div')
resetOpt(); // Hides the elements in "hide" array when the first select element is choosen
try
{
document.getElementById(this.value).style.display='';
}
catch(e){} ; // When the value of the element is not an element ID
}
}
}
window.addEventListener?window.addEventListener('load',setOpt,false):
window.attachEvent('onload',setOpt);
function resetOpt()
{
for(var i=0;i<hide.length;i++)
document.getElementById(hide[i]).style.display='none'; // Hide the elements in "hide" array
}
</script>
Here's are the radio buttons that use the script above:
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>(Question A1) A prominent accident smokes on top of the blessed reactionary?</legend>
<input type="radio" name="aaa" id="aaa_0" value="notA2" />
<label for="aaa_0">Yes</label>
<input type="radio" name="aaa" id="aaa_1" value="A2" />
<label for="aaa_1">No</label>
<input type="radio" name="aaa" id="aaa_2" value="A2" />
<label for="aaa_2">Unsure</label>
</fieldset>
</div>
<div id="A2" data-role="fieldcontain">
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>(Question A2) Does a married composite remainder the shallow whistle??</legend>
<input type="radio" name="bbb" id="bbb_0" value="" />
<label for="bbb_0">Yes</label>
<input type="radio" name="bbb" id="bbb_1" value="" />
<label for="bbb_1">No</label>
<input type="radio" name="bbb" id="bbb_2" value="" />
<label for="bbb_2">Unsure</label>
</fieldset>
</div>
If anyone has ideas about fixing this, or examples of other ways to do branching forms, I'd be very grateful!
Thanks,
Patrick
I played around a little bit with your example, removed all your plain JavaScript and added some jQuery Mobile style script, see working example here
<script>
$("input[type='radio']").bind( "change", function(event, ui) {
var mySelection = $('input[name=aaa]:checked').val();
//alert(mySelection);
if (mySelection == "A2") {
$('#A2').removeClass('ui-hidden-accessible');
} else {
$('#A2').addClass('ui-hidden-accessible');
};
});
</script>
I have a jsp page that gets input from the user in a series of forms. First I ask for the user's height, then their weight. I'd like to ask for each on a separate "page". But really I'm just submitting the same jsp file again, only using the values in the url to figure out which form contents I should be showing:
String height = request.getParameter("height");
String weight = request.getParameter("weight");
<form>
<%
if (height != null) {
%>
Weight: <input type="text" name="weight" />
<%
} else {
%>
Height: <input type="text" name="height" />
<%
}
%>
<input type="submit" />
</form>
So the first run would ask for their height, the second would ask for their weight (if it sees the "height" param is already present in the url). Is that possible? It seems like I lose the params as I progress through each step,
Thanks
Just add a hidden input field with the height stored in it so you don't lose the height value when asking for weight in the second step:
<input type="text" name="weight" />
<input type="hidden" name="height" value="<%= height %>" />
I've created a custom helper that renders a grid and receives the strongly typed view's model as a parameter.
Basically my view looks like this:
<% using (Html.BeginForm("UpdateValues", "Home", FormMethod.Post)) { %>
<%= Html.MyGrid(Model)%>
<input type="submit" value="Update Values" />
<%} %>
But when I click on the submit button, all the values on the model are null.
This is what the controller looks like:
[HttpPost]
public string UpdateValues(AssignmentResultsVm assignmentResults)
{
//..... do something
}
How can I make this work?
Thanks in advance.
You need to make sure that the items are arranged in your grid so that the default model binder can map the data map to your view model class.
This is done by index the name property of the data your are binding like this:
<form method="post" action="/Home/Create">
<input type="text" name="[0].Title" value="Curious George" />
<input type="text" name="[0].Author" value="H.A. Rey" />
<input type="text" name="[1].Title" value="Code Complete" />
<input type="text" name="[1].Author" value="Steve McConnell" />
<input type="submit" />
</form>
You can have this done for you by the EditorTemplates feature of asp.net mvc which is exemplified in this article.