how to get value of "active_id" for openerp kanban view - odoo

I'm creating a new module where I want to put a button in kanban view of Contact screen. When any user click on that button I need active_id of the selected contact. It is possible to get for tree and form view but I don't know how to do that for kanban view.
Can anyone please help here?
Thanks

You need to use the contex dictionary variably for this purpose ,
If you click on the bu
<button string="Click Me" type="object" name="my_func" context="{'active' : active_id}" />
Method:
def my_func(self, cr, uid, ids, context={}):
# do stuff using the info passed in the context variable...

Related

Instead of pick-list field how to create radio button in salesforce lightning component

I have created a page with lightening components as shown the below image, I want to change my pick-List field into radio button next to picklist option to choose the appropriate selection, can someone please help to create radio buttons instead of pickList filed
in the component I have used below code
<div class="slds-form-element">
<div class="slds-form-element__control">
<ui:inputSelect label="Race Type"
aura:id="Type"
class="slds-select"
labelClass="slds-form-element__label"
value="{!v.newRace.Race_Type__c}" />
</div>
Maybe something in line with this: (replace v.Name with attribute that contains the name of the race):
<aura:component>
<lightning:radioGroup name="radioGroup"
label="slds-form-element__label"
options="{! v.newRace.Race_Type__c }"
value="{! v.Name}"
type="radio"/>
</aura:component>

how to disable a BUTTON after first click?

This might be a simple question.but,does any one know how to disable a button after clicking it in Odoo? Thanks for all your help.
Most of Odoo module use state for this kind of problem. the general idea of it that you must have a field and the button is displayed based on the value of that field.
Ex:
# in you model
bool_field = fields.Boolean('Same text', default=False)
In your view:
<button name="some_method"......... attrs="{'invisible': [('bool_field', '=', True)]}" />
...
...
...
<!-- keep the field invisible because i don't need the user to see
it, the value of this field is for technical purpuse -->
<field name="bool_field" invisible="1"/>
In your model:
#api.multi
def some_method(self):
# in this method i will make sure to change the value of the
# field to True so the button is not visible any more for user
self.bool_field = True
...
...
...
So if you all ready have a field that the button change it's value you can use it directly
or create a special field for this purpose.

Button in tree view odoo 9

I need a button in tree view for all line. After clicking on the button I need get line id.
I'm trying, but not working:
*.xml
<button name="copy_line" class="text-right" icon="fa-files-o" type="object"/>
*.py
#api.multi
def copy_line(self):
print("Not come here!")
for r in self:
print(r.id)
object has no attribute 'copy_line'
To call the method on button click that record should be saved.
But in this case, Record was not saved so you are not able to call the method on button click.
Alternet way is, you can create a new line based on onchange or button in the footer and add self._cr.commit() to commit and raise ValidationError.
You define copy_line in the wrong model.
If your button is included inside a tree view defined for a One2Many field line_ids and that field is referencing object.line, you method copy_line should be created in that model.
For example:
line_ids = fields.One2Many('object.line', 'ref_id', string='Lines')
class ObjectLine(models.Model):
_name = 'object.line'
#api.multi
def copy_line(self):
print("Not come here!")
for r in self:
print(r.id)

How to show username on dropdown button using React-Bootstrap and EJS?

I would like to show username on dropdown button after users log in to my site. But, how is it done using React-Bootstrap?
My code for the dropdown button looks like this.
<DropdownButton title="Dropdown" id="bg-nested-dropdown">
<MenuItem eventKey="1">Account</MenuItem>
<MenuItem eventKey="2">Log Out</MenuItem>
</DropdownButton>
I want to change the title to username so that he/she can confirm that they actually logged in by seeing their username on the dropdown button.
I can retrieve username easily like this using EJS.
<% if (!user) { %>
some text
<% } else { %>
<%= user.username %>
<% } %>
But, I want to show the username(user.username) on the dropdown button.
You can do:
<DropdownButton title="Dropdown" id="bg-nested-dropdown">
<MenuItem eventKey="1">Account</MenuItem>
<MenuItem eventKey="2">Log Out</MenuItem>
{ user ? <MenuItem eventKey="x">{ user.username }</MenuItem> : <MenuItem eventKey="y">Some text</MenuItem> }
</DropdownButton>
Gilad's answer makes sense to me, but I've never tried this myself.
Maybe some things to consider:
are you keeping track of state anywhere and can you put your user object into state outside of this react button?
have you tried this.user?
have you tried creating an EJS element (like a < p >) with the username and telling React to load that if it exists?
none of these may do it, but hey. I'm going to be doing some work like this in next few days and will update if I figure out something.
Its better to use <Dropdown/> instead of <DropdownButton/>
Example:
<Dropdown id="language-selector-in-header">
<Dropdown.Toggle>
<i className={iconClass}></i> Some text or other html elements
</Dropdown.Toggle>
<Dropdown.Menu>
<MenuItem eventKey="en"><i className="flag-icon flag-icon-us"></i> English</MenuItem>
</Dropdown.Menu>
</Dropdown>

ASP.NET MVC 4 Passing data to the controller

I have a form, with a textbox and some radio buttons (Only 1 radio button can be selected at once) so I want to submit to the controller, the person name and the radio button select, that is value 1, 2 or 3 depending on the selection (1:Programmer, 2:Project Manager, 3:Analyst) but I do not know how to pass only the value of the radio button selected instead of the value of all them. how to get rid of this?
for example, it person name is David and the selected radio button is Programmer, I want to pass (David,1), if selected radio button is Project Manager (David, 2) and if selected radio button is Analyst (David, 3) to the controller.
#using (Html.BeginForm("AddPerson", "AddToDatabase", FormMethod.Get))
{
<div id="Radio">
#Html.TextBox("PersonName")
#Html.RadioButton("Programmer")
#Html.RadioButton("Project Manager")
#Html.RadioButton("Analyst")
</div>
<input type="submit" value="#Resource.ButtonTitleAddPerson" />
}
The controller signature is:
public bool AddPerson(string name, int charge)
Try to use #Html.RadioButton in other way:
#Html.RadioButton("Profession", "1") Programmer
#Html.RadioButton("Profession", "2") Project Manager
#Html.RadioButton("Profession", "3") Analyst
In your approach you receive three unconnected radio buttons with different id. And form thinks that they are different inputs and sends them all.