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
|
||||
class GolemResources(models.Model):
|
||||
""" GOLEM Resources """
|
||||
_name = 'golem.resources'
|
||||
_description = 'GOLEM Resources'
|
||||
|
||||
name = fields.Char()
|
||||
active = fields.Boolean(default=False)
|
||||
resource_type = fields.Many2one("golem.resourcetype", string="Resource type")
|
||||
resource_responsible = fields.Many2one("res.partner", string="Resource Responsible")
|
||||
article_link = fields.Many2one("product.template", string="Article Link")
|
||||
name = fields.Char(required=True)
|
||||
active = fields.Boolean(default=True)
|
||||
resource_type = fields.Many2one("golem.resourcetype")
|
||||
resource_responsible = fields.Many2one("res.partner")
|
||||
article_link = fields.Many2one("product.template")
|
||||
|
||||
#Configuration de disponibilité(période, jours et horaire)
|
||||
start_of_availability_date = fields.Date(string="Start of availibility date ")
|
||||
end_of_availability_date = fields.Date(string="End of availibility date ")
|
||||
weekdays_of_availibility = fields.Many2many('golem.weekday', string="Weekdays of availibility")
|
||||
start_of_availability_date = fields.Date(required=True)
|
||||
end_of_availability_date = fields.Date(required=True)
|
||||
timetable = fields.One2many("golem.timetable", "resource_id", string="Availibility timetable")
|
||||
|
||||
@api.multi
|
||||
@ -48,9 +47,9 @@ class GolemReservation(models.Model):
|
||||
_name = 'golem.reservation'
|
||||
_description = 'GOLEM Reservation'
|
||||
|
||||
start_date = fields.Datetime(string='Start date')
|
||||
end_date = fields.Datetime(string='End date')
|
||||
linked_resource = fields.Many2one('golem.resources', string="Linked resource")
|
||||
start_date = fields.Datetime()
|
||||
end_date = fields.Datetime()
|
||||
linked_resource = fields.Many2one('golem.resources', required=True)
|
||||
user = fields.Many2one('res.users', required=True)
|
||||
on_behalf_of = fields.Many2one('res.partner', required=True)
|
||||
status = fields.Selection([
|
||||
@ -65,19 +64,27 @@ class GolemReservation(models.Model):
|
||||
|
||||
@api.multi
|
||||
def status_confirm(self):
|
||||
self.status = 'confirmed'
|
||||
#self.status = 'confirmed'
|
||||
exceptions.ValidationError('not allowed')
|
||||
|
||||
@api.multi
|
||||
def status_canceled(self):
|
||||
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
|
||||
class GolemResourceType(models.Model):
|
||||
""" GOLEM Resource Type """
|
||||
_name = 'golem.resourcetype'
|
||||
_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
|
||||
class GolemWeekDay(models.Model):
|
||||
@ -100,6 +107,5 @@ class GolemTimetable(models.Model):
|
||||
|
||||
@api.constrains('start_time', 'end_time')
|
||||
def _check_time_consistency(self):
|
||||
for r in self:
|
||||
if r.end_time < r.start_time:
|
||||
raise exceptions.ValidationError('End time should be higher than start time')
|
||||
if self.end_time < self.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="start_of_availability_date"/>
|
||||
<field name="end_of_availability_date"/>
|
||||
<field name="weekdays_of_availibility" widget="many2many_tags" options="{'no_create_edit':'1'}"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@ -92,14 +91,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<field name="resource_responsible"/>
|
||||
<field name="article_link"/>
|
||||
</group>
|
||||
<field name="id" invisible="1"/>
|
||||
<group colspan="3">
|
||||
<separator string="Availibility configuration" colspan="3"/>
|
||||
<field name="start_of_availability_date"/>
|
||||
<field name="end_of_availability_date"/>
|
||||
<field name="weekdays_of_availibility" widget="many2many_tags" options="{'no_create_edit':'1'}"/>
|
||||
<field name="timetable">
|
||||
<tree editable="bottom" context="{'default_resource_id': active_id}">
|
||||
<field name="resource_id" invisible="1" />
|
||||
</group>
|
||||
<label string="Please save the resource before fixing the timetable availibility" attrs="{'invisible': [('id', '!=', False)]}"/>
|
||||
<group colspan="3">
|
||||
<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="start_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>
|
||||
</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-->
|
||||
<menuitem id="resources_menu" name="Resources" sequence="10"/>
|
||||
<menuitem id="resources_menu" name="Resources" />
|
||||
<menuitem id="resources_sub_menu" name="Resources" parent="resources_menu"
|
||||
action="action_resources"/>
|
||||
<menuitem id="configuration_sub_menu" name="Configuration" parent="resources_menu"
|
||||
action="action_configuration"/>
|
||||
</data>
|
||||
</odoo>
|
||||
|
Loading…
Reference in New Issue
Block a user