I have a model in a custom plugin that I'm developing with a field that I want to restrict to a particular domain. My model looks something like:
from openerp.osv import fields, osv
class MyModel(osv.Model):
_name = 'mymodel'
_columns = {
'ui_code_version': fields.many2one(
comodel_name='robots.software.versions',
string='UI Code Version',
domain="[('project', '=', 'ui')]"
)
}
When directly editing an instance of my model, it seems like the domain
is properly restricting my choices to ui project versions, which is great.
However, if I set up the Mass Editing module so that I can edit the ui versions of multiple instances of mymodel
, the domain filter is not applied and I can erroneously select software versions from other projects.
Poking around in the database, it looks like the domain isn't even being stored there.
MyOdooDatabase> SELECT name, domain FROM ir_model_fields \
WHERE model = 'mymodel' AND name = 'ui_code_version'
+-----------------------+----------+
| name | domain |
|-----------------------+----------|
| ui_code_version | <null> |
+-----------------------+----------+
Similarly, the domain isn't in the Settings->Technical->Database Structure->Fields entry for this field:
Q: How can I get the Mass Editing module to obey my fields domain so that I can only select ui project versions? Does that domain need to be stored in the database? If so, how?
Edit: As requested by Bhavesh Odedra, below are the definitions for robots.software.versions
and robots.software.projects
:
class RobotsSoftwareVersions(osv.Model):
_name = 'robots.software.versions'
_description = 'Software Version'
_columns = {
'name': fields.char('Name'),
'project': fields.many2one('robots.software.projects', 'Project'),
'version': fields.char('Version', help='The git tag or hash (e.g. 3.2.1)')
}
class RobotsSoftwareProjects(osv.Model):
_name = 'robots.software.projects'
_columns = {
'name': fields.char('Name'),
'upstream': fields.char('Upstream'),
}