Odoo14 | No record found for unique ID base.user_admin - odoo-14

Accidently the user with id=2 which is (admin) deleted.How we can recover/fix this?

Create xml record again with that xml ID.
<record id="base.user_admin" model="res.users">
<field name="login">admin</field>
<field name="password">admin</field>
<field name="partner_id" ref="base.partner_admin"/>
<field name="company_id" ref="main_company"/>
<field name="company_ids" eval="[(4, ref('main_company'))]"/>
<field name="groups_id" eval="[(6,0,[])]"/>
<field name="signature"><![CDATA[<span>-- <br/>Administrator</span>]]></field>
</record>

Related

How to use selection field (dropdown) instead of checkboxes in Odoo groups (roles) selection?

I am creating a custom module in Odoo for a faculty and y need to create 3 roles (groups): students, professors and admins. An user cannot have 2 roles at the same time, so it could only be either a teacher, a professor or an admin. I have defined the permisions in the following code. But for selecting those permissions, Odoo creates a view with checkboxes, where you can chose 2 or more roles at the same time, instead of a selection field (dropdown), I dont want that. How can I force Odoo to create a dropdown for the selection of those roles
]
<record model="ir.module.category" id="module_category_faculty">
<field name="name">Faculty</field>
<field name="description">Faculty Roles</field>
<field name="sequence">45</field>
</record>
<record id="group_faculty_student" model="res.groups">
<field name="name">Student</field>
<field name="category_id" ref="module_category_faculty"/>
</record>
<record id="group_faculty_professor" model="res.groups">
<field name="name">Professor</field>
<field name="category_id" ref="module_category_faculty"/>
</record>
<record id="group_faculty_admin" model="res.groups">
<field name="name">Admin</field>
<field name="category_id" ref="module_category_faculty"/>
</record>
<record id="group_faculty_student" model="res.groups">
<field name="name">Student</field>
<field name="category_id" ref="module_category_faculty"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="group_faculty_professor" model="res.groups">
<field name="name">Professor</field>
<field name="category_id" ref="module_category_faculty"/>
<field name="implied_ids" eval="[(4, ref('group_faculty_student'))]"/>
</record>
<record id="group_faculty_admin" model="res.groups">
<field name="name">Administrator</field>
<field name="category_id" ref="module_category_faculty"/>
<field name="implied_ids" eval="[(4, ref('group_faculty_professor'))]"/>
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
</record>
But in that case all Professors also have Stundent group.

Odoo not displayed field

I get a problem with displaying custom field in sale order view.
sale_order.py
...
'typeship' : fields.many2one('vips_shop.delivery', string="Type delivery", readonly=False),
'usersess' : fields.many2one('vips_vc.session', string="Session customer", readonly=False),
...
sale_order.xml
<record model="ir.ui.view" id="sale_order_usersess_form_view">
<field name="name">order.usersess</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="client_order_ref" position="after">
<field name="usersess" string="User Session ID"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="sale_order_typeship_form_view">
<field name="name">order.typeship</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="client_order_ref" position="after">
<field name="typeship" string="Type shipping"/>
</field>
</field>
</record>
As result i received this: field usersess displayed fine, typeship - not displayed.
Why is it happening? All fields for usersess and typeship is equal.
Thanks for Hardik Patadia
why are you having two separate views for showing two fields? Why are
you not showing both of them in single inherited view? I think view
priority may help you
When I'm showing in single view all displayed fine:
<record model="ir.ui.view" id="sale_order_usersess_form_view">
<field name="name">order.usersess</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="client_order_ref" position="after">
<field name="usersess" string="User Session ID"/>
<field name="typeship" string="Type shipping"/>
</field>
</field>
</record>

Openerp make scheduled action

In openerp there's a standard module named account_followup_print, in here there's a method called do_process which sends out all the payment followup emails.
I want it to automatically do this every day without having to click the button. So I have made the following:
<openerp>
<data>
<record forcecreate="True" id="ir_cron_project_task" model="ir.cron">
<field name="name">Run Payment Follow-up scheduler</field>
<field eval="True" name="active"/>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'account_followup.print'" name="model"/>
<field eval="'do_process'" name="function"/>
</record>
</data>
Yet this does not work, what am I doing wrong here? Thanks in advance!
Try following,
<record id = "ir_cron_project_task" model = "ir.cron">
<field name="name">Run Payment Follow-up scheduler</field>
<field eval="True" name="active"/>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'account_followup.print'" name="model"/>
<field eval="'do_process'" name="function"/>
<field eval="'()'" name="args"/>
</record>

Record Rule for user groups in openerp

I have created a new module in openerp which contain consumption details related to each project.
I have created two user groups for my module (user,manager).User can create consumption details of project and he can see only consumption details which he has created.
I give the permission like this
<record id="property_rule_mat_mgmt_user" model="ir.rule">
<field name="name">Material Manage Rule</field>
<field model="ir.model" name="model_id" ref="model_mat_mgmt"/>
<field name="domain_force">[('create_uid','=',user.id)]</field>
</record>
It is working fine
Similarly if I assign a user as manager of my module he can see all consumption details of projects,in which he is member or manager.How to write the rule, I tried different ways but can't find a proper rule.
This is one of the rule I have tried
<record id="property_rule_mat_mgmt_manager" model="ir.rule">
<field name="name">Material Manage manager Rule</field>
<field model="ir.model" name="model_id" ref="project.model_project_project"/>
<field name="domain_force">['|',('user_id','=',False),('user_id','=',user.id)]</field>
</record>
For the record, it would have been be easier to answer if you could give the details of your model, specifically the mat.mgmt one. Perhaps that's why there was no answer yet.
Let's say you have a many2one relationship between mat.mgmt and project.project named project_id, you could then use something like this:
<record id="property_rule_mat_mgmt_manager" model="ir.rule">
<field name="name">Material Manage manager Rule</field>
<field model="ir.model" name="model_id" ref="model_mat_mgmt"/>
<field name="domain_force">['|',('project_id.user_id','=',False),('project_id.user_id','=',user.id)]</field>
</record>
Notice that the model is still model_mat_mgmt as this is the model on which the filtering is applied. You didn't want to filter projects but mat.mgmt if I understand correctly your question.
<record id="user_record_rule_id" model="ir.rule">
<field name="name">Record Rule Name</field>
<field model="ir.model" name="model_id" ref="model_my_model_name"/>
<field name="domain_force">[('create_uid', '=', user.id)]</field>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_unlink" eval="True"/>
<field name="groups" eval="[(4,ref('group_user'))]"/>
</record>
<record id="manager_record_rule_id" model="ir.rule">
<field name="name">Record Rule Name</field>
<field model="ir.model" name="model_id" ref="model_my_model_name"/>
<field name="domain_force">[]</field>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_unlink" eval="True"/>
<field name="groups" eval="[(4,ref('group_manager'))]"/>
</record>
Try above code:
manager group should be inherited from user group
example:
<record id="group_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="module_category_name"/>
</record>
<record id="group_manager" model="res.groups">
<field name="name">Manager</field>
<field name="implied_ids" eval="[(4, ref('group_user'))]"/>
<field name="category_id" ref="module_exit_category"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
Explanation:
User can create the record(s) as well as can view his record(s) only
but manager can see all the user's record(s) as well as he can create & view his own record(s)

Openerp 6.1 put product category in sale order line

I want to show the product category in the sale.order.line.tree view of a sales order with the following code which I wrote. It shows the category button under the group by button but on clicking it, I get the following error and I have don't know how to solve the bug:assert groupby_def and groupby_def._classic_write, "Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True"
AssertionError: Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True
Here is my code:
from osv import fields, osv<code>
class sales_order_line_category(osv.osv):
_name='sale.order.line'
_inherit='sale.order.line'
_columns={'categ_id': fields.related('product_id', 'categ_id', type='many2one', relation='product.categ_id'),
}
sales_order_line_category()
My view:
`<?xml version="1.0" encoding="utf-8"?>
<record id="view_sale_orderlinecategory" model="ir.ui.view">
<field name="name">sale.order.line.categoryinherit</field>
<field name="model">sale.order.line</field>
<field name="type">tree</field>
<field name="inherit_id" ref="sale.view_order_line_tree"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="categ_id" string="Category"/>
</field>
</field>
</record>
<record id="view_sale_orderlinecategory2" model="ir.ui.view">
<field name="name">sale.order.line.categoryinherit2</field>
<field name="model">sale.order.line</field>
<field name="type">search</field>
<field name="inherit_id" ref="sale.view_sales_order_uninvoiced_line_filter"/>
<field name="arch" type="xml">
<group expand="0" string="Group By..." >
<filter string="Category of Product" icon="terp-stock_symbol-selection" name="Category" context="{'group_by':'categ_id'}"/>
</group>
</field>
</record>
<record id="view_sale_orderlinecategory3" model="ir.ui.view">
<field name="name">sale.order.line.categoryinherit3</field>
<field name="model">sale.order,line</field>
<field name="type">search</field>
<field name="inherit_id" ref="sale.view_sales_order_uninvoiced_line_filter"/>
<field name="arch" type="xml">
<field name="name" position="before">
<field name="categ_id" string="Category"/>
</field>
</field>
</record>
</data>
`
WOuld you please try with following code replace?
'categ_id': fields.related('product_id', 'categ_id', type='many2one', relation='product.category', store=True),
Check that your field categ_id must be appear in tree view of sale.order.line where you try to do group by categ_id
Hope this help