Salve ,
sono alle prime armi con Odoo 8 stò cercando di estendere la classe task inserendo una pagina nel notebook che contiene una lista di utenti , per ogni elemento della lista vorrei poter scegliere da un listbox un members del progetto padre del task,
ad ora sono riuscita a visualizzare la lista degli user , ma vorrei anche potere decidere di caricare solo gli utenti che fanno parte di un gruppo.
Qualcuno può darmi un aiuto? Grazie
questo è il mio codice:
# -*- coding: utf-8 -*-
from openerp import models, fields, api
class extended_task(models.Model):
_inherit = "project.task"
start_date = fields.Date('start date')
stop_date= fields.Date('stop date')
percentdone = fields.Float(string="%done")#, compute='_%done')
id_member_list = fields.One2many('extended_task.list_member', 'task_id', string="List member")
class list_members(models.Model):
_name = 'extended_task.list_member'
user_id =fields.Many2one('res.users', 'Membro task', required=True, select="1")
month_start =fields.Integer()
month_stop =fields.Integer()
tot_hours=fields.Integer()
task_id = fields.Many2one('extended_task.extended_task',
ondelete='cascade', string="List", required=True)
<openerp>
<data>
<!--Aggiungo campi in project form-->
<record model="ir.ui.view" id="edit_task">
<field name="name">project.task.form</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2"> </field>
<field name="arch" type="xml">
<!-- aggiunto lista allocati-->
<notebook position="inside">
<page string="Allocated list">
<field name="id_member_list" >
<tree string="Lista Allocati" editable="top">
<field name="user_id" context="{'default_groups_ref': }"/>
<field name="month_start"/>
<field name="month_stop"/>
<field name="tot_hours"/>
</tree>
</field>
</page>
</notebook>
<xpath expr="/form/sheet/group" position="after">
<group>
<!--il campo data inizio e data fine-->
<field name="start_date"></field>
<field name="stop_date"></field>
<!-- aggiunto %done-->
<field name="percentdone" widget="progressbar"></field>
</group>
</xpath>
</field>
</record>
<!-- add project task in project filter-->
<record id="view_project_task_filter" model="ir.ui.view">
<field name="name">project.task.search.form</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_search_form" ></field>
<field name="arch" type="xml">
<field name="name" position="after">
<group>
<field name="start_date" string="Start Date" ></field>
<field name="stop_date" string="Stop Date" ></field>
</group>
</field>
</field>
</record>
<!-- add the project task field on project view
-->
<record id="view_project_task" model="ir.ui.view">
<field name="name">project.task.tree</field>
<field name="model">project.task</field>
<field name="field_parent">child_ids</field>
<field name="inherit_id" ref="project.view_task_tree2" ></field>
<field name="arch" type="xml">
<field name="project_id" position="after">
<field name="start_date" string="Start Date" ></field>
<field name="stop_date" string="Stop Date" ></field>
</field>
</field>
</record>
<!-- -->
<!-- list members form view -->
<record model="ir.ui.view" id="list_member_form_view">
<field name="name">list_member.form</field>
<field name="model">extended_task.list_member</field>
<field name="arch" type="xml">
<form string="list member">
<sheet>
<group string="lista membri">
<field name="task_id"/>
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="list_member_tree_view">
<field name="name">list_member.tree</field>
<field name="model">extended_task.list_member</field>
<field name="arch" type="xml">
<tree string="member Tree">
<field name="task_id"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="list_member_list_action">
<field name="name">list_member</field>
<field name="res_model">extended_task.list_member</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
</data>
</openerp>