How to inherit and add Action menu in odoo - odoo

I have created and upgraded a custom module successfully. My module especially inherits & adds new fields in Products for e-commerce.
Now I am facing an issue that could not add an action button at the action button dropdown in the website setting->product->select product ..
this is how I extend and add a field
from odoo import models, fields, API
class ProductTemplate(models.Model):
_inherit = 'product.template'
isOffered = fields.Boolean('isOffered')

See this
Or:
To add the button inside the action button we need to add the code below.
<act_window name="You Action"
id="update_state_action"
res_model="update.state"
binding_model="sale.order"
binding_views="form"
view_mode="form"
target="new"
/>
Where binding_model is the model to bind the action to. and res_model is like a wizard that performs an action
Check this for details

Related

default values on a related model

From my model I have a many2one relationship to res.partner
Such relationship "feeds" a dropdown field (menu)
Such dropdown field contains a list of partners and the last item is "Start writing", to create a new partner (see this picture; "Inizia a scrivere is the Italian for "Start writing")
I'd like the new partner being created to have some fields automatically assigned with some default values
I've been suggested to use an action with a context but in this case I'm not starting the creation of a new partner from a menu or button and I'm not sure how to call my action from the last item of the dropdown menu
you can apply a context attribute on a related field in a view
Like this
<field name="some_related_field_id"
context="{'default_field_to_be_set_on_the_related_model': 'some_value'}"/>
Please notice that the name of the field to be set is not
default_field_to_be_set_on_the_related_model
it is
field_to_be_set_on_the_related_model
The initial default_ is a convention to set default values
That's required, if you don't prefix the name of your field with default_ the thing won't work

Different methods on a single button based on the group of the user? odoo 12

I've created a button and wrote a certain function in its method,So now i have to implement like if the user in the certain group click the button i need to trigger a wizard.(i have to take a user input and continue).
And also please let me know is there any other type of TransientModel in odoo 12 other than wizard like a message prompt where we can take the user input and continue?
You can add multiple versions of the button. I mean you can add multiple buttons with the same 'display name', i.e, string attribute, which will each one call a different method, and show it based on the user group by adding attribute 'groups' in the button and giving the particular group you want it to be visible for
Example:
<button name="method_1" string="MyButton" groups="sale.group_sale_salesman" type="object"/>
<button name="method_2" string="MyButton" groups="stock.group_stock_user" type="object"/>

Sylius grid add button to product table

How can I override product table grid to add new button next to edit and delete?
I have found: vendor\sylius\sylius\src\Sylius\Bundle\AdminBundle\Resources\config\grids\product.yml
The button should open modal button with html content. Thanks,
You have two options here.
You could either include a config file for grid which will look more or less like this:
# app/config/grids.yml
sylius_grid:
grids:
sylius_admin_product:
actions:
# your new action here
or copy entire yaml file you've found in
vendor\sylius\sylius\src\Sylius\Bundle\AdminBundle\Resources\config\grids\product.yml
into your app/Resources folder:
app/Resources/SyliusAdminBundle/config/grids/product.yml
and override what you want :)
More info can be found here: http://docs.sylius.org/en/latest/customization/grid.html
There is an example here:
Custom template and How to register and How to use
You can register this action in any place where you define grids. It's not necessary
sylius_grid:
templates:
filter:
your_filter_name: #YourBundle/Path/After/Resource/_filter_name.html.twig
action:
# the same defining
bulk_action:
# the same defining

Call Pop-Up for WebDynpro from a Business AddIn?

We got a Web Dynpro Application which was created with the Floorplan Manager.
By clicking a specific button I start a Business AddIn which check some conditions and then it should show a popup on the screen with a message for the user.
Is there a way I can accomplish that?
One way to get a PopUp (eg confirmation) window in Floorplan applications is to overwrite the NEEDS_CONFIRMATION method of the Interface IF_FPM_GUIBB_*_EXT inside your feeder-class.
Create a reference to cl_fpm_confirmation_request and put this one in the export-parameter EO_CONFIRMATION_REQUEST of the Method.
By Example:
METHOD if_fpm_guibb_list_ext~needs_confirmation.
DATA li_req TYPE REF TO cl_fpm_confirmation_request.
CASE io_event->mv_event_id.
WHEN 'YOUR_EVENT_ID'.
CREATE OBJECT li_req
EXPORTING
it_confirmation_text = 'Plaintext in Content of Popup'
iv_window_title = 'Title of the Popup'
iv_button_text_approve = 'Text Approve-Button'
iv_button_text_reject = 'Text Reject-Button'
.
eo_confirmation_request = li_confrequ.
ENDCASE.
ENDMETHOD.
The method will be called before the PROCESS_EVENT-Method an will override it when you cancel the popup.
Please be aware that every GUIBB-Implementation has it´s own extension interface, e.g. List, Tree, ...
For a deeper look inside popups in FPM or custom-popups have a look into https://blogs.sap.com/2013/11/26/popups-in-floorplan-manager/

How create action is called in a master page while submitting the _form?

For example,
if we create a master page named BED
while creating a new record for the master we create it using the create bed link in the right side(which has the controller URL bed/create).
But after that entering all the fields, and clicking the save button(in _form).
We have not mentioned any controller url in the save button but how it manages to locate the bed/create
In the same way while updating if we click the link for update, it locates the update action with the id, but while saving the page again how it manages to locate the bed/create again.
By default action of form is the same url (if you create action at '/index.php?r=bed/create' action of form is set action="/index.php?r=bed/create"). But if you need to change it - just add it to attributes of ActiveForm. For example for bed/update view:
$form = $this->beginWidget('CActiveForm', array(
'id'=>'user-form',
'action'=>'/index.php?r=bed/create'
));