How to show and change the state in tree view - odoo-10

I want to show the state change field in tree view. Usually we did this in form view. For example in form view state can be changed from draft to done. I need like this type of state change in tree view also. can you give a solution to do this?

You can do it via Wizard process, In More/Action option you can create new wizard for update state.
Ex :
class test(models.TransientModel):
_name="update.state"
state=fields.Selection([('draft','draft'),('done','done')])
#api.multi
def **update_state_ept**(self)
active_ids=self._context.get(active_ids)
records=self.env[model].search(active_ids).write({'state':self.state})
You can select records from tree view and open wizard from More/Action Menu,select state & update it.
Above example is just an update state, you can put different conditions based on your requirement.
Ex: If record is draft then we can confirm it.
You can create following answer for create new wizard in more/action menu item.
How do i make and attache action to button
This may help you.

Related

Why is my Oracle APEX DML Form stuck in edit mode and not going back to create mode?

I have created a page based on "Form & Report" template. So there is the Report page on which there is the create button. That create button leads to the form page which contains.
It is pretty simple. I don't know if there is a cache memory not emptying itself or if there is a setting that I have not properly set.
When I want to create a new database record, Oracle Apex behaves as if I asked it to update a record (though it still presents me with empty text fields).
Below the image of what's happening.
Create button of the Report
Buttons for edit are shown when I click the create button
Those edit buttons are shown instead of the buttons below => This means that the Apex software is behaving like I asked to edit a record not to insert a record.
Why is this happening?
You need to take a look at your create button. Is it passing a value to the form? If so, you probably don't want that. Is it clearing the cache of the form? If not, you probably want to clear it.
Also, on the form page take a look at your processes.. specifically the Automated Row Fetch (ARF) process.. what's the primary key that this process is using?
Also, take a look at the conditions for each button on your form. For the delete/save buttons you likely want a condition type of "value of item / column in expression 1 Is NOT NULL".
For your create button you would want the opposite.. "value of item /... IS NULL".
In both cases for the expression 1 you'd want to use the item that your ARF is leveraging.
#Bloomberg58 if you used the wizard that should not have anyway try to validate the create button in report page and the server-side validation of create and save button in form page

Dynamics CRM sub grid defaulting to creating new record vs. lookup existing records

We are using Dynamics CRM 2016. I am using the Account entity to track both customers and competitors. I created a new 1:N relationship between Opportunity and Account and named it Account_Competitors. I put a sub grid on my opportunity form titled "Competitors" and configured it to show related Account_Competitors. When I click the "+" button I get a quick create form. I want the "Add Existing" behavior. How do I fix this?
If the lookup to Opportunity on Account is business required, you will experience what you see now (which does not sound optimal).
If you change the lookup to be optional instead, the initial behavior when pressing the "+" button in a subgrid will be to initiate the "Add Existing" behavior.
With that said, it sounds a bit strange to have a 1:N-relationship for this. In this way a Competitor-Account can only be associated with a single Opportunity. I would suggest looking into using the standard Competitor entity, or using an N:N relationship instead.
To control the behavior of the new record button on subgrids, look at the child entity being selected in the subgrid..If the lookup field for the parent is required, the user will get a “new record” form when clicking the + button. If the lookup field for the parent entity is not required on the child entity, the user will get the lookup field to “add existing.”
For more details with example you can look at http://www.inogic.com/blog/2014/05/sub-grid-add-action-behavior-in-dynamics-crm/

How do I point a menu item to a component's task?

How do I point a Joomla menu item to a specific task in my custom component? I have had no trouble creating menu items that point to my views, and each view is available in the list when I select my component in the menu. But I have not found a way to route the menu to one of my component's tasks.
In some cases, I am using a controller method (i.e. a task) to decide which models and views to present to the user. Usually this is when I need to display data from multiple models, or I need to use information in the session state to determine which view is appropriate for the user. It is in these cases that I need a menu item that points to the task.
So, how do I get a menu item to bring a user to "index.php?option=com_mycomponent&task=do.something"?
What have I tried already, you ask? I've looked at just about every Google reference I could find, and none seem to address this issue. I'm either looking for the wrong thing, or it's so dead easy that nobody has ever had to ask for help. I have also looked through the Joomla components & menu items, finding no examples of a menu item pointing to a controller task.
You can add a field to the request fieldset. Name it task. The value would be "do.something". Make the field type="hidden".
I'm suggesting the hidden because you really don't want the users to be able to change it.
The request fieldset is for fields that go into the url directly with the format &name=value.
I found the above answer not flexible enough and finally found this to work perfectly, you can override the menu item form xml ( administrator/components/com_menus/models/forms/item.xml ) and make the link field editable so you can add any request parameters you want, including tasks.
Make sure you leave/add the view name of the request as otherwise the link type cannot be determined, so add it even if it is not relevant eg. &view=yourview.
See system plugin onContentPrepareForm below
function onContentPrepareForm(&$form, $data) {
$option = JFactory::getApplication()->input->get('option');
// allow us to edit the link field of the menu item for this component to include some custom request values
if($option == 'com_menus' && $data->type=='component' && $data->request['option']=='com_your_component_name'){
$form->setFieldAttribute('link','readonly','false');
}
}

extjs Save component view state before removing it from parent component

Let me explain the my scenario. I am using ExtJS5. I have got a view component (let us name is viewOne) contain two combo boxes, button search and some action button, on click of search button the grid is populated. This viewOne is in a parent view component (viewParent). I need to load a second view (viewTwo) on selecting some grid row and clicking some action button a new view is loaded (viewTwo) in the parentView. When I come back from viewTwo to viewOne I need old values of combo boxes to re perform the search.
Currently I am storing the values of combo boxes in a store and set then when the after view render and call search. We have discarded card layout for this implementation.
I wanted to know how this can be done via Ext.state , I cannot find any example on the same that is close solution to my problem. Any other way of doing this ?
State seems reasonable for that. First of all you must set StateProvider (by calling Ext.state.Manager.setProvider) to instance of class which extends Ext.state.Provider.
Then state should work for you. Only thing that you must remember is to set stateful property to true and set stateId of the component.
Usually you don't need to save state by yourself. All built-in stateful components have defined state events. When such state event occur (eg. expand on panel) then state is saved automatically. You can customize state events by calling addStateEvents in initComponent.
To provide custom component state you should override applyState and getState methods. When you combine it with addStateEvents you have all what you need.
Example: http://jsfiddle.net/48jw81da/16/

MVC3 global predicate filter

I am building an admin console and all controllers depend on a dropdown selection for customer.
I would like to move this customer selection to the layout and persist it across all controllers so that you do not need to select it everywhere.
What is the best way to go about doing this?
Thanks in advance.
Move the dropdown to your _layout.cshtml.
Create a BaseView that all views will inherit from and give it a property to store the Customers & Current Customer.
Create a BaseController method that will fill in a BaseView instance.
Store the currently selected customer on your session.
Create a Global Filter and have it check all views to see if they inherit BaseView. If they do it can convert them to a BaseView and then fill in the properties.
Write some code in the _layout that can use the View to fill in the dropdown. I'm a bit fuzzy here since my coworker actually did this part when we did something similar.
When the user changes the dropdown value you can use JSON to call an action method that will update the current customer in session.
I would consider writing HTML helper. You assume that all the birds can fly, but say one day you have another exceptional scenario and you no longer need this dropdown box. Alternatively include it in a partial view and render that view where you need it - it's only one extra line of code.
E.g.
#section main_content{
#{ Html.RenderPartial("MyPartialViewContainingDropDownBox"); }
}

Resources