over 9 years ago
If you want to make data model in OpenERP(Odoo) follow the below mentioned code and paste it in your model.py file:
- session_ids = fields.One2many(
- 'openacademy.session', 'course_id', string="Sessions")
- @api.multi
- def copy(self, default=None):
- default = dict(default or {})
- copied_count = self.search_count(
- [('name', '=like', u"Copy of {}%".format(self.name))])
- if not copied_count:
- new_name = u"Copy of {}".format(self.name)
- else:
- new_name = u"Copy of {} ({})".format(self.name, copied_count)
- default['name'] = new_name
- return super(Course, self).copy(default)
- _sql_constraints = [
- ('name_description_check',
- 'CHECK(name != description)',
session_ids = fields.One2many( 'openacademy.session', 'course_id', string="Sessions") @api.multi def copy(self, default=None): default = dict(default or {}) copied_count = self.search_count( [('name', '=like', u"Copy of {}%".format(self.name))]) if not copied_count: new_name = u"Copy of {}".format(self.name) else: new_name = u"Copy of {} ({})".format(self.name, copied_count) default['name'] = new_name return super(Course, self).copy(default) _sql_constraints = [ ('name_description_check', 'CHECK(name != description)',
0 Comment(s)