Adding menu to Odoo 10 in custom module - odoo

I want to add a submenu to Settings->Technical menu in Odoo 10.
I have tried with the following code, apparently the menu item is loaded (you can see that it is one of the menus created by the custom module) but it is not displayed.
Any tip/suggestion on why?
<?xml version="1.0"?>
<odoo>
<menuitem id="sale_order_custom_document"
name="Sale Order Custom Documen"
parent="base.menu_custom"
/>
</odoo>
Thanks

You have to define the action in menuitem then only it is visible. menuitem without any action will became normal string for display purpose. So either add sub menu with action or directly assign any action to it.
<menuitem name="Sale Order Custom Document" action="<your_action_id>" id="sale_order_custom_document" parent="base.menu_custom" sequence="20"/>
Here's a description link for odoo action

you must also create the actions 's record named:
product.product_template_action_custom_docs for example
declare your menu just after
Try this:
<odoo>
<data>
<!-- your initial code in your <app>_view.xml -->
<record id="product.product_template_action_custom_docs" model="ir.actions.act_window">
<field name="name">Sale Order Custom Document</field>
<field name="res_model">product.template</field>
<field name="view_mode">tree,kanban,form</field>
<field name="view_type">form</field>
<field name="context">{"search_default_filter_to_sell":1}</field>
<field name="help" type="html">
<p> here you write the help form your form</p>
</field>
</record>
<!-- after the action, you can now paste your menu declaration
your specified "action", "id","name","sequence" and "parent"-->
<menuitem action="product.product_template_action_custom_docs"
id="sale_order_custom_document" parent="base.menu_custom" sequence="20" name="Sale Order Custom Document" />
</data>
<odoo>

Related

Adding a combination of leave type in the TimeOff module in the LeaveForm? Odoo13

I needed to add a feature that can combine two leave types in the TimeOff module form, and when a user submits the form the leaves gets deducted from the respective time off type. (In the form I am thinking to add a second dropdown menu where he/she can add the other time off).
I am using Odoo13, I am inheriting the module, but can't figure it out to add a dropdown in which the user can select multiple leaves.
model=hr.leave, externalid = hr_holidays.hr_leave_view_form
Work that I have done:
I have created a module which inherits the hr_holidays module in Odoo13, In the leave form i have sucessfully added the dropdown which is above but it is selecting the same time-off type which is selected above.
Here is the xml file:
<?xml version='1.0' encoding='UTF-8' ?>
<odoo>
<!--Adding the Drop Down-->
<record id="hr_leave_view_form_addnewleave" model="ir.ui.view">
<field name="name">leave.addleave</field>
<field name="model">hr.leave</field>
<field name="inherit_id" ref="hr_holidays.hr_leave_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[#name='description']" position="before">
<div class="row" name="status_id">
<label class="col-2 mr-0" for="holiday_status_id"/>
<!-- RLI FIXME: we should avoid redefining the domain in the view when there already is a domain on the model -->
<field name="holiday_status_id" domain="['&', ('virtual_remaining_leaves', '>', 0), '|', ('allocation_type', 'in', ['fixed_allocation', 'no']),'&',('allocation_type', '=', 'fixed'), ('max_leaves', '>', '0')]" context="{'employee_id':employee_id, 'default_date_from':date_from}" options="{'no_create': True, 'no_open': True}" class="col-9 pl-0" nolabel="1"/>
</div>
</xpath>
</field>
</record>
</odoo>
In this the code with is for the dropdown.
The LeaveForm image with dropdowm
Thanks in advance.Please look into the photo that I uploaded.

How to add a new button inside the action menu Odoo 12?

Im trying to add a button inside the action in the model named 'consultation', After clicking the button i need to open up the wizard i created follow,But im stuck in some errors
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="specialist_no_show" model="ir.ui.view">
<field name="name">specialist no show</field>
<field name="model">specialist.no.show</field>
<field name="arch" type="xml">
<form string="No Show">
<group>
<group>
<field name="partner_id" readonly="1"/>
</group>
</group>
<footer>
<button name="update_no_show" string="Confirm" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>
<act_window name="No Show"
id="specialist_no_show"
res_model="specialist_no_show" #model created for the wizard
binding_model="consultation" #model where i want to show the button in the action
binding_views="form"
view_mode="list"
target="new"
/>
</odoo>
I can spot some problems that you can try:
The XML ID for the form and the act_window must be different. In your example it is both specialist_no_show
The res_model must be specialist.no.show
The structure for the act_window is different depending on your Odoo Version (see below).
For Odoo Version 12.0
<act_window name="No Show"
id="action_specialist_no_show"
res_model="specialist.no.show"
src_model="consultation"
view_mode="form"
target="new"
/>
For Odoo Version 13.0
<act_window name="No Show"
id="action_specialist_no_show"
res_model="specialist.no.show"
binding_model="consultation"
view_mode="form"
target="new"
/>
Also, the error logs would be helpful as #Kenly suggested. Always post those.

Odoo 10: Add extra fields to the product form

I want to add a couple of extra fields to the product form, right after 'standard_price'.
I created a view that inherits from "product.product_template_form_view" and added my fields there:
<field name="standard_price" position="after">
<field name="my_field" />
</field>
I then restart odoo updating the module, but I don't see my new fields when I call the product form.
The fields appear on the database model (created inherited models also), but not on the user interface.
What I'm missing here?
Check these things:
Inherited from correct base form product.template.common.form
Make sure you are looking at correct form for product.template (Product), not product.product (Product Variant).
Do you see the input field without caption in edit mode? If this is the case, you can have broken structure in the html level. Next bullet will solve this.
Standard_price field has unique html structure because it can have unit of measure (uom) connected to it. Try connecting to simple field or use the container div standard_price_uom for connection, see template code below.
Template code for working view with a new field after standard_price_uom div:
<div name='standard_price_uom' position="after">
<field name="my_field" />
</div>
If these does not help, please provide whole view definition.
Make sure you use the correct model. Use product.template instead of product.product.
<record id="product_template_form" model ="ir.ui.view">
<field name="name">product.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view" />
<field name="arch" type="xml">
<field name="standard_price" position="after">
<field name="my_field"/>
</field>
</field>
</record>
...
class ProductTemplate(models.Model):
_inherit = "product.template"
my_field = fields.Char()
Make sure you have added your XML file into your module’s __manifest__.py file. Odoo only pulls in XML from files that you tell it to.
You can see examples of this on any core modules. See sale/__manifest__.py for an example.
On your module, it would be something like this:
{
...
‘data’: [
‘views/form/form_product.xml’,
]
...
}
I have tested it in Odoo 12.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_product_template_common_form_inherit" model="ir.ui.view">
<field name="name">product.template.common.form.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//div[#name='standard_price_uom']" position="after">
<label for="my_field" string="My Field"/>
<div>
<field name="my_field"/>
</div>
</xpath>
</field>
</record>
</odoo>

Inherit TransientModel and have two views ( website.config.settings )

I am trying to inherit the Website settings menu and have two views. website.config.settings is a models.TransientModel
When I am inheriting that and viewing with a new menuitem it overwrites the previous view. Like - There are two views now, the new record I defined named Website Event Settings . When I click on that it loads the new modified view but when I click on existing Settings menu, it shows nothing.
In summary, the existing website settings menu not working and new menu does. I need both of them.
The py code and record view I used are following -
class cofair_website_design_config(models.TransientModel):
_name = 'website.config.settings'
_inherit = 'website.config.settings'
event_title = fields.Char(related='website_id.event_title', string='Event Title')
XML:
<record id="view_website_event_config_settings" model="ir.ui.view">
<field name="name">Website Event Settings</field>
<field name="model">website.config.settings</field>
<field name="arch" type="xml">
<form class="oe_form_configuration">
<header>
<button string="Apply" type="object" name="execute" class="oe_highlight"/>
<button string="Cancel" type="object" name="cancel" class="oe_link"/>
</header>
<div>
<group string="Event Page Section">
<group>
<field name="event_title_color"/>
</group>
</group>
</div>
</form>
</field>
</record>
<record id="action_website_event_configuration" model="ir.actions.act_window">
<field name="name">Website Event Settings</field>
<field name="res_model">website.config.settings</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
<field name="view_id" ref="view_website_event_config_settings"/>
</record>
<menuitem id="menu_website_event_settings" parent="website.menu_website_configuration" name="Website Event Settings" action="action_website_event_configuration"/>
Instead of renaming the modules (which causes relational error), I found a workaround. I have inherited the main settings and put a view id there and called it with menuitem -
<!-- Bring settings menu out -->
<record id="website.action_website_configuration" model="ir.actions.act_window">
<field name="name">Website Settings</field>
<field name="res_model">website.config.settings</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
<field name="view_id" ref="website.view_website_config_settings"/>
</record>
<menuitem id="website.menu_website_website_settings" parent="website.menu_website_configuration" name="Website Admin" action="website.action_website_configuration"/>
Then I called my record action and it loaded the view and action. Another catch point is I had to show website_id to show the values of specific websites or the transient model will always be empty.
Change the _name attribute in your model definition to something else and also modify the xml appropraitely.
class cofair_website_design_config(models.TransientModel):
_name = 'something.else'
_inherit = 'website.config.settings'
event_title = fields.Char(related='website_id.event_title', string='Event Title')
ir.ui.view
<field name="model">something.else</field>
and ir.actions.act_window
<field name="res_model">something.else</field>
That should copy all the fields and methods from website.config.settings to the new model something.else and keep it separate from website.config.settings

Show form field and tree view together odoo

I managed to add two custom fields to the settings by inheriting res.config.settings in a new module created. The xml page of the same is
<record id="op_product_fast_moving_parts_form" model="ir.ui.view">
<field name="name">Configure Fast Moving Parts</field>
<field name="model">fastmovingparts.config.settings</field>
<field name="arch" type="xml">
<form string="FastMoving">
<header>
<button string="Apply" type="object" name="execute" class="oe_highlight"/>
or
<button string="Cancel" type="object" name="cancel" class="oe_link"/>
</header>
<separator string="Configure Fast Moving Parts"/>
<group name="Configure Fast Moving Parts">
<field string="Minimum Quantity" name="fast_moving_parts_min_qty"/>
</group>
<group>
<field string="Interval" name="fast_moving_parts_chk_interval"/>
</group>
</form>
</field>
</record>
It is updating the settings when clicking on the Apply button.
Here I have one more requirement that I need to open a wizard on clicking Apply button which will display products tree. How can I achieve this?
Thanks in advance
I didn't get your question, but I think that you want to open a wizard on clicking Apply button which will display products tree.