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.
Related
I am using Odoo 11 and get the below error when installing a custom module. This is a module that is working in Odoo 10. I cant figure out where I am going wrong.
Field `custom_discount_product_id2` does not exist
Error context:
View `pos.config.custom.discount.form.view`
[view_id: 1029, xml_id: pos_custom.view_pos_config_form_custom_discount, model: pos.config, parent_id: 730]
None" while parsing /odoo/custom/addons/pos_custom/views/pos_custom_sale_view.xml:22, near
<record model="ir.ui.view" id="view_pos_config_form_custom_discount">
<field name="name">pos.config.custom.discount.form.view</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[#id='title']" position="after">
<group string="Custom Discount">
<field name="custom_discount_product_id2"/>
</group>
</xpath>
</field>
</record>
Here is my sale.py file
from odoo import api, fields, models
class PosConfig(models.Model):
_inherit = 'pos.config'
custom_discount_product_id2 = fields.Many2one('product.product', string='Custom Discount Product')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
And here is the view file.
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="view_pos_config_form_custom_discount">
<field name="name">pos.config.custom.discount.form.view</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[#id='title']" position="after">
<group string="Custom Discount">
<field name="custom_discount_product_id2" />
</group>
</xpath>
</field>
</record>
</data>
</openerp>
I've checked other modules, restarted server, but for some reason the field is not created.
Make sure <your_module>/__init__.py contains:
from . import models
and that <your_module>/models/__init__.py contains:
from . import sale
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.
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'm new to openerp.I want to add new fields to inherited custom module and at the same time i want to remove unwanted fields in newly created Custom Module.I want add some details like Mothername and Fathername and also i want to hide unwanted details like job position and website.Can any one please tell me.
Thanks in advance
My Code :
init.py
import lead
openerp.py
{
'name': 'Lead Information',
'version': '0.1',
'category': 'Tools',
'description': """This module is Lead information.""",
'author': 'Nitesh',
'website': '',
'depends': ['base'],
'init_xml': ['lead_view.xml'],
'update_xml': [],
'demo_xml': [],
'installable': True,
'active': True,
'application': True
}
lead.py
from osv import osv
from osv import fields
class cus(osv.osv):
_name = "lead.partner"
_inherit = "res.partner"
_description = "This table is for keeping lead data"
_columns = {
'mothername': fields.char('Mother Name',size=10,required=True)
}
lead_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- ===================== This is tree layout =============================-->
<record id="lead_tree" model="ir.ui.view">
<field name="name">Lead</field>
<field name="model">lead.partner</field>
<field name="arch" type="xml">
<field name="mothername"/>
<field name="website" position="attributes"><!--removed / from the end-->
<attribute name="invisible">True</attribute>
</field>
</field>
</record>
<!-- ========================This is Form layout===============================-->
<record id="lead_form" model="ir.ui.view">
<field name="name">Lead</field>
<field name="model">lead.partner</field>
<field name="arch" type="xml">
<field name="mothername"/>
<field name="function" position="attributes"><!--removed / from the end-->
<attribute name="invisible">True</attribute>
</field>
</field>
</record>
<!-- ========================= Action Layout ============================= -->
<record id="action_lead" model="ir.actions.act_window">
<field name="name">Lead</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,form</field>
<field name="view_id" ref="lead_tree"/>
</record>
<!-- ===========================Menu Settings=========================== -->
<menuitem name = "Lead" id = "menu_lis_lab" action="action_lead"/>
</data>
</openerp>
If you want to remove any field than use this,
<field name="website" position="replace"/>
you can remove fields which are from parent view. this is right way.
You can use these values in the position attribute:
inside (default): your values will be appended inside the tag
after: add the content after the tag
before: add the content before the tag
replace: replace the content of the tag.
for more details - http://openerp-server.readthedocs.org/en/latest/03_module_dev_03.html
Hope this would be helpful to you.
First add create the fields in *.py file and upgrade your custom module and later add the fields in *.xml and upgrade the module again,it will work perfectly fine.Now i can add the fields and hide the unwanted fields in my custom module
ex:I want add Mothername and Father name below "JObPostion" and to hide website field
the below is the working code
My code
lead_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- ===================== This is tree layout =============================-->
<record id="lead_tree" model="ir.ui.view">
<field name="name">Lead</field>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<tree string="lead">
<field name = "name"/>
</tree>
</field>
</record>
<!-- ========================This is Form layout===============================-->
<record id="view_res_partner_inherited" model="ir.ui.view">
<field name="name">view.res.partner.inherited</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<data>
<field name="website" position="replace"/>
<field name="function" position="after">
<field name="mothername"/>
<field name="fathername"/>
</field>
</data>
</field>
</record>
<!-- ========================= Action Layout ============================= -->
<record id="action_lead" model="ir.actions.act_window">
<field name="name">Lead</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,form</field>
<field name="view_id" ref="lead_tree"/>
</record>
<!-- ===========================Menu Settings=========================== -->
<menuitem name = "Lead" id = "menu_lis_lab" action="action_lead"/>
</data>
</openerp>
and
lead.py
from osv import osv
from osv import fields
class res_partner(osv.osv):
_inherit = "res.partner"
_description = "adding fields to res.partner"
_columns = {
'mothername': fields.char('Mother Name',size=64,required=True),
'fathername': fields.char('Father Name',size=64,required=True)
}
I am using openerp 6.My form contains one text box and I need to get that value and assign it to a variable so to perform calculations and to return a result to store in a new textbox...
I have give .py file here. This will calculate square of the number
from osv import osv
from osv import fields
class test_base(osv.osv):
_name='test.base'
_columns={
'first':fields.integer('Enter Number here'),
'result':fields.integer('Display calclation result'),
}
def first_change(self, cr, uid, ids,first,context=None):
r=first*first
return {'value':{'result':r}}
test_base()
xml file is given here
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="test_base_form">
<field name="name">test.base.form</field>
<field name="model">test.base</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="best Base">
<field name="first" on_change="first_change(first)"/>
<field name="result"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="test_base_tree">
<field name="name">test.base.tree</field>
<field name="model">test.base</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Test Base">
<field name="first"/>
<field name="result"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_test_seq">
<field name="name">Test Base</field>
<field name="res_model">test.base</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
</record>
<menuitem id="menu_test_base_main" name="Test Base">
</menuitem>
<menuitem id="menu_test_base_sub" parent="menu_test_base_main" name="Square number" action="action_test_seq">
</menuitem>
</data>
</openerp>