I need to change a field name in Odoo 11 installed on Windows.
In the customer credit notes field name (Taxes), I need to change that to (Pat).
How can I change it? Is it possible to change in XML through overriding and is it the correct way?
Yes you can do this through the xml using either one of below method.
<xpath expr="//field[#name='your_field_name']" position="attributes">
<attribute name="string">Pat</attribute>
</xpath>
OR
<field name="your_field_name" position="attributes">
<attribute name="string">Pat</attribute>
</field>
I hope it will help you.
You can do in XML if you want to do it only in that view. If you want to do it for all views, add string option in your Python code:
tax_ids = fields.Many2many('taxes.taxes',string = 'Pat' )
So in your dB and code references it will be called tax_ids but the user will see 'Pat'
Related
I have a many2many field that represents a list of student. I want to only add student to that list but not remove any students from that list (in form view). Is it possible to implement that?
I think it's possible to do it. You need to override the #write method. Each time that an update will be made on your object, you need the compare the actual length of your many2many field current_length and the new length of students made by the update new_length.
If new_length > current_length, it's means that the update is an adding, so you can consider the changes. Otherwise, it's means that the update is a removing, so you just need to ignore the changes.
Please find below, an exemple of implementation :
#api.multi
def write(self, values):
current_length = len(self.student_list)
new_length = len(values['student_list'])
if current_length > new_length:
\* Removing of students *\
values['student_list'] = self.student_list
res = super(Object, self).write(values)
return res
Note that you can go further by making another comparaison between the ids of the current and new list, in order to be sure that the students are the same.
It s not possible using the many2many_tags widget, but using the xml tree view as part of your Form view, you can add the delete-attribute on the tree-node inside the scope of your own field:
<form>
<notebook>
<sheet>
<page string="Graduated" name="gratuated_students">
<field name="students_ids" >
<tree string="Students" editable="bottom" delete="0" >
<field name="name"/>
<field name="birthday"/>
<field name="score" readonly="1"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
If this view comes from an odoo's module (no custom module): you'd rather inherit this view and add the attribute "delete=0" to the existing student_ids field:
<xpath expr="//form[1]/sheet[1]/notebook[1]/page[1]/field[#name='students_ids']/tree[1]" position="attributes">
<attribute name="delete">0</attribute>
</xpath>
Otherwise, if you really want to use the many2many_tags widget and if your are experienced with odoo's js-framework, you could develop your own option "no_delete" on the basis of the following OCA module:
https://odoo-community.org/shop/web-m2x-options-2661#attr=10772
I want hide fields for user in odoo 9. For example, hide Deadline in Project > Task module.
Only administrator can see this fields.
Any solution how create group etc. hide_only_admin_see and in field add this line.
<field name="date_deadline" groups="hide_only_admin_see" />
I'm find in source groups="base.group_no_one", groups="base.group_user"
but don't understand is it possible create my own group, when add to fiels that only Manager can see this...
Here is my solution:
https://postimg.org/image/rvxi74f51/
https://postimg.org/image/b87h1dlhv/
https://postimg.org/image/5mzst1wtz/
ID from file add to field etc: groups="export.res_groups_84"
On odoo 8, you forbid access to a field to all users (except configuration permissions) in that way:
<field name="date_deadline" position="attributes">
<attribute name="groups">base.group_system</attribute>
</field>
To create new group of permissions,
on odoo 8, you can create record for new category like:
<record model="ir.module.category" id="xxx">
<field name="name">Name of new category of permissions</field>
<field name="sequence">200</field>
</record>
You can create new records for groups permission on res_groups:
<record model="res.groups" id="hide_only_admin_see">
<field name="category_id" ref="XXXX"/>
<field name="name">Usuario</field>
</record>
On category_id you must write the ir_module_category you are creating / overridiing.
After this, you have to create a line on your ir.model.access.csv to give correct permissions to the model you want, something like:
"access_project.issue","project_issue access","model_project_issue","hide_only_admin_see",1,0,0,0
Finally, go to the line and override like:
<field name="date_deadline" groups="your_custom_module.hide_only_admin_see" />
I try to make a page tab in a view dynamicly visible based on the value of a field of the model. A field that is availble on the screen.
I need to change this is an inherited view
I tried:
<xpath expr="//page[#string='Functions']" position="attributes">
<attribute name="invisible">[('org_type_id','!=',0)]</attribute>
</xpath>
But now the page tab function is always hidden. even for the org_type_id that are 0.
Is it not possible to use xpath to add a dynamic invisible attritbute?
You are totally going on wrong way to do that job.
Just you can do with the the following way to do your job
some thing like this.
<xpath expr="//page[#string='Functions']" position="attributes">
<attribute name="attrs">{'invisible':[('org_type_id','!=',0)]}</attribute>
I hope this should helpful for you :)
You should also try this,
<page string="Functions" position="attributes">
<attribute name="attrs">{'invisible':[('org_type_id','!=',0)]}</attribute>
</page>
The partner_id has a context
{'show_address': 1}
Which I thought made the address show inline, but setting the context doesn't seem to accomplish the same thing on partner_shipping_id
<field name="partner_shipping_id" position="attributes">
<attribute name="context">{'show_address':1,'default_type':'delivery'}</attribute>
</field>
What am I missing?
Seems like I also need to make it always reload as the address is pulled in dynamically.
<field name="partner_shipping_id" position="attributes">
<attribute name="context">{'show_address':1,'default_type':'delivery'}</attribute>
<attribute name="options">{"always_reload": True}</attribute>
</field>
Yes you are right you missed
always_reload
Since the web client has already sent the record with a value it will not call name_get method. so the always_reload option in Many2one field forces to call name_get method explicitly
researchorial but indeed i have done all the google around what i want o achieve in openerp that how to change those fields label ,i don't wanna play with fields and i know how to create new fields but what about base fields i am not able to edit them they throw some error that you cannot change the base fields from here so objective is clear that those label like Company, SSNID in hr module i want them changed according to them nothing else!!
please do not post links of already same question cause they had not been answered !!
Thank You
You can change the label of a field in two ways.
1. Python code
Inherit the model where that field is defined, then inside _columns add the same field name with new label.
For example, if you want to change SSNID to Employee ID, assume that in the base module the field is defined as 'ssnid' and the field is in hr.employee model.
from osv import osv, fields
class hr_employee(osv.osv):
_inherit = 'hr.employee'
_columns = {'ssnid': fields.integer('Employee ID')
}
hr_employee()
2. XML code(change the view)
Inherit your view and add the attribute for the field 'ssnid'. For example in base module the field view is like <field name="ssnid"/> .To change it inherit its corresponding form and tree view and you can change the field by using position="attribute" and also position="replace". Add the attribute string="Employee ID".
<field name="ssnid" position="replace">
<field name="ssnid" string="Employee ID"/>
</field>
Create New Hr employee Inherited view By this way.
<record model="ir.ui.view" id="updated_hr_form_view">
<field name="name">updated.hr.form</field>
<field name="model">hr.employee</field>
<field name="type">form</field>
<field name="inherit_id" ref="hr.view_employee_form" />
<xpath expr="//form/notebook/page[#string='Personal Information'/group/field[#name='ssnid']]" position="replace">
<field name="ssnid" string="Your New Label"/>
</xpath>
</field>
</record>