I want to notify the user that a record has been updated so I create a boolean field that indicates the change. I also color coded the tree so that when the boolean field is set true the color will change to notify the user.
Now I have to update the boolean field when the user click on the record in the tree view and open the form view. How do I do that?
Here is a dummy model and a dummy view I created:
Model:
from openerp import models, fields, api, _
class form_record_update_test_subject_a(models.Model):
_name = "form.record.update.test.subject.a"
name = fields.Char('Name')
is_blue = fields.Boolean('Is Blue')
form_record_update_test_subject_a()
View:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<menuitem name="Testing Module"
id="testing_module_menu"
sequence="1"/>
<menuitem id="form_record_update_menu" name="Form Record Update Test" parent="testing_module_menu" sequence="1"/>
<record model="ir.ui.view" id="form_record_update_test_subject_a_form_view">
<field name="name">form.record.update.test.subject.a.form.view</field>
<field name="model">form.record.update.test.subject.a</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Form Request Update Test" version="8.0">
<sheet>
<group>
<field string="Name" name="name" class="oe_inline"/>
<field string="Is Blue" name="is_blue" class="oe_inline"/>
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="form_record_update_test_subject_a_tree_view">
<field name="name">form.record.update.test.subject.a.tree.view</field>
<field name="model">form.record.update.test.subject.a</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Class" colors="blue:is_blue==True">
<field string="Name" name="name"/>
<field string="Is Blue" name="is_blue"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="form_record_update_test_subject_a_search">
<field name="name">form.record.update.test.subject.a.search</field>
<field name="model">form.record.update.test.subject.a</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Form Request Update Test Search">
<field string="Name" name="name"/>
<field string="Is Blue" name="is_blue"/>
</search>
</field>
</record>
<record id="form_record_update_test_subject_a_action" model="ir.actions.act_window">
<field name="name">Form Request Update Test</field>
<field name="res_model">form.record.update.test.subject.a</field>
<field name="view_type">form</field>
<field name="domain">[]</field>
<field name="context">{}</field>
<field name="view_id" eval="form_record_update_test_subject_a_tree_view"/>
<field name="search_view_id" ref="form_record_update_test_subject_a_search"/>
<field name="target">current</field>
<field name="help">Form Request Update Test</field>
</record>
<menuitem action="form_record_update_test_subject_a_action" icon="STOCK_JUSTIFY_FILL" sequence="1"
id="form_record_update_test_subject_a_action_menu" parent="testing_module.form_record_update_menu"
/>
</data>
</openerp>