Welcome!

Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

Sign up

You need to be registered to interact with the community.
This question has been flagged
1 Reply
44 Views

Hey Cyllo community, how do I create a new model in Cyllo?

Avatar
Discard

That's a great question! In Odoo, the standard model type for persistent business objects is 'models.Model'. Here's how you'd define a 'product.category' model:


from odoo import api, fields, models

class ProductCategory(models.Model):
​_name = 'product.category'
  ​_description = 'Product Category'
  ​_rec_name = 'name' 

​name = fields.Char(string='Category Name', required=True)
  ​description = fields.Text(string='Description')
  ​active = fields.Boolean(string='Active', default=True)
  ​parent_id = fields.Many2one('product.category', string='Parent Category') 
  ​child_ids = fields.One2many('product.category', 'parent_id', string='Child Categories')

Avatar
Discard

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!