How to set a filter as default filter in odoo - python-3.x

i'm using odoo 11 and i want to set a default filter which group by employee. i made a modification on the module but it doesn't shows the right result(i want to remove the administrator filter) .I don't know what's the problem .Any idea for help please ?
.
<record id="action_bt_overtime_management" model="ir.actions.act_window">
<field name="name">Overtime</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">bt.hr.overtime</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'search_default_employee_id':1}</field>
<field name="search_view_id" ref="bt_overtime_management_search"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Create Overtime Request
</p>
</field>
</record>

Try to give like this
<record id="action_bt_overtime_management" model="ir.actions.act_window">
<field name="name">Overtime</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">bt.hr.overtime</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'group_by':'employee_id'}</field>
<field name="search_view_id" ref="bt_overtime_management_search"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Create Overtime Request
</p>
</field>
</record>

Related

issue to Add a custom list view in odoo

when i add my list view code in the my .xml file
this code:
<odoo>
<data>
<record id="test_list_view" model="ir.ui.view">
<field name="arch" type="xml">
<tree string="Tests">
<field name="name"/>
<field name="last_seen"/>
</tree>
</field>
</record>
</data>
</odoo>
to this file :(estate_list_views.xml)
i can not up great my module because of this error
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/hadi/Public/st/odoo/odoo/http.py", line 640, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/hadi/Public/st/odoo/odoo/http.py", line 316, in _handle_exception
raise exception.with_traceback(None) from new_cause
odoo.tools.convert.ParseError: while parsing /home/hadi/Public/st/odoo/oca/estate/views/estate_list_views.xml:3, near
<record id="test_list_view" model="ir.ui.view">
<field name="arch" type="xml">
<tree string="Tests">
<field name="name"/>
<field name="last_seen"/>
</tree>
</field>
</record>
i follow this tutorial but that not have any description please unless introduce to me a free video tutorial for odoo
I think you missed the model name
Try this:
<record id="test_list_view" model="ir.ui.view">
<field name="name">model.tree.view</field>
<field name="model">your.model.name</field>
<field name= "arch" type = "xml">
<tree string="Tests">
<field name="name"/>
<field name="last_seen"/>
</tree>
</field>
</record>
See this for reference.

Odoo hide some view type on specific model

I need the following view types on CRM hide calendar,pivot,graph,cohort,dashboard using a custom module
I tried with this without success
<record id="crm_action" model="ir.actions.act_window">
<field name="name">CRM views</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">crm.lead</field>
<field name="view_type">crm.lead.kanban</field>
<field name="view_mode">tree,form,calendar,graph</field>
</record>
thanks
UPDATE
Your module should depend on crm. Then, the code must be this:
<record model="ir.actions.act_window" id="crm.crm_lead_action_pipeline">
<field name="view_mode">kanban,tree,form</field>
</record>

Odoo 12 - Model not found even though it exists

I am porting a localization accountability model from Odoo 8 to Odoo 12, I ported a function that worked flawlessly but then right after that I tried porting some other code that does not interfere with the first on, even though, whenever it is initialized by the init.py Odoo brings up an error telling me that the model cannot be found, even though it is correctly set up.
All I've tried is to ignore the new modules I added right after setting up the one that should be perfectly working right now. Without them (or without any new module at all, because I've tried porting different ones) it works, but this shouldn't be the case at all.
wizard_nro_ctrl.py
class WizNroctrl(models.TransientModel):
_name = 'nroctrl'
_description = "Wizard that changes the invoice control number"
new_nroctrl = fields.Char('Control Number', required=True)
sure = fields.Boolean('Are you sure?')
# Change control number of the invoice
def set_noctrl(self):
if not self.sure:
raise except_orm('Error!', 'Please confirm that you want to do this by checking the option')
current_id = self._context['current_id']
inv_object = self.env['account.invoice'].browse(current_id)
inv_object.nro_ctrl = self.new_nroctrl
return True
wizard_nro_ctrl_view.xml
<?xml version='1.0' encoding='UTF-8'?>
<odoo>
<data>
<record model="ir.ui.view" id="wizard_nro_ctrl_form">
<field name="name">wizard.nro.ctrl.form</field>
<field name="model">nroctrl</field>
<field name="arch" type="xml">
<form string="Changing the Control Number">
<field name="new_nroctrl" placeholder="New control number"/>
<separator string="Are you sure you want to do this?" colspan="4"/>
<field name="sure"/>
<footer>
<button name="set_noctrl" string="Confirm" type="object"/>
<button special="cancel" string="Cancel"/>
</footer>
</form>
</field>
</record>
<record id="action_wiz_nroctrl" model="ir.actions.act_window">
<field name="name">Change control number</field>
<field name="type">ir.actions.act_window</field>
<field name="model">wiz.nroctrl</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</odoo>
The init.py has the model initialized and the folder as well.
The model should work just fine, without this error. There's no reason to my knowledge for this issue.
odoo.tools.convert.ParseError: "Error while validating constraint
Model not found: nroctrl
Please make sure that in the model action you have wrote include model name 'nroctrl'. give the below xml code (nroctrl):
<record id="action_wiz_nroctrl" model="ir.actions.act_window">
<field name="name">Change control number</field>
<field name="type">ir.actions.act_window</field>
<field name="model">nroctrl</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
Also please ensure that you have given file name in init.py of wizard folder. also the folder name in ini.py of module.

How to make website menu item invisible in specific group?

I'm working on a private sale website. If the user is a manager, the menu2 will look, else user is a salesman, the menu3 will look. How can I do that?
What is the best solution?
Here is my code:
<record id="menu_shop_sales" model="website.menu">
<field name="name">menu2</field>
<field name="url">/shop_sales</field>
<field name="parent_id" ref="website.main_menu"/>
<field name="sequence" type="int">21</field>
</record>
<record id="menu_shop_dealer" model="website.menu">
<field name="name">menu3</field>
<field name="url">/shop_dealer</field>
<field name="parent_id" ref="website.main_menu"/>
<field name="sequence" type="int">22</field>
</record>
Add groups like this.
<field name="groups" eval="[(6, 0, [ref('base.group_user')])]"/>
Or write access rule in csv.
Add groups attribute.
groups="base.group_user"
example:
<record id="menu_shop_dealer" model="website.menu">
<field name="name">menu3</field>
<field name="url">/shop_dealer</field>
<field name="parent_id" ref="website.main_menu"/>
<field name="sequence" type="int">22</field>
<field name="groups">base.group_user</field>
</record>

How to add rule in openerp7

I have code that shows I have multiple stations each station have a different worker.. I use rule to show each station to it's worker only .. I have supervisor who must see all stations .. how can I do rule for the supervisor to see all stations
This is rule for worker
<record model="ir.rule" id="station_worker_rule">
<field name="name">station worker Rule</field>
<field name="model_id" ref="model_mrp_production_workcenter_line"/>
<field name="domain_force">[('user_id','=',user.id)]</field>
<field name="groups" eval="[(4, ref('group_worker'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_unlink" eval="True"/>
<field name="perm_create" eval="True"/>
</record>
For the supervisor you have to change a domain and groups.
You have to put a domain
<field name="domain_force">[(1 ,'=', 1)] </field>
<field name="groups" eval="[(4, ref('group_supervisor'))]"/>

Resources