Field does not exist ODOO - odoo

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

Related

how to hide odoo 13 point of sale kanban droplist/drop menu?

I tried this code but nothing happened:
#view.xml
<odoo>
<data>
<record id="view_pos_config_kanban_inherit" model="ir.ui.view">
<field name="name">pos.config.inherit</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_kanban"/>
<field name="arch" type="xml">
<xpath expr="//kanban/templates/t/div/div[3][contains(#class='o_kanban_manage_button_section')]" position="replace">
</xpath>
</field>
</record>
</data>
</odoo>
What I want To Hide
Odoo will raise odoo.tools.convert.ParseError: "Invalid number of arguments" because of contains function used in div.
You can check in the XPath documentation provided by Odoo that contains is a function to manipulate strings:
contains(s1, s2)
returns true if s1 contains s2
Use XPath to locate the div with o_kanban_manage_button_section class and make it invisible.
Example:
<record id="view_pos_config_kanban" model="ir.ui.view">
<field name="name">pos.config.kanban.view</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_kanban"/>
<field name="arch" type="xml">
<xpath expr="//t/div/div/div[#class='o_kanban_manage_button_section']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
</field>
</record>
My Solution:
<odoo>
<data>
<record id="view_pos_config_kanban" model="ir.ui.view">
<field name="name">pos.config.kanban.view</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_kanban"/>
<field name="arch" type="xml">
<xpath expr="//kanban/templates/t/div/div[1]/div[2][#class='o_kanban_manage_button_section']" position="replace">
</xpath>
</field>
</record>
</data>
</odoo>

How to access custom module with normal user in odoo

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.

Add new fields and Hide unwanted fileds in Custom Module in Openerp

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)
}

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

Path for Custom Module in Openerp 7.0

my OpenERP 7.0 is install in d:\openERP 7.0 on windows 7. I have copied a custom module to D:\OpenERP 7.0\Server\server\openerp\addons, but when I update module list I am unable to see my custom module.
I have tried advanced search options with filters 'extra' and 'not installed' but still no success.
<data>
<record model="ir.ui.view" id="notebook_tree_view">
<field name="name">notebook.tree</field>
<field name="model">notebook</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Notebook">
<field name="title"/>
<field name="note"/>
<field name="note_date"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="notebook_form_view">
<field name="name">notebook.form</field>
<field name="model">notebook</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Notebook">
<field name="title"/>
<field name="note"/>
<field name="note_date"/>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_notebook_form">
<field name="name">notebook</field>
<field name="res_model">notebook</field>
</record>
<menuitem id="notebook_menu"
name="Notebook"
icon="terp-project"
/>
<menuitem id="notebook_menu_mainform"
name="Notes"
action="action_notebook_form"
parent="notebook_menu"
/>
</data>
try debugging this way :
1) Install another addons module and see if you can do
that. If you cannot do that then you are probably putting it
in the wrong directory.
You should have 3 directors one for the server , addons and web
2) If the above goes well then its your module which has
the problem. Double check your openerp.py file
For the form views you need to add an attribute version='7.0'
For example
<record model="ir.ui.view" id="notebook_form_view">
<field name="name">notebook.form</field>
<field name="model">notebook</field>
<field name="arch" type="xml">
<form string="Notebook" version="7.0">
<field name="title"/>
<field name="note"/>
<field name="note_date"/>
</form>
</field>
</record>
Also dont test the module in the old gtk client. openerp 7 doesnt have a gtk client