I need to assign Technical feature group to admin during installing my custom module. I tried below code.
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="res.users" id="base.user_root">
<field name="partner_id" ref="base.partner_root"/>
<field name="company_id" ref="base.main_company"/>
<field name="company_ids" eval="[(4, ref('base.main_company'))]"/>
<field name="groups_id" eval="[(4,ref('base.group_no_one'))]"/> <!--ams.group_residents -->
<field name="signature"><![CDATA[<span>--<br/>
Administrator</span>]]></field>
</record>
</data>
</openerp>
How can I do that?
Adding base.group_no_one to groups_id is sufficient:
<record model="res.users" id="base.user_root">
<field name="groups_id" eval="[(4,ref('base.group_no_one'))]"/>
</record>
Related
[![enter image description here][1]][1]I have a problem with adding a new field to the sale order view of odoo12. I have created a new module. I hope that you can help me.
Below the code of my view form
<odoo>
<record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml"></field>
<field name="payment_term_id" position="after">
<field name="additional_note"/>
</field>
</record>
</odoo>```
when i try to install the new module i have the following error:
File "src\lxml\etree.pyx", line 3557, in lxml.etree._Validator.assert_
AssertionError: Element odoo has extra content: record, line 3
[1]: https://i.stack.imgur.com/e1DOw.png
The problem is in the <field name="arch" type="xml"></field> line: the <field> tag is closed, and your additional_note field is declared outside of it.
Try this code instead:
<odoo>
<record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<!-- Leave the 'arch' field open -->
<field name="arch" type="xml">
<!-- Put your custom field and its position inside the 'arch' field.
Use 'xpath' tag to create a more precise positioning -->
<xpath expr="//group/group/field[#name='payment_term_id']" position="after">
<field name="additional_note"/>
</xpath>
<!-- Now, close the 'arch' field -->
</field>
</record>
</odoo>
The view is not correctly defined, you can refer to account_analytic_view.
The view definition should be (according to the provided link):
<odoo>
<record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<data>
<field name="payment_term_id" position="after">
<field name="additional_note"/>
</field>
</data>
</field>
</record>
</odoo>
I'm new to Odoo. While trying to call a server action from a menuitem it can't find the model_id.
My view code:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.actions.server" id="open_calculator">
<field name="name">Open Calculator</field>
<field name="model_id" ref="calculator"/>
<field name="type">ir.actions.server</field>
<field name="state">code</field>
<field name="code">
<!--code-->
</field>
</record>
<!-- Top menu item -->
<menuitem name="Calculator" id="calculator.menu_root"
action="open_calculator"/>
</data>
</openerp>
The error:
raise ValueError('External ID not found in the system: %s' % (xmlid))
ParseError: "External ID not found in the system: calculator.calculator" while parsing /home/administrador/Escritorio/calculator-test-project/calculator/views/views.xml:4, near
<record model="ir.actions.server" id="open_calculator">
<field name="name">Open Calculator</field>
<field name="model_id" ref="calculator"/>
<field name="type">ir.actions.server</field>
<field name="state">code</field>
<field name="code">
<!--code-->
</field>
</record>
Model:
# -*- coding: utf-8 -*-
from openerp import models, fields, api, http
class Calculator(models.Model):
_name = 'calculator'
What am I missing?
It appears that there is a convention you have to follow in model_id's ref attr. You have to add '_model' before your model name:
<field name="model_id" ref="model_calculator"/>
instead of:
<field name="model_id" ref="calculator"/>
or it won't work.
Just as in this question
I have been trying to target an inherited element in the view, but it's not working for me.
So I have a view that inherits from the form view of hr.contract as shown here:
<record id="hr_contract_view_form_cayor" model="ir.ui.view">
<field name="name">name</field>
<field name="model">hr.contract</field>
<field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
<field name="arch" type="xml">
<data>
<!-- more elements define with xpath -->
<xpath expr="//field[#name='job_id']" position="after">
<field name="retirement_age"/>
</xpath>
...
<xpath expr="//page[#name='information']" position="after">
<page string="Allowances" groups="hr_payroll.group_hr_payroll_user">
<group>
<group name="allowances_group1">
...
<field name="car_allowance"/>
...
</group>
<group name="allowances_group2">
...
</group>
</group>
</page>
</xpath>
</data>
</field>
</record>
I have defined a new file to inherit from this form view, which adds a new field to it, as follows:
<record id="hr_contract.hr_contract_view_form_inherited" model="ir.ui.view">
<field name="name">hr.contract.grade.rank.form.inherit</field>
<field name="model">hr.contract</field>
<field name="inherit_id" ref="module.hr_contract_view_form_cayor"/>
<field name="arch" type="xml">
<data>
<xpath expr="//group[#name='allowances_group1']" position="inside">
<field name="medical_allowance" />
</xpath>
</data>
</field>
</record>
But when I upgrade my module, I get the following error:
Field `retirement_age` does not exist
How can I correctly inherit from the first one, and add my new field?
Any help will be greatly appreciated, thanks in advance.
Please try this code :
Python :
class HrContract(models.Model):
_inherit = 'hr.contract'
retirement_age = fields.Char(string="Retirement Age:")
XML :
<record id="hr_contract_view_form_cayor" model="ir.ui.view">
<field name="name">name</field>
<field name="model">hr.contract</field>
<field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
<field name="arch" type="xml">
<data>
<!-- more elements define with xpath -->
<xpath expr="//field[#name='job_id']" position="after">
<field name="retirement_age"/>
</xpath>
</data>
</field>
</record>
I want to add one field call validator to customer invoice (account_invoice).
openerp.py:
'depends': ['base','account'],
my model:
class account_invoice_validator(models.Model):
_inherit = "account.invoice"
validator = fields.Char()
my view:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<!-- Model: account.invoice -->
<record id="view_account_invoice_customer_validator" model="ir.ui.view">
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='user_id']" position="after">
<field name="validator"/>
</xpath>
</field>
</record>
</data>
</openerp>
the validator column was added to database but i couldn't show it on the tree view (list). What do i miss?
Can you try like this?
<record id="view_account_invoice_customer_validator" model="ir.ui.view">
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_tree"/>
<field name="arch" type="xml">
<xpath expr="//tree/field[#name='user_id']" position="after">
<field name="validator"/>
</xpath>
</field>
</record>
Try this:
<record id="view_account_invoice_customer_validator" model="ir.ui.view">
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_tree"/>
<field name="arch" type="xml">
<xpath expr="/tree/field[#name='user_id']" position="after">
<field name="validator"/>
</xpath>
</field>
</record>
How do I add a selection field for country in information panel of product.product_normal_form_view
Here is the solution.
<record id="product_normal_form_view_inherit" model="ir.ui.view">
<field name="name">product.normal.form.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<xpath expr="//form/sheet/notebook/page[#string='Information']/group/group/field[#name='list_price']" position="after">
<field name="country_id"/>
</xpath>
</field>
</record>
Inherit product.template.
Your xml file should be:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_template_product_form_inherited" model="ir.ui.view">
<field name="name">product.template.product.form.inherited</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//page[#string='Information']/group/group" position="inside">
<field name='country_id'/>
</xpath>
</field>
</record>
</data>
</openerp>
python file:
from openerp import models, fields
class product_template(models.Model):
_inherit = 'product.template'
country_id = fields.Many2one('res.country', 'Country')