Reason for Error:-
Field 'hide_inv_button' used in attributes must be present in view but is missing: - 'hide_inv_button' in attrs="{'invisible': [('hide_inv_button', '!=', True)]}"
My Model is:-
class StudentMarkList(models.Model):
_name = 'student.mark'
_rec_name = 'student_id'
student_id = fields.Many2one('student.student',string='StudentName')
branch= fields.Many2one('student.branch', string='Branch Name')
sub1= fields.Many2one('student.subject', string='Subjectname1')
mark1 =fields.Integer(string='Mark1')
sub2= fields.Many2one('student.subject', string='Subjectname2')
mark2 =fields.Integer(string='Mark2')
sub3= fields.Many2one('student.subject', string='Subjectname3')
mark3 =fields.Integer(string='Mark3')
total =fields.Integer(string='Total Mark',store="true",compute='_compute_total')
state = fields.Selection([
('confirmed', 'Confirm'),
], string='Status', readonly=True, copy=False, index=True, track_visibility='onchange')
@api.depends('mark1','mark2','mark3')
def _compute_total(self):
for record in self:
record.total = record.mark1+record.mark2+record.mark3
@api.multi
def action_confirm(self):
self.state = 'confirmed'
self.hide_inv_button = False
My View is :-
<!-- Form View of Student MarkList-->
<record model="ir.ui.view" id="studentmark_form_view">
<field name="name">studentmark.form</field>
<field name="model">student.mark</field>
<field name="arch" type="xml">
<form string="StudentMark Form">
<header>
<button name="action_confirm" string="Confirm" type="object" class="oe_highlight"
attrs="{'invisible': [('hide_inv_button', '!=', True)]}"/>
</header>
<sheet>
<group>
<field name="student_id"/>
<field name="branch"/>
</group>
<notebook>
<page string="Marks">
<table>
<tr>
<td> Subject </td>
<td> Mark </td>
</tr>
<tr>
<td><field name="sub1"/> </td>
<td><field name="mark1"/> </td>
</tr>
<tr>
<td><field name="sub2"/> </td>
<td><field name="mark2"/> </td>
</tr>
<tr>
<td><field name="sub3"/> </td>
<td><field name="mark3"/> </td>
</tr>
</table>
</page>
</notebook>
Total Marks :-<field name="total"/>
</sheet>
</form>
</field>
</record>
Please Help..
Thanks in Advance...
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
Hi Aswathy,
In your XML you have the following piece of code:
<button name="action_confirm" string="Confirm" type="object" class="oe_highlight"
attrs="{'invisible': [('hide_inv_button', '!=', True)]}"/>
However, nowhere in the XML you have defined the field 'hide_inv_button'. Because of this Odoo cannot handle your invisible attribute as it does not know how to interpret or parse it. Simply add the 'hide_inv_button' somewhere in your form. If you don't want it visible you can hide it for users in the view while the condition will keep working:
<field name="hide_inv_button" invisible="1"/> <!-- Remove invisible="1" if you also want to show the field to the users -->
Regards,
Yenthe
My button is not visible now..
I have changed like this
My model is:-
class StudentMarkList(models.Model):
_name = 'student.mark'
_rec_name = 'student_id'
student_id = fields.Many2one('student.student',string='StudentName')
branch= fields.Many2one('student.branch', string='Branch Name')
sub1= fields.Many2one('student.subject', string='Subjectname1')
mark1 =fields.Integer(string='Mark1')
sub2= fields.Many2one('student.subject', string='Subjectname2')
mark2 =fields.Integer(string='Mark2')
sub3= fields.Many2one('student.subject', string='Subjectname3')
mark3 =fields.Integer(string='Mark3')
total =fields.Integer(string='Total Mark',store="true",compute='_compute_total')
hide_inv_button =fields.Boolean(string='Invisibles')
state = fields.Selection([
('confirmed', 'Confirm'),
], string='Status', readonly=True, copy=False, index=True, track_visibility='onchange')
@api.depends('mark1','mark2','mark3')
def _compute_total(self):
for record in self:
record.total = record.mark1+record.mark2+record.mark3
@api.multi
def action_confirm(self):
self.state = 'confirmed'
self.hide_inv_button = False
My View is:-
<record model="ir.ui.view" id="studentmark_form_view">
<field name="name">studentmark.form</field>
<field name="model">student.mark</field>
<field name="arch" type="xml">
<form string="StudentMark Form">
<header>
<button name="action_confirm" string="Confirm" type="object" class="oe_highlight"
attrs="{'invisible': [('hide_inv_button', '!=', True)]}"/>
</header>
<sheet>
<group>
<field name="student_id"/>
<field name="branch"/>
<field name="hide_inv_button" invisible="1"/>
</group>
<notebook>
<page string="Marks">
<table>
<tr>
<td> Subject </td>
<td> Mark </td>
</tr>
<tr>
<td><field name="sub1"/> </td>
<td><field name="mark1"/> </td>
</tr>
<tr>
<td><field name="sub2"/> </td>
<td><field name="mark2"/> </td>
</tr>
<tr>
<td><field name="sub3"/> </td>
<td><field name="mark3"/> </td>
</tr>
</table>
</page>
</notebook>
Total Marks :-<field name="total"/>
</sheet>
</form>
</field>
</record>
That is because your domain matches with the value of your boolean field. by default hide_inv_button is false, matching the domain to hide the button by default too.
When I set the default=True then it works
Thank You
Exactly, changes the default computation of the domain. Best of luck. :)
Oh my god spent over 5 hours diving into Odoo source code with no lucky and what I missed is
`<field name="my_god_damn_field" invisible="1"/>`
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden