You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
820 B

  1. from odoo import models, api, fields
  2. class X2MDemo(models.Model):
  3. _name = 'x2m.demo'
  4. name = fields.Char()
  5. line_ids = fields.One2many('x2m.demo.line', 'demo_id')
  6. @api.multi
  7. def open_x2m_matrix(self):
  8. wiz = self.env['x2m.matrix.demo.wiz'].create({})
  9. return {
  10. 'name': 'Try x2many 2D matrix widget',
  11. 'type': 'ir.actions.act_window',
  12. 'view_type': 'form',
  13. 'view_mode': 'form',
  14. 'res_model': 'x2m.matrix.demo.wiz',
  15. 'target': 'new',
  16. 'res_id': wiz.id,
  17. 'context': self.env.context,
  18. }
  19. class X2MDemoLine(models.Model):
  20. _name = 'x2m.demo.line'
  21. name = fields.Char()
  22. demo_id = fields.Many2one('x2m.demo')
  23. user_id = fields.Many2one('res.users')
  24. value = fields.Integer()