mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] web_widget_x2many_2d_matrix_example: add field_label_x_axis / field_label_y_axis features in tests module
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import x2m_demo
|
||||
from . import res_users
|
||||
|
||||
13
web_widget_x2many_2d_matrix_example/models/res_users.py
Normal file
13
web_widget_x2many_2d_matrix_example/models/res_users.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models, api, fields
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = 'res.users'
|
||||
|
||||
matrix_display_name = fields.Char(compute="_compute_matrix_display_name")
|
||||
|
||||
@api.depends("name", "email")
|
||||
def _compute_matrix_display_name(self):
|
||||
for user in self:
|
||||
user.matrix_display_name = "%s (%s)" % (user.name, user.email)
|
||||
@@ -7,8 +7,16 @@ class X2MDemo(models.Model):
|
||||
_description = 'X2Many Demo'
|
||||
|
||||
name = fields.Char()
|
||||
|
||||
display_name = fields.Char(compute="_compute_display_name")
|
||||
|
||||
line_ids = fields.One2many('x2m.demo.line', 'demo_id')
|
||||
|
||||
@api.depends("name")
|
||||
def _compute_display_name(self):
|
||||
for demo in self:
|
||||
demo.display_name = "%s (#%s)" % (demo.name, demo.id)
|
||||
|
||||
@api.multi
|
||||
def _open_x2m_matrix(self, view_xmlid):
|
||||
wiz = self.env['x2m.matrix.demo.wiz'].create({})
|
||||
@@ -46,7 +54,9 @@ class X2MDemoLine(models.Model):
|
||||
|
||||
name = fields.Char()
|
||||
demo_id = fields.Many2one('x2m.demo')
|
||||
demo_display_name = fields.Char(related="demo_id.display_name")
|
||||
user_id = fields.Many2one('res.users')
|
||||
user_display_name = fields.Char(related="user_id.matrix_display_name")
|
||||
value = fields.Integer()
|
||||
value_selection = fields.Selection(
|
||||
[('val1', 'Value 1'), ('val2', 'Value 2')],
|
||||
|
||||
Reference in New Issue
Block a user