adding new menuitem odoo 10 Sales addon doesn't work - menuitem

I don't know what's missing here but the menuitem doesn't show in Odoo 10
I want to add a menuitem for showing a specific Customers called "Annonceur"
here my field in python code
from odoo import models, fields, api
class Annonceur(models.Model):
_inherit = 'res.partner'
annonceur = fields.Boolean("annonceur", default=False)
then I want to add a menuitem in Left menu of Sale addon and window_action for showing this type of Customers axactly like Customers
<record id="action_partner_annonceur_form" model="ir.actions.act_window">
<field name="name">Annonceurs</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.partner</field>
<field name="view_type">form</field>
<field name="view_mode">tree,kanban,form</field>
<field name="domain">[('annonceur','=','True')]</field>
<field name="context">{'default_customer':1, 'search_default_customer':1}</field>
<field name="filter" eval="True"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to add a contact in your address book.
</p><p>
Odoo helps you easily track all activities related to
a customer: discussions, history of business opportunities,
documents, etc.
</p>
</field>
</record>
<menuitem id="annonceur_view"
parent="sales_team.menu_sales"
name="Annonceurs"
action="action_partner_annonceur_form"
sequence="5"/>
that's all my code please help me what's missing here

Add inherit id in Action menu.
Add the code below in your action menu.
<field name="inherit_id" ref="base.view_res_partner_filter"/>

Related

*Odoo 10* How to generate report to xls/xlsx file?

I like to generate a report to xls/xlsx file. I want to get all the product list on another Model to a TransientModel. ( I do my research but without someone explaining it to me I am not able to get the whole picture. )
aging_inventory_report.py
***aging_inventory_report.py***
from time import strftime, gmtime
from odoo import models, fields, api
from report_xlsx.report.report_xlsx import ReportXlsx
class AgingInventoryReport(models.TransientModel):
_name = 'aging.inventory.report'
_inherit = 'product.template'
_description = 'Aging of Inventory Report'
***from here, these are the codes that I get from searching over internet***
def print_xls_report(self, cr, uid, ids, context=None):
data = self.read(cr, uid, ids)[0]
return {'type': 'ir.actions.report.xml',
'report_name': 'dealer_stock_aging_report.report_name.xlsx',
'datas': data
}
class ClassABCD(ReportXlsx):
def generate_xlsx_report(self, workbook, data, lines):
current_date = strftime("%Y-%m-%d", gmtime())
logged_users = self.env['res.users'].search([('id', '=', data['create_uid'][0])])
sheet = workbook.add_worksheet()
# add the rest of the report code here
ClassABCD('report.dealer_stock_aging_report.report_name.xlsx', 'product.template')
*** I don't under stand the code but it successfully integrate into my model.***
XML
aging_inventory_report.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_aging_inventory_report" model="ir.ui.view">
<field name="name">Aging of Inventory</field>
<field name="model">aging.inventory.report</field>
<field name="arch" type="xml">
<form string="Aging Inventory">
<group>
<p>
Retrieve list of Aging Inventory.
</p>
</group>
<footer>
<button name="print_xls_report" string="Save as XLS" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer>
</form>
</field>
</record>
</odoo>
view_aging_inventory_report.xml
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="action_view_aging_inventory_report" model="ir.actions.act_window">
<field name="name">Retrieve Aging Inventory Report</field>
<field name="res_model">aging.inventory.report</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_aging_inventory_report"/>
<field name="target">new</field>
</record>
<menuitem id="action_menu_aging_inventory_report"
name="Aging Inventory"
action="action_view_aging_inventory_report"
parent="dealer_inventory_cost.inventory_cost"
sequence="2"/>
</odoo>
Hoping someone could help me on this. Thank you. Id something is not clear please let me know.

add another options in action button in tree view odoo 10

I want to add another options in action button on tree view. Moreover in export and delete, i want to add "Confirm" options. I don't know how, please help me. Thanks
<record id="action_id" model="ir.actions.server">
<field name="name">name</field>
<field name="model_id" ref="module_name.model_object_name" />
<field name="code">
action = model.function_name()
</field>
</record>
You can do by this way:
<record id="id" model="ir.actions.act_window">
<field name="name">Confirm Order</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">custom.model.name</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
If you want to add custom group for this option then you can add one attribute here also like:
<field name="groups_id" eval="[(4,ref('model.group_name'))]"/>
I was able to make a popup wizard appear in a different model with this:
<act_window id="module_name.your_custom_action_name"
name="your_custom_name"
src_model="model.in.wich.you.want.to.add.the.action"
res_model="model.in.wich.the.action.resides"
view_mode="form"
target="new"
multi="True"/>

How to replace purchase order form id purchase.purchase_order_form to custom form id in odoo 10?

I want to replace purchase order form id purchase.purchase_order_form to own custom id in Odoo 10 using
replace id priority or X path or other method using xml please sort out my problem and send some demo.
you can try with this:
<record id="purchase.purchase_order_form" model="ir.ui.view">
<field name="name">purchase.order.form</field>
<field name="model">purchase.order</field>
<field name="arch" type="xml">
<form string="Purchase Order">
<header>
</header>
</form>
</field>
</record>
don`t forget add depends for purchase at manifest.py
maybe this can help you

How to create nested tree view for departments Odoo 10

I'd like to have visualization for my departments in odoo v 10.0, like so:
Parent Department 1
-> Child department 1
--> Job position of this department
--> Job position of this department
-> Child department 2
--> Job position of this department
--> Job position of this department
Parent department 2
instead of simply having Parent department / Child department
How this might be achieved? Should I use grouping or iteration or something else in view? If possible - with example please
Try this code:
<record id="action_hr_department_test" model="ir.actions.act_window">
<field name="name">Departments</field>
<field name="res_model">hr.department</field>
<field name="view_type">tree</field>
<field name="view_mode">tree,form</field>
<field name="domain">[]</field>
<field name="context">{'group_by':['parent_id','name','manager_id']}</field>
</record>
<menuitem id="menu_hr_department_test" name="Departments Test"
action="action_hr_department_test"/>
Hope it will help you.

Odoo hide edit and more buttons if not admin

I'm trying to hide the edit and more button in user form if the connected user is not the admin.
Here is my code
<xpath expr='//form[#string="Users"]' position='attributes'>
<attribute name="edit" >{'false':[('id', '!=', '1')]}</attribute>
<attribute name="more">{'false':[('id', '!=', '1')]}</attribute>
</xpath>
i get the following error:
SyntaxError: JSON.parse: expected property name or '}' at line 1 column 2 of the JSON data
Unfortunately, what you trying achive is not possible using expression, rather I would advise to user "Customized Views"
Make out of user form edit="false" this will make edit button go away for all users (res.users.form).
Now go to Customized Views under Settings/Technical/User Interface/Customized Views, you need to be in debug mode to be able to see this menu.
Under Customized Views create a new record and choose User : Admin and in original view choose : res.users.form and in View Architecture
copy and pare original view View Architecture and just remove edit='false'
This should help, I believe.
Bests
Expanding #shodowsjedi's answer, To achieve what you want you have to create two views (They're essentially the same just that one is attached to a specific group and will be displayed for a user that belongs to that group)
This is a mockup of how your xml file should look
<!--original form view-->
<record id="model_form_view" model="ir.ui.view">
<field name="name">your.model</field>
<field name="model">your.model</field>
<field name="arch" type="xml">
<form string="Users">
<!--whatever is in your form -->
</field>
</record>
<!--inherited formview to hide edit option -->
<record id="model_form_view_noedit" model="ir.ui.view">
<field name="name">your.model</field>
<field name="model">your.model</field>
<field name="inherit_id" ref="model_form_view"/>
<field name="groups_id" eval="[(6, 0, [ref('base.group_user') ])]"/>
<field name="arch" type="xml">
<xpath expr='//form[#string="Users"]' position='attributes'>
<attribute name="edit">false</attribute>
</xpath>
</field>
</record>
It's always better to know how things work from the backend in Odoo