forked from Yaltik/golem
amélioration de vue et raison de rejection
This commit is contained in:
parent
fdf556a8d8
commit
1415b0306f
@ -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 models
|
from . import models, wizard
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
'name': 'GOLEM resources pack',
|
'name': 'GOLEM resources pack',
|
||||||
'summary': 'GOLEM resources pack',
|
'summary': 'GOLEM resources pack',
|
||||||
'description': ''' GOLEM resources pack ''',
|
'description': ''' GOLEM resources pack ''',
|
||||||
'version': '10.0.0.0.3',
|
'version': '10.0.0.0.4',
|
||||||
'category': 'GOLEM',
|
'category': 'GOLEM',
|
||||||
'author': 'Youssef El Ouahby, Fabien Bourgeois',
|
'author': 'Youssef El Ouahby, Fabien Bourgeois',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
@ -28,5 +28,6 @@
|
|||||||
'installable': True,
|
'installable': True,
|
||||||
'depends': ['golem_resource'],
|
'depends': ['golem_resource'],
|
||||||
'data': ['views/golem_resource_pack_views.xml',
|
'data': ['views/golem_resource_pack_views.xml',
|
||||||
|
'wizard/golem_pack_rejection_views.xml',
|
||||||
'security/ir.model.access.csv']
|
'security/ir.model.access.csv']
|
||||||
}
|
}
|
||||||
|
@ -26,25 +26,39 @@ class GolemResourcePack(models.Model):
|
|||||||
""" GOLEM Resource Pack Model """
|
""" GOLEM Resource Pack Model """
|
||||||
_name = 'golem.resource.pack'
|
_name = 'golem.resource.pack'
|
||||||
_description = 'GOLEM Resource Pack Model'
|
_description = 'GOLEM Resource Pack Model'
|
||||||
|
_inherit = 'mail.thread'
|
||||||
|
|
||||||
name = fields.Char(compute='_compute_name', store=True)
|
name = fields.Char(compute='_compute_name', store=True)
|
||||||
reservation_ids = fields.One2many('golem.resource.reservation', 'pack_id')
|
reservation_ids = fields.One2many('golem.resource.reservation', 'pack_id',
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
track_visibility='onchange')
|
||||||
|
|
||||||
|
note = fields.Text(help='Notes, optional subject for the reservation, reason',
|
||||||
note = fields.Text(help='Notes, optional subject for the reservation, reason')
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
track_visibility='onchange')
|
||||||
|
|
||||||
user_id = fields.Many2one('res.users', required=True, index=True, readonly=True,
|
user_id = fields.Many2one('res.users', required=True, index=True, readonly=True,
|
||||||
string='User', default=lambda self: self.env.user)
|
string='User', default=lambda self: self.env.user)
|
||||||
partner_id = fields.Many2one('res.partner', string='On behalf of',
|
partner_id = fields.Many2one('res.partner', string='On behalf of',
|
||||||
required=True, index=True)
|
required=True, index=True, readonly=True,
|
||||||
|
states={'draft': [('readonly', False)]},
|
||||||
|
track_visibility='onchange')
|
||||||
state = fields.Selection([('canceled', 'Canceled'),
|
state = fields.Selection([('canceled', 'Canceled'),
|
||||||
('draft', 'Draft'),
|
('draft', 'Draft'),
|
||||||
('confirmed', 'Confirmed'),
|
('confirmed', 'Confirmed'),
|
||||||
('validated', 'Validated'),
|
('validated', 'Validated'),
|
||||||
('rejected', 'Rejected')],
|
('rejected', 'Rejected')],
|
||||||
default='draft', compute="_compute_pack_state")
|
default='draft', compute="_compute_pack_state",
|
||||||
|
track_visibility='onchange')
|
||||||
reservation_count = fields.Integer(compute="_compute_reservation_count",
|
reservation_count = fields.Integer(compute="_compute_reservation_count",
|
||||||
string="Reservation count")
|
string="Reservation count")
|
||||||
|
rejection_reason = fields.Text(readonly=True, track_visibility='onchange')
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.constrains('partner_id')
|
||||||
|
def set_reservation_partner(self):
|
||||||
|
for pack in self:
|
||||||
|
pack.reservation_ids.write({'partner_id': pack.partner_id.id})
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('reservation_ids')
|
@api.depends('reservation_ids')
|
||||||
@ -78,11 +92,15 @@ class GolemResourcePack(models.Model):
|
|||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def state_rejected(self):
|
def state_rejected(self):
|
||||||
""" pack rejected """
|
""" Wizard call for pack reject """
|
||||||
for pack in self:
|
self.ensure_one()
|
||||||
for reservation in pack.reservation_ids:
|
pack_id = self[0]
|
||||||
if reservation.state == "confirmed":
|
return {'name' : _('Please enter the rejection reason'),
|
||||||
reservation.write({'state' :'rejected'})
|
'type' : 'ir.actions.act_window',
|
||||||
|
'res_model' : 'golem.pack.rejection.wizard',
|
||||||
|
'context': {'default_pack_id': pack_id.id},
|
||||||
|
'view_mode': 'form',
|
||||||
|
'target': 'new'}
|
||||||
|
|
||||||
|
|
||||||
@api.depends('partner_id')
|
@api.depends('partner_id')
|
||||||
|
@ -18,22 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
-->
|
-->
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<!-- Calendars -->
|
|
||||||
<!-- <record model="ir.ui.view" id="golem_resource_reservation_view_calendar">
|
|
||||||
<field name="name">GOLEM Resource Reservation Calendar</field>
|
|
||||||
<field name="model">golem.resource.reservation</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<calendar date_start="date_start" date_stop="date_stop" color="resource_id"
|
|
||||||
event_open_popup="%(golem_resource.golem_resource_reservation_view_form)s"
|
|
||||||
mode="month">
|
|
||||||
<field name="resource_id" />
|
|
||||||
<field name="partner_id" />
|
|
||||||
<field name="note" />
|
|
||||||
</calendar>
|
|
||||||
</field>
|
|
||||||
</record>-->
|
|
||||||
|
|
||||||
<!-- Trees -->
|
<!-- Trees -->
|
||||||
<record model="ir.ui.view" id="golem_resource_pack_view_tree">
|
<record model="ir.ui.view" id="golem_resource_pack_view_tree">
|
||||||
<field name="name">GOLEM Resource Pack Tree</field>
|
<field name="name">GOLEM Resource Pack Tree</field>
|
||||||
@ -76,66 +60,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="user_id" />
|
<field name="user_id" />
|
||||||
<field name="partner_id" />
|
<field name="partner_id" />
|
||||||
<field name="note" />
|
<field name="note" />
|
||||||
|
<field name="rejection_reason"
|
||||||
|
attrs="{'invisible': [('state', '!=', 'rejected')]}"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<field name="reservation_ids" context="{'default_partner_id' : partner_id}" />
|
<field name="reservation_ids" context="{'default_partner_id' : partner_id}" />
|
||||||
</sheet>
|
</sheet>
|
||||||
<!--<div class="oe_chatter">
|
<div class="oe_chatter">
|
||||||
<field name="message_follower_ids" widget="mail_followers" />
|
<field name="message_follower_ids" widget="mail_followers" />
|
||||||
<field name="message_ids" widget="mail_thread" />
|
<field name="message_ids" widget="mail_thread" />
|
||||||
</div>-->
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Searches -->
|
|
||||||
<!--<record model="ir.ui.view" id="golem_resource_reservation_view_search">
|
|
||||||
<field name="name">GOLEM Resource Reservation Search</field>
|
|
||||||
<field name="model">golem.resource.reservation</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<search>
|
|
||||||
<field name="date_start" />
|
|
||||||
<field name="date_stop" />
|
|
||||||
<field name="day_start"/>
|
|
||||||
<field name="resource_id" />
|
|
||||||
<field name="user_id" />
|
|
||||||
<field name="partner_id" />
|
|
||||||
<field name="state" />
|
|
||||||
<filter name="state_draft" string="Draft"
|
|
||||||
domain="[('state', '=', 'draft')]" />
|
|
||||||
<filter name="state_confirmed" string="Confirmed, to Validate"
|
|
||||||
domain="[('state', '=', 'confirmed')]" />
|
|
||||||
<filter name="state_validated" string="Validated"
|
|
||||||
domain="[('state', '=', 'validated')]" />
|
|
||||||
<filter name="state_rejected" string="Rejected"
|
|
||||||
domain="[('state', '=', 'rejected')]" />
|
|
||||||
<separator />
|
|
||||||
<filter name="day_reservation" string="Day Reservation"
|
|
||||||
domain="[('day_start', '=', context_today().strftime('%%Y-%%m-%%d'))]" />
|
|
||||||
<filter name="7days_reservation" string="7 Days Reservations"
|
|
||||||
domain="[('date_start', '>=', (context_today()+datetime.timedelta(days=0)).strftime('%%Y-%%m-%%d')),
|
|
||||||
('date_start', '<=', (context_today()+datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]" />
|
|
||||||
<filter name="30days_reservation" string="30 Days Reservations"
|
|
||||||
domain="[('date_start', '>=', (context_today()+datetime.timedelta(days=0)).strftime('%%Y-%%m-%%d')),
|
|
||||||
('date_start', '<=', (context_today()+datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]" />
|
|
||||||
<filter name="group_state" string="State"
|
|
||||||
context="{'group_by': 'state'}" />
|
|
||||||
<filter name="group_resource" string="Resource"
|
|
||||||
context="{'group_by': 'resource_id'}" />
|
|
||||||
<filter name="group_partner_id" string="Partner"
|
|
||||||
context="{'group_by': 'partner_id'}" />
|
|
||||||
<filter name="group_user" string="User"
|
|
||||||
context="{'group_by': 'user_id'}" />
|
|
||||||
<filter name="group_date_month" string="Month"
|
|
||||||
context="{'group_by': 'date:month'}" />
|
|
||||||
<filter name="group_date_week" string="Week"
|
|
||||||
context="{'group_by': 'date:week'}" />
|
|
||||||
<filter name="group_date_day" string="Day"
|
|
||||||
context="{'group_by': 'date:day'}" />
|
|
||||||
</search>
|
|
||||||
</field>
|
|
||||||
</record>-->
|
|
||||||
|
|
||||||
<!-- Actions -->
|
<!-- Actions -->
|
||||||
<act_window id="golem_resource_pack_action" name="Reservation Pack"
|
<act_window id="golem_resource_pack_action" name="Reservation Pack"
|
||||||
res_model="golem.resource.pack" view_mode="tree,form" />
|
res_model="golem.resource.pack" view_mode="tree,form" />
|
||||||
|
19
golem_resource_pack/wizard/__init__.py
Normal file
19
golem_resource_pack/wizard/__init__.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# -*- 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/>.
|
||||||
|
|
||||||
|
from . import golem_pack_rejection
|
38
golem_resource_pack/wizard/golem_pack_rejection.py
Normal file
38
golem_resource_pack/wizard/golem_pack_rejection.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# -*- 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 Resources Pack management """
|
||||||
|
|
||||||
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
class GolemReservationRejectionWizard(models.TransientModel):
|
||||||
|
"""GOLEM Resource wizard : refusal reason for a pack """
|
||||||
|
_name = "golem.pack.rejection.wizard"
|
||||||
|
|
||||||
|
pack_id = fields.Many2one('golem.resource.pack', required=True)
|
||||||
|
reason = fields.Text(required=True)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def reject(self):
|
||||||
|
""" Sets pack status to rejected and add reason """
|
||||||
|
self.ensure_one()
|
||||||
|
rejection = self[0]
|
||||||
|
for reservation in rejection.pack_id.reservation_ids:
|
||||||
|
if reservation.state == "confirmed":
|
||||||
|
reservation.write({'state' :'rejected'})
|
||||||
|
rejection.pack_id.write({'rejection_reason': rejection.reason})
|
41
golem_resource_pack/wizard/golem_pack_rejection_views.xml
Normal file
41
golem_resource_pack/wizard/golem_pack_rejection_views.xml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?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>
|
||||||
|
|
||||||
|
<!-- Forms -->
|
||||||
|
<record model="ir.ui.view" id="golem_pack_rejection_wizard_view_form">
|
||||||
|
<field name="name">GOLEM Pack Rejection Wizard Form</field>
|
||||||
|
<field name="model">golem.pack.rejection.wizard</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Rejection reason">
|
||||||
|
<group>
|
||||||
|
<field name="pack_id" readonly="1" />
|
||||||
|
<field name="reason" />
|
||||||
|
</group>
|
||||||
|
<footer>
|
||||||
|
<button name="reject" string="Reject" type="object"
|
||||||
|
class="oe_highlight" />
|
||||||
|
<button string="Cancel" class="oe_link" special="cancel" />
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
Loading…
Reference in New Issue
Block a user