Fonction de recherche de membres

This commit is contained in:
eloyoussef 2018-03-23 15:44:37 +01:00
parent 4cd64ef8aa
commit 79c8d501a0
7 changed files with 140 additions and 30 deletions

View File

@ -27,5 +27,6 @@
'installable': True, 'installable': True,
'depends': ['golem_member', 'golem_family'], 'depends': ['golem_member', 'golem_family'],
'data': ['views/golem_member_views.xml', 'data': ['views/golem_member_views.xml',
'wizard/golem_precreation_member_wizard_views.xml'] 'wizard/golem_precreation_member_request_wizard_views.xml',
'wizard/golem_precreation_member_result_wizard_views.xml']
} }

View File

@ -18,10 +18,9 @@
""" GOLEM Members """ """ GOLEM Members """
import logging
from odoo import models, fields, api, _ from odoo import models, api, _
from odoo.exceptions import UserError
_LOGGER = logging.getLogger(__name__)
class GolemMember(models.Model): class GolemMember(models.Model):
@ -30,10 +29,24 @@ class GolemMember(models.Model):
@api.multi @api.multi
def precreation_search(self): def precreation_search(self):
""" Precreation member search """
self.ensure_one() self.ensure_one()
return {'name' : _('Please enter the rejection reason'), return {'name' : _('Please enter member searched'),
'type' : 'ir.actions.act_window', 'type' : 'ir.actions.act_window',
'res_model' : 'golem.precreation.member.wizard', 'res_model' : 'golem.precreation.member.request.wizard',
#'context': {'default_reservation_id': reservation_id.id},
'view_mode': 'form', 'view_mode': 'form',
'target': 'new'} 'target': 'new'}
@api.multi
def open_line(self):
""" open member form """
self.ensure_one()
return {
'type': 'ir.actions.act_window',
'name': 'Member',
'view_type': 'form',
'view_mode': 'form',
'res_model': self._name,
'res_id': self.id,
'flags': {'initial_mode': 'edit'},
'target': 'current',
}

View File

@ -16,4 +16,4 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from . import golem_precreation_member_wizard from . import golem_precreation_member_request_wizard, golem_precreation_member_result_wizard

View File

@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
""" GOLEM Precreation Member Request wizard"""
from odoo import models, fields, api
class GolemPrecreationMemberRequestWizard(models.TransientModel):
"""GOLEM Precreation Request Member Wizard """
_name = "golem.precreation.member.request.wizard"
name = fields.Char()
@api.multi
def search_members(self):
""" Search members """
self.ensure_one()
domain = ['|',
('name', 'ilike', self.name),
('email', 'ilike', self.name)]
members = self.env['golem.member'].search(domain)
if members:
ids = members.mapped('id')
return {'name' : ('Member search result "{}"'.format(self.name)),
'type' : 'ir.actions.act_window',
'res_model' : 'golem.precreation.member.result.wizard',
'context': {'default_member_ids': ids},
'view_mode': 'form',
'flags': {'initial_mode': 'view'},
'target': 'new'}

View File

@ -18,32 +18,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<odoo> <odoo>
<data> <data>
<!--<record id="golem_precreation_member_wizard" type="ir.ui.view" > <record model="ir.ui.view" id="golem_precreation_member_request_wizard">
<field name="name">Golem Precreation Member Wizard</field> <field name="name">Golem Precreation Member Request Wizard Form</field>
<field name="model">golem.precreation.member.wizard</field> <field name="model">golem.precreation.member.request.wizard</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form> <form string="Member Searching">
<group>
<field name="name"/>
</group>
</form>
</field>
</record>-->
<record model="ir.ui.view" id="golem_precreation_member_wizard">
<field name="name">Golem Precreation Member Wizard Form</field>
<field name="model">golem.precreation.member.wizard</field>
<field name="arch" type="xml">
<form string="Rejection reason">
<group> <group>
<field name="name" /> <field name="name" />
</group> </group>
<footer> <footer>
<button name="search_members" string="Search" type="object" class="oe_link" />
<button string="Cancel" class="oe_link" special="cancel" /> <button string="Cancel" class="oe_link" special="cancel" />
</footer> </footer>
</form> </form>
</field> </field>
</record> </record>
</data> </data>
</odoo> </odoo>

View File

@ -19,8 +19,9 @@
from odoo import models, fields, api from odoo import models, fields, api
class GolemPrecreationMemberWizard(models.TransientModel): class GolemPrecreationMemberResultWizard(models.TransientModel):
"""GOLEM Precreation member wizard """ """GOLEM Precreation member Result Wizard """
_name = "golem.precreation.member.wizard" _name = "golem.precreation.member.result.wizard"
name = fields.Char() member_ids = fields.Many2many('golem.member')
name_searched = fields.Char(default="test")

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<odoo>
<data>
<!--<record id="golem_precreation_member_wizard" type="ir.ui.view" >
<field name="name">Golem Precreation Member Wizard</field>
<field name="model">golem.precreation.member.wizard</field>
<field name="arch" type="xml">
<form>
<group>
<field name="name"/>
</group>
</form>
</field>
</record>-->
<record model="ir.ui.view" id="golem_precreation_member_result_wizard">
<field name="name">Golem Precreation Member result Wizard Form</field>
<field name="model">golem.precreation.member.result.wizard</field>
<field name="arch" type="xml">
<form string="list">
<label string="No member found for the current search"
attrs="{'invisible': [('member_ids', '!=', [])]}"/>
<field name="member_ids" readonly="1"
attrs="{'invisible': [('member_ids', '=', [])]}">
<tree readonly="1">
<field name="id" invisible="1"/>
<field name="firstname"/>
<field name="lastname"/>
<field name="email"/>
<button name="open_line" type="object"
string="details" />
</tree>
</field>
<footer>
<button string="Close" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
</data>
</odoo>