Add initial Odoo FSM modules and deployment make targets
This commit is contained in:
1
odoo/addons/dsrpt_repair_technicians/__init__.py
Normal file
1
odoo/addons/dsrpt_repair_technicians/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
14
odoo/addons/dsrpt_repair_technicians/__manifest__.py
Normal file
14
odoo/addons/dsrpt_repair_technicians/__manifest__.py
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "DSRPT Repair Technicians",
|
||||
"summary": "Technicians and availability",
|
||||
"version": "19.0.1.0.0",
|
||||
"category": "Services",
|
||||
"author": "DisruptLab",
|
||||
"license": "LGPL-3",
|
||||
"depends": ["base", "dsrpt_repair_main"],
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"views/technician_views.xml",
|
||||
],
|
||||
"installable": True,
|
||||
}
|
||||
1
odoo/addons/dsrpt_repair_technicians/models/__init__.py
Normal file
1
odoo/addons/dsrpt_repair_technicians/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import technician
|
||||
66
odoo/addons/dsrpt_repair_technicians/models/technician.py
Normal file
66
odoo/addons/dsrpt_repair_technicians/models/technician.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from odoo import api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class RepairTechnician(models.Model):
|
||||
_name = "repair.technician"
|
||||
_description = "Repair Technician"
|
||||
_order = "name"
|
||||
|
||||
name = fields.Char(required=True)
|
||||
user_id = fields.Many2one("res.users", string="User")
|
||||
zone_ids = fields.Many2many("repair.fsm.zone", string="FSM Zones")
|
||||
active = fields.Boolean(default=True)
|
||||
schedule_ids = fields.One2many("repair.technician.schedule", "technician_id", string="Weekly Schedule")
|
||||
exception_ids = fields.One2many("repair.technician.exception", "technician_id", string="Exceptions")
|
||||
|
||||
|
||||
class RepairTechnicianSchedule(models.Model):
|
||||
_name = "repair.technician.schedule"
|
||||
_description = "Repair Technician Weekly Schedule"
|
||||
_order = "technician_id, day_of_week, hour_from"
|
||||
|
||||
technician_id = fields.Many2one("repair.technician", required=True, ondelete="cascade")
|
||||
day_of_week = fields.Selection(
|
||||
selection=[
|
||||
("0", "Monday"),
|
||||
("1", "Tuesday"),
|
||||
("2", "Wednesday"),
|
||||
("3", "Thursday"),
|
||||
("4", "Friday"),
|
||||
("5", "Saturday"),
|
||||
("6", "Sunday"),
|
||||
],
|
||||
required=True,
|
||||
)
|
||||
hour_from = fields.Float(required=True)
|
||||
hour_to = fields.Float(required=True)
|
||||
|
||||
@api.constrains("hour_from", "hour_to")
|
||||
def _check_hours(self):
|
||||
for rec in self:
|
||||
if rec.hour_from < 0 or rec.hour_to > 24 or rec.hour_to <= rec.hour_from:
|
||||
raise ValidationError("Schedule hours must be between 0 and 24, and hour_to must be greater than hour_from.")
|
||||
|
||||
|
||||
class RepairTechnicianException(models.Model):
|
||||
_name = "repair.technician.exception"
|
||||
_description = "Repair Technician Exception"
|
||||
_order = "start_datetime desc"
|
||||
|
||||
technician_id = fields.Many2one("repair.technician", required=True, ondelete="cascade")
|
||||
name = fields.Char(required=True)
|
||||
exception_type = fields.Selection(
|
||||
selection=[("positive", "Positive"), ("negative", "Negative")],
|
||||
required=True,
|
||||
default="negative",
|
||||
)
|
||||
start_datetime = fields.Datetime(required=True)
|
||||
end_datetime = fields.Datetime(required=True)
|
||||
note = fields.Text()
|
||||
|
||||
@api.constrains("start_datetime", "end_datetime")
|
||||
def _check_dates(self):
|
||||
for rec in self:
|
||||
if rec.end_datetime <= rec.start_datetime:
|
||||
raise ValidationError("Exception end must be after start.")
|
||||
@@ -0,0 +1,4 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_repair_technician_user,repair.technician user,model_repair_technician,base.group_user,1,1,1,1
|
||||
access_repair_technician_schedule_user,repair.technician.schedule user,model_repair_technician_schedule,base.group_user,1,1,1,1
|
||||
access_repair_technician_exception_user,repair.technician.exception user,model_repair_technician_exception,base.group_user,1,1,1,1
|
||||
|
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<record id="view_repair_technician_tree" model="ir.ui.view">
|
||||
<field name="name">repair.technician.tree</field>
|
||||
<field name="model">repair.technician</field>
|
||||
<field name="arch" type="xml">
|
||||
<list>
|
||||
<field name="name"/>
|
||||
<field name="user_id"/>
|
||||
<field name="zone_ids" widget="many2many_tags"/>
|
||||
<field name="active"/>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_repair_technician_form" model="ir.ui.view">
|
||||
<field name="name">repair.technician.form</field>
|
||||
<field name="model">repair.technician</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="user_id"/>
|
||||
<field name="zone_ids" widget="many2many_tags"/>
|
||||
<field name="active"/>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Weekly Schedule">
|
||||
<field name="schedule_ids" context="{'default_technician_id': id}">
|
||||
<list editable="bottom">
|
||||
<field name="day_of_week"/>
|
||||
<field name="hour_from"/>
|
||||
<field name="hour_to"/>
|
||||
</list>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Exceptions">
|
||||
<field name="exception_ids" context="{'default_technician_id': id}">
|
||||
<list editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="exception_type"/>
|
||||
<field name="start_datetime"/>
|
||||
<field name="end_datetime"/>
|
||||
<field name="note"/>
|
||||
</list>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_repair_technician" model="ir.actions.act_window">
|
||||
<field name="name">Technicians</field>
|
||||
<field name="res_model">repair.technician</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_repair_technicians" name="Technicians" parent="dsrpt_repair_main.menu_repair_root" action="action_repair_technician" sequence="30"/>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user