forked from Yaltik/golem
Réalisation des améliorations proposés.
This commit is contained in:
parent
15a23e460f
commit
7dc2213593
@ -17,23 +17,22 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
from odoo import models, fields, api, exceptions
|
from odoo import models, fields, api, _, exceptions
|
||||||
#modèle de base : ressources
|
#modèle de base : ressources
|
||||||
class GolemResources(models.Model):
|
class GolemResources(models.Model):
|
||||||
""" GOLEM Resources """
|
""" GOLEM Resources """
|
||||||
_name = 'golem.resources'
|
_name = 'golem.resources'
|
||||||
_description = 'GOLEM Resources'
|
_description = 'GOLEM Resources'
|
||||||
|
|
||||||
name = fields.Char()
|
name = fields.Char(required=True)
|
||||||
active = fields.Boolean(default=False)
|
active = fields.Boolean(default=True)
|
||||||
resource_type = fields.Many2one("golem.resourcetype", string="Resource type")
|
resource_type = fields.Many2one("golem.resourcetype")
|
||||||
resource_responsible = fields.Many2one("res.partner", string="Resource Responsible")
|
resource_responsible = fields.Many2one("res.partner")
|
||||||
article_link = fields.Many2one("product.template", string="Article Link")
|
article_link = fields.Many2one("product.template")
|
||||||
|
|
||||||
#Configuration de disponibilité(période, jours et horaire)
|
#Configuration de disponibilité(période, jours et horaire)
|
||||||
start_of_availability_date = fields.Date(string="Start of availibility date ")
|
start_of_availability_date = fields.Date(required=True)
|
||||||
end_of_availability_date = fields.Date(string="End of availibility date ")
|
end_of_availability_date = fields.Date(required=True)
|
||||||
weekdays_of_availibility = fields.Many2many('golem.weekday', string="Weekdays of availibility")
|
|
||||||
timetable = fields.One2many("golem.timetable", "resource_id", string="Availibility timetable")
|
timetable = fields.One2many("golem.timetable", "resource_id", string="Availibility timetable")
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@ -48,9 +47,9 @@ class GolemReservation(models.Model):
|
|||||||
_name = 'golem.reservation'
|
_name = 'golem.reservation'
|
||||||
_description = 'GOLEM Reservation'
|
_description = 'GOLEM Reservation'
|
||||||
|
|
||||||
start_date = fields.Datetime(string='Start date')
|
start_date = fields.Datetime()
|
||||||
end_date = fields.Datetime(string='End date')
|
end_date = fields.Datetime()
|
||||||
linked_resource = fields.Many2one('golem.resources', string="Linked resource")
|
linked_resource = fields.Many2one('golem.resources', required=True)
|
||||||
user = fields.Many2one('res.users', required=True)
|
user = fields.Many2one('res.users', required=True)
|
||||||
on_behalf_of = fields.Many2one('res.partner', required=True)
|
on_behalf_of = fields.Many2one('res.partner', required=True)
|
||||||
status = fields.Selection([
|
status = fields.Selection([
|
||||||
@ -65,19 +64,27 @@ class GolemReservation(models.Model):
|
|||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def status_confirm(self):
|
def status_confirm(self):
|
||||||
self.status = 'confirmed'
|
#self.status = 'confirmed'
|
||||||
|
exceptions.ValidationError('not allowed')
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def status_canceled(self):
|
def status_canceled(self):
|
||||||
self.status = 'canceled'
|
self.status = 'canceled'
|
||||||
|
|
||||||
|
@api.constrains('status')
|
||||||
|
def _onConfirmReservation(self):
|
||||||
|
if(self.status == 'confrimed'):
|
||||||
|
exceptions.UserError('not allowed')
|
||||||
|
#exceptions.ValidationError('not allowed')
|
||||||
|
|
||||||
|
|
||||||
#modèle de base pour identifier le type de la ressource
|
#modèle de base pour identifier le type de la ressource
|
||||||
class GolemResourceType(models.Model):
|
class GolemResourceType(models.Model):
|
||||||
""" GOLEM Resource Type """
|
""" GOLEM Resource Type """
|
||||||
_name = 'golem.resourcetype'
|
_name = 'golem.resourcetype'
|
||||||
_description = 'GOLEM Resource Type'
|
_description = 'GOLEM Resource Type'
|
||||||
|
|
||||||
name = fields.Char(string='Resource Type')
|
name = fields.Char(string='Resource Type',required=True)
|
||||||
|
|
||||||
#modèle de base pour stocker les jours de la semaine
|
#modèle de base pour stocker les jours de la semaine
|
||||||
class GolemWeekDay(models.Model):
|
class GolemWeekDay(models.Model):
|
||||||
@ -100,6 +107,5 @@ class GolemTimetable(models.Model):
|
|||||||
|
|
||||||
@api.constrains('start_time', 'end_time')
|
@api.constrains('start_time', 'end_time')
|
||||||
def _check_time_consistency(self):
|
def _check_time_consistency(self):
|
||||||
for r in self:
|
if self.end_time < self.start_time:
|
||||||
if r.end_time < r.start_time:
|
raise exceptions.ValidationError(_('End time should be higher than start time'))
|
||||||
raise exceptions.ValidationError('End time should be higher than start time')
|
|
||||||
|
@ -67,7 +67,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="article_link"/>
|
<field name="article_link"/>
|
||||||
<field name="start_of_availability_date"/>
|
<field name="start_of_availability_date"/>
|
||||||
<field name="end_of_availability_date"/>
|
<field name="end_of_availability_date"/>
|
||||||
<field name="weekdays_of_availibility" widget="many2many_tags" options="{'no_create_edit':'1'}"/>
|
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@ -92,14 +91,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="resource_responsible"/>
|
<field name="resource_responsible"/>
|
||||||
<field name="article_link"/>
|
<field name="article_link"/>
|
||||||
</group>
|
</group>
|
||||||
|
<field name="id" invisible="1"/>
|
||||||
<group colspan="3">
|
<group colspan="3">
|
||||||
<separator string="Availibility configuration" colspan="3"/>
|
<separator string="Availibility configuration" colspan="3"/>
|
||||||
<field name="start_of_availability_date"/>
|
<field name="start_of_availability_date"/>
|
||||||
<field name="end_of_availability_date"/>
|
<field name="end_of_availability_date"/>
|
||||||
<field name="weekdays_of_availibility" widget="many2many_tags" options="{'no_create_edit':'1'}"/>
|
</group>
|
||||||
<field name="timetable">
|
<label string="Please save the resource before fixing the timetable availibility" attrs="{'invisible': [('id', '!=', False)]}"/>
|
||||||
<tree editable="bottom" context="{'default_resource_id': active_id}">
|
<group colspan="3">
|
||||||
<field name="resource_id" invisible="1" />
|
<field name="timetable" context="{'default_resource_id': active_id}" attrs="{'readonly': [('id', '=', False)]}">
|
||||||
|
<tree editable="bottom" >
|
||||||
|
<field name="resource_id" invisible="1"/>
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="start_time" />
|
<field name="start_time" />
|
||||||
<field name="end_time" />
|
<field name="end_time" />
|
||||||
@ -119,9 +121,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="view_mode">tree,form,search</field>
|
<field name="view_mode">tree,form,search</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<!--liste d'affichage du modèle golem.resources-->
|
||||||
|
<record model="ir.ui.view" id="resourcetype_tree_view">
|
||||||
|
<field name="name">resourcetype.tree</field>
|
||||||
|
<field name="model">golem.resourcetype</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree editable="bottom" string="Resource Type Form">
|
||||||
|
<field name="name"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!--action du sous menu configuration-->
|
||||||
|
<record model="ir.actions.act_window" id="action_configuration">
|
||||||
|
<field name="name">Resources Type</field>
|
||||||
|
<field name="res_model">golem.resourcetype</field>
|
||||||
|
<field name="view_mode">tree</field>
|
||||||
|
</record>
|
||||||
<!--menu principale et sous menu-->
|
<!--menu principale et sous menu-->
|
||||||
<menuitem id="resources_menu" name="Resources" sequence="10"/>
|
<menuitem id="resources_menu" name="Resources" />
|
||||||
<menuitem id="resources_sub_menu" name="Resources" parent="resources_menu"
|
<menuitem id="resources_sub_menu" name="Resources" parent="resources_menu"
|
||||||
action="action_resources"/>
|
action="action_resources"/>
|
||||||
|
<menuitem id="configuration_sub_menu" name="Configuration" parent="resources_menu"
|
||||||
|
action="action_configuration"/>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user