I need import employees(hr.employee object) from xml and to tie them with users(res.users object) and contacts(res.partner object). Relation with user working is good(screen below after import).
But I have problem with contacts. When system import user she authomatically create new contact which applies to user. How I can to tie this contact with employee if I don't know ID?
I tried add contact record to xml file and set relations. But in this case system creates 2 contacts. And one of them is not related to user.
Here my xml for import from my module.
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="user_test" model="res.users">
<field name="name">My Name</field>
<field name="login">my_name</field>
<field name="password">1111</field>
</record>
<!-- I tried create contact like this...
but then will be created 2 contacts
instead 1 + one of them is not related with user -->
<!--<record id="contact_test" model="res.partner">-->
<!--<field name="name">My Name</field>-->
<!--<field name="user_id" ref="user_test"/>-->
<!--</record>-->
<record id="employee_test" model="hr.employee">
<field name="name">My Name</field>
<field name="work_email">my_name#gmail.com</field>
<field name="user_id" ref="user_test"/>
</record>
</data>
</openerp>
So, my question is: How I can to set contact(which was created authomatically from user) to employee?
Try this:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="contact_test" model="res.partner">
<field name="name">My Name</field>
</record>
<record id="user_test" model="res.users">
<field name="name">My Name</field>
<field name="login">my_name</field>
<field name="password">1111</field>
<field name="partner_id ref="contact_test"/>
</record>
<record id="employee_test" model="hr.employee">
<field name="name">My Name</field>
<field name="work_email">my_name#gmail.com</field>
<field name="user_id" ref="user_test"/>
<field name="partner_id" ref="contact_test"/>
</record>
</data>
</openerp>
Here solution:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!-- at first create contact -->
<record id="contact_test" model="res.partner">
<field name="name">My Name</field>
</record>
<record id="user_test" model="res.users">
<field name="name">My Name</field>
<field name="login">my_name</field>
<field name="password">1111</field>
<!-- relation between user and contact -->
<field name="partner_id" ref="contact_test"/>
</record>
<record id="employee_test" model="hr.employee">
<field name="name">My Name</field>
<field name="work_email">my_name#gmail.com</field>
<field name="user_id" ref="user_test"/>
<!-- relation employee and contact -->
<field name="address_home_id" ref="contact_test"/>
</record>
</data>
</openerp>
In this case will be created 1 contact, 1 user and 1 employee. Employee will have relation with contact.
Related
I have created a few companies under res.company
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="True">
<record id="partner_my_company_hk" model="res.partner" context="{'default_is_company': True}">
<field name="name">My company HK</field>
<field name="company_id" eval="None"/>
<field name="customer" eval="False"/>
<field name="is_company" eval="True"/>
<field name="street"></field>
<field name="city"></field>
<field name="zip"></field>
<field name="phone"></field>
<field name="email">info#my_company.com</field>
<field name="website">www.my_company.com</field>
<field name="image" type="base64" file="base/static/img/res_company_logo.png"/>
</record>
<record id="partner_my_company_us" model="res.partner">
<field name="name">My company US</field>
<field name="company_id" eval="None"/>
<field name="customer" eval="False"/>
<field name="is_company" eval="True"/>
<field name="street"></field>
<field name="city"></field>
<field name="zip"></field>
<field name="phone"></field>
<field name="email">info#my_company.com</field>
<field name="website">www.my_company.com</field>
<field name="image" type="base64" file="base/static/img/res_company_logo.png"/>
</record>
<record id="company_my_company_hk" model="res.company">
<field name="name">My company HK</field>
<field name="partner_id" ref="partner_my_company_hk"/>
<field name="currency_id" ref="base.USD"/>
</record>
<record id="partner_my_company_hk" model="res.partner">
<field name="company_id" ref="company_my_company_hk"/>
</record>
<record id="company_my_company_us" model="res.company">
<field name="name">My company US</field>
<field name="partner_id" ref="partner_my_company_us"/>
<field name="currency_id" ref="base.USD"/>
</record>
<record id="partner_my_company_us" model="res.partner">
<field name="company_id" ref="company_my_company_us"/>
</record>
</data>
</odoo>
This is my original res_users.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<record id="base.user_admin" model="res.users">
<field name="groups_id" eval="[(4, ref('account.group_account_user'))]"/>
</record>
</data>
</odoo>
So I want to set those 2 newly created 2 companies into base.user_admin
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<record id="base.user_admin" model="res.users">
<field name="groups_id" eval="[(4, ref('account.group_account_user'))]"/>
<field name="company_id" ref="company_my_company_hk" />
<field name="company_ids" eval="[(4, ref('company_my_company_hk')),(4, ref('company_my_company_us'))]" />
</record>
</data>
</odoo>
And it is not working. But when I uninstall the module and reinstall it works.
Why? I cannot uninstall the module just to make it work in the future. What are the limitations and how to bypass the limits?
You can change the noupdate value on XML, change the desired fields and should take the change on noupdate back.
<!-- Allow updating on noupdate=True records -->
<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data">
<value
eval="[('module', '=', 'base'), ('name', '=', 'user_admin')]" />
</function>
<value eval="{'noupdate': False}" />
</function>
<record id="base.user_admin" model="res.users">
<!-- change fields here -->
</record>
<!-- Revoke noupdate change -->
<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data">
<value
eval="[('module', '=', 'base'), ('name', '=', 'user_admin')]" />
</function>
<value eval="{'noupdate': True}" />
</function>
External ID user_admin in base has been marked as noupdate.
And noupdate cannot be overridden.
Unless I run
UPDATE ir_model_data SET noupdate=False WHERE name = 'user_admin' and module='base';
Otherwise I won't be able to update it when I upgrade the module
More refined solution to #CZoellner 's solution is:
<function name="toggle_noupdate" model="ir.model.data" eval="['res.users', ref('base.user_admin')]"/>
I need to remove a user from Administration group (settings/Access Rights).
I tried below code but nothing happened.
Custom_module.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="res.users" id="base.user_root">
<field name="groups_id" eval="[(3,ref('base.group_system'))]"/>
</record>
</data>
</openerp>
/base/base_securit.xml
<data noupdate="1">
<record model="res.groups" id="group_system">
<field name="name">Settings</field>
<field name="implied_ids" eval="[(4, ref('group_erp_manager'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
</data>
How can I do it?
<record model="res.groups" id="base.group_system">
<field name="users" eval="[(3,ref('base.user_root'))]"/>
</record>
Can you try the opposite? From the groups model remove the user from the group?
Odoo/openerp 8 supports creating dashboard in which we can add multiple reports into it.
My question is: How can we inherit this dashboard to customize it?
For example, I want to add a button which helps clone the dashboard to another user.
It seems that this dashboard is not a usual FormView.
You can't inherit dashboards in Odoo 8.because dashboards is work like views container not usual view if you want to customize one .. just copy it's code and paste it in your module over again and customize what you need.
Try to make formview for yourself :-)
This is a good example:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.actions.act_window" id="act_centiro_stocks_tree_pendientes">
<field name="name">Centiro stock</field>
<field name="res_model">stock.picking</field>
<field name="view_type">tree</field> <!-- form -->
<field name="view_mode">tree</field>
<field name="domain">[('state', 'not in', ('assigned','done'))]</field>
</record>
<record model="ir.actions.act_window" id="act_centiro_stocks_tree_procesados">
<field name="name">Centiro stock</field>
<field name="res_model">stock.picking</field>
<field name="view_type">tree</field> <!-- form -->
<field name="view_mode">tree</field>
<field name="domain">[('state', 'in', ('assigned','done'))]</field>
</record>
<record model="ir.actions.act_window" id="act_centiro_stocks_graph">
<field name="name">Operaciones Centiro</field>
<field name="res_model">gc.operaciones.centiro</field>
<field name="view_type">form</field>
<field name="auto_refresh" eval="1" />
<field name="view_mode">kanban,form</field>
</record>
<record model="ir.ui.view" id="board_view_stock_centiro_form">
<field name="name">Stock Centiro</field>
<field name="model">board.board</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Centiro Stock Dashboard">
<hpaned>
<child1>
<action string="Estado almacén Centiro" name="%(act_centiro_stocks_graph)d" colspan="2" />
</child1>
<child2>
<action string="Pedidos pendientes" name="%(act_centiro_stocks_tree_pendientes)d" colspan="2" />
<action string="Pedidos sin ubicar" name="%(act_centiro_stocks_tree_procesados)d" colspan="2" />
</child2>
</hpaned>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="open_stock_centiro_board">
<field name="name">Stock Centiro Dashboard</field>
<field name="res_model">board.board</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="usage">menu</field>
<field name="view_id" ref="board_view_stock_centiro_form" />
</record>
<menuitem id="dashboard_menu" name="Dasboard custom module"
parent="cabecera_dashboard_custom_module" action="open_stock_centiro_board" />
</data>
Good luck
I created a custom module and created a new user in odoo with email :1#1.com and password :1234 .When i try to login with new user webpage show this error
:"The server encountered an internal error and was unable to complete
your request. Either the server is overloaded or there is an error in
the application."
and in eclipe show this error:
"AccessError: ('AccessError', u'Sorry, you are not allowed to access
this document. Only users with the following access level are
currently allowed to do that:\n- Human Resources/Employee\n\t-
Administration/Settings\n\n(Document model: ir.ui.menu)')"
. Below is my code :
Core.py
from openerp.osv import fields, osv
class Student(osv.osv):
_name = "tt.student"
_columns = {
'name': fields.char('Code',size=20,required=True),
'ten': fields.char('Name',size=100,required=True),
'ngay':fields.date('Date',required=True),
}
Student()
main.xml
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="student_tree" model="ir.ui.view">
<field name="name">Student</field>
<field name="model">tt.student</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree>
<field string="Mã số" name="name"/>
<field string="Tên" name="ten"/>
<field string="Ngày sinh" name="ngay"/>
</tree>
</field>
</record>
<record id="student_form" model="ir.ui.view">
<field name="name">Student</field>
<field name="model">tt.student</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form>
<group col="2">
<field string="Mã số" name="name"/>
<field string="Tên" name="ten"/>
<field string="Ngày sinh" name="ngay"/>
</group>
</form>
</field>
</record>
<record id="action_student" model="ir.actions.act_window">
<field name="name">Student</field>
<field name="res_model">tt.student</field>
<field name="view_mode">tree,form</field>
</record>
</data>
</openerp>
menu.xml
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<menuitem id="main" name="Student"></menuitem>
<menuitem id="quanly" name="Quản lý" parent="main"></menuitem>
<menuitem id="sinhvien_sub" action="action_student" name="Sinh viên" parent="quanly"/>
</data>
</openerp>
You should add in the security folder the access. Add ir.access.csv file and you should define for each object the access to view, read, write and delete.
How to add customer payment tree to cahs register of openerp.I add in my coding like that.
'customer_payment_lines':fields.one2many('account.voucher','account_id','Customer Payments'),
in account.bank.statement.
But I can't see any line of customer payment in cash register.
What should i do?
Somebody help me.
Thanks in Advance.
For one2many, It is neccesary to put many2one in other object. in your case, you have to put many2one in account.voucher. and also check that you have kept your field "customer_payment_lines" in view. Try this,
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<!-- product tree -->
<record id="view_royalfood_customer_payment" model="ir.ui.view">
<field name="name">Royal Food Customer Payment</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form2" />
<field name="arch" type="xml">
<field name="opening_details_ids" position="after">
<field name="customer_payment_lines">
<tree>
<field name="name"/>
<field name="company_id"/>
<field name="account_id"/>
</tree>
</field>
</field>
</field>
</record>
</data>
</openerp>
Hope this will solve your problem.