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.

34 lines
955 B

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