Ajout des boutons de validation et du filtre sur la liste des résérvation

This commit is contained in:
eloyoussef 2018-02-13 15:04:55 +01:00
parent b389be7bbc
commit eccc217882
3 changed files with 44 additions and 5 deletions

View File

@ -77,6 +77,14 @@ class GolemReservation(models.Model):
def status_canceled(self):
self.status = 'canceled'
@api.multi
def status_validated(self):
self.status = 'validated'
@api.multi
def status_rejected(self):
self.status = 'rejected'
@api.constrains('status')
def _onConfirmReservation(self):
if self.status == 'confirmed':
@ -106,6 +114,8 @@ class GolemReservation(models.Model):
for reservation in self.linked_resource.reservation :
if(self.id != reservation.id and reservation.status == 'confirmed' and not (self.end_date < reservation.start_date or self.start_date > reservation.end_date)):
raise exceptions.UserError("Not allowed, the resource is taken during this period, please choose another période before confirming ")
elif (not self.linked_resource.validation_required):
self.status = 'validated'

View File

@ -43,6 +43,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="user"/>
<field name="on_behalf_of"/>
<field name="status"/>
</tree>
</field>
</record>
@ -60,6 +61,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<button name="status_canceled" type="object"
string="Cancel" statuss="confirmed"
class="oe_highlight"/>
<button name="status_validated" type="object"
string="Validate" statuss="confirmed"
class="oe_highlight"/>
<button name="status_rejected" type="object"
string="Reject" statuss="confirmed"
class="oe_highlight"/>
<field name="status" widget="statusbar"/>
</header>
<sheet>
@ -74,10 +81,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</form>
</field>
</record>
<!-- recherche relative au menu reservation-->
<record model="ir.ui.view" id="reservation_search_view">
<field name="name">reservation.search</field>
<field name="model">golem.reservation</field>
<field name="arch" type="xml">
<search string="Reservation tree">
<field name="start_date"/>
<field name="end_date"/>
<field name="linked_resource"/>
<field name="user"/>
<field name="on_behalf_of"/>
<field name="status"/>
<filter name="Reservations_to_validate" string="Reservation to Validate"
domain="[('status', '=', 'confirmed')]"/>
</search>
</field>
</record>
<!-- action relative au menu réservation-->
<record model="ir.actions.act_window" id="action_reservation">
<field name="name">Reservation</field>
<field name="res_model">golem.reservation</field>
<field name="view_mode">tree,form,calendar</field>
<field name="view_mode">tree,search,form,calendar</field>
</record>
<menuitem id="reservation_sub_menu" name="Reservation" parent="resources_menu"
action="action_reservation"/>

View File

@ -70,6 +70,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="arch" type="xml">
<tree string="Resource Form">
<field name="name"/>
<field name="validation_required"/>
<field name="resource_type"/>
<field name="resource_responsible"/>
<field name="article_link"/>
@ -95,6 +96,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<group colspan="2">
<group colspan="4" col="4">
<field name="name"/>
<field name="validation_required"/>
<field name="resource_type"/>
<field name="resource_responsible"/>
<field name="article_link"/>