Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
928 Visualizzazioni

Hi All,

(I do not have access to the coding, only Studio)

I've added a Many2Many field [Dep. Skills] within the Department view on Employees tab, this is a selection to show which Skills are required within that specific department.

I'm then trying to create sub-lists, breaking down the Dep. Skills into the 11 categories [Skill Type]

I want to only need to add the data in once per department, in the Dep. Skills field, which then auto-populates the categories.

How would I go about this? 

I want all mentioned fields to be shown as Many2Many Labels, if possible.

(The below fields are manually added, to provide a visual representation, I want this to be auto-filled, based on Skill Type)


Avatar
Abbandona
Risposta migliore

To create sub-lists and auto-populate the categories based on the Dep. Skills field, you can use the following steps:

  1. Create a Many2Many field called Dep. Skills in the Department view.
  2. Create a Many2Many field called Skill Type in the Skill model.
  3. Create a relationship between the Department and Skill models.
  4. Create a computed field in the Department model that calculates the list of Skill Types for the current department.
  5. Set the Dep. Skills field in the Department view to be a Many2Many Label.

Here is an example of the code for the computed field:

def _get_skill_types(self):
    return self.skill_ids.mapped('skill_type_id')

skill_types = fields.Many2ManyField('skill.skill', compute='_get_skill_types', string='Skill Types',
help='The list of skill types for this department.')

This code first gets the list of Skills that are associated with the current department. The code then maps the Skills to their Skill Types. The resulting list of Skill Types is then returned by the computed field.

Once you have created the computed field, you can set the Dep. Skills field in the Department view to be a Many2Many Label. This will display the list of Skill Types as a clickable list. When the user clicks on a Skill Type, the corresponding Skills will be displayed.

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
lug 23
6403
2
gen 25
436
0
nov 23
6215
2
lug 22
1839
2
dic 19
5834