Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Person/Location inheritance of res.partner #4

Merged
merged 7 commits into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fieldservice/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'views/fsm_order.xml',
'views/fsm_route.xml',
'views/menu.xml',
'data/fsm_stage.xml',
],
'application': True,
'license': 'AGPL-3',
Expand Down
43 changes: 43 additions & 0 deletions fieldservice/data/fsm_stage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="fsm_stage_new" model="fsm.stage">
<field name="name">New</field>
<field name="sequence">10</field>
</record>

<record id="fsm_stage_confirmed" model="fsm.stage">
<field name="name">Confirmed</field>
<field name="sequence">20</field>
</record>

<record id="fsm_stage_scheduled" model="fsm.stage">
<field name="name">Scheduled</field>
<field name="sequence">30</field>
</record>

<record id="fsm_stage_assigned" model="fsm.stage">
<field name="name">Assigned</field>
<field name="sequence">40</field>
</record>

<record id="fsm_stage_enroute" model="fsm.stage">
<field name="name">En Route</field>
<field name="sequence">50</field>
</record>

<record id="fsm_stage_started" model="fsm.stage">
<field name="name">Started</field>
<field name="sequence">60</field>
</record>

<record id="fsm_stage_complete" model="fsm.stage">
<field name="name">Complete</field>
<field name="sequence">70</field>
</record>

<record id="fsm_stage_cancelled" model="fsm.stage">
<field name="name">Cancelled</field>
<field name="sequence">100</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions fieldservice/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from . import (
res_config_settings,
res_partner,
fsm_stage,
fsm_location,
fsm_person,
Expand Down
17 changes: 13 additions & 4 deletions fieldservice/models/fsm_location.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo import api, fields, models


class FSMLocation(models.Model):
_name = 'fsm.location'
_inherit = 'res.partner'
_inherits = {
'res.partner': 'partner_id'
}
_description = 'Field Service Location'

name = fields.Char(string='Name')
type = fields.Char(string='Type', size=35)
description = fields.Char(string='Description')

@api.model
def create(self, vals):
vals.update({
'customer': False,
'type': 'delivery',
'fsm_location': True,
})
return super(FSMLocation, self).create(vals)
14 changes: 10 additions & 4 deletions fieldservice/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@ class FSMOrder(models.Model):
_name = 'fsm.order'
_description = 'Field Service Order'

def _default_stage_id(self):
return self.env.ref('fieldservice.fsm_stage_new')

name = fields.Char(string='Name', required=True)
fsm_route_id = fields.Many2one('fsm.route', string='Route')
partner_id = fields.Many2one('res.partner', string='Customer',
domain=('customer', '=', True))
customer_id = fields.Many2one('res.partner', string='Customer',
domain=('customer', '=', True))
fsm_location_id = fields.Many2one('fsm.location', string='Location')
fsm_person_id = fields.Many2one('fsm.person',
string='Field Service Person')
requested_date = fields.Datetime(string='Requested Date')
scheduled_date = fields.Datetime(string='Scheduled Date')
date = fields.Datetime(string='Date')
description = fields.Char(string='Description')
fsm_stage_id = fields.Many2one('fsm.stage', string='Stage')
description = fields.Text(string='Description')
stage_id = fields.Many2one('fsm.stage', string='Stage',
track_visibility='onchange',
index=True,
default=lambda self: self._default_stage_id())
14 changes: 11 additions & 3 deletions fieldservice/models/fsm_person.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo import api, models


class FSMPerson(models.Model):
_name = 'fsm.person'
_inherit = 'res.partner'
_inherits = {
'res.partner': 'partner_id'
}
_description = 'Field Service Person'

name = fields.Char(string='Name', size=35, required=True)
@api.model
def create(self, vals):
vals.update({
'customer': False,
'fsm_person': True,
})
return super(FSMPerson, self).create(vals)
11 changes: 9 additions & 2 deletions fieldservice/models/fsm_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,12 @@ class FSMRoute(models.Model):
fsm_order_ids = fields.One2many('fsm.order', 'fsm_route_id',
string='Orders')
fsm_person_id = fields.Many2one('fsm.person',
string='Field Service Person')
date = fields.Date(string='Date')
string='Field Service Person',
required=True)
date = fields.Date(string='Date', required=True)

_sql_constraints = [
('fsm_route_person_date_uniq',
'unique (fsm_person_id, date)',
"You cannot create 2 routes for the same person on the same day!"),
]
11 changes: 11 additions & 0 deletions fieldservice/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResPartner(models.Model):
_inherit = 'res.partner'

fsm_location = fields.Boolean('Is a Field Service Location')
fsm_person = fields.Boolean('Is a Field Service Person')
95 changes: 78 additions & 17 deletions fieldservice/views/fsm_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,38 @@
<field name="name">fsm.order.form</field>
<field name="model">fsm.order</field>
<field name="arch" type="xml">
<form string="Service Request">
<form string="Orders">
<header>
<field name="stage_id" widget="statusbar"/>
</header>
<sheet>
<group>
<group>
<field name="name"/>
<field name="partner_id"/>
<field name="customer_id"/>
<field name="fsm_location_id"/>
</group>
<group>
<field name="fsm_person_id"/>
<field name="scheduled_date"/>
<field name="date"/>
<field name="fsm_stage_id"/>
</group>
</group>
<notebook>
<page string="Request">
<field name="description"/>
<group>
<group>
<field name="requested_date"/>
</group>
<group></group>
</group>
<group string="Description">
<field name="description"
nolabel="1"
widget="html"/>
</group>
</page>
<page string="Attributes">
<page string="Work Orders" groups="">
</page>
<page string="Map">
</page>
Expand All @@ -40,10 +51,13 @@
<field name="name">fsm.order.tree</field>
<field name="model">fsm.order</field>
<field name="arch" type="xml">
<tree string="Service Requests" default_order="date">
<field name="partner_id" string="Customer"/>
<field name="fsm_stage_id" string="Stage"/>
<field name="date" string="Date"/>
<tree string="Order" default_order="date">
<field name="date"/>
<field name="name"/>
<field name="customer_id"/>
<field name="fsm_location_id"/>
<field name="fsm_person_id"/>
<field name="stage_id" string="Stage"/>
</tree>
</field>
</record>
Expand All @@ -52,16 +66,18 @@
<field name="name">fsm.order.kanban</field>
<field name="model">fsm.order</field>
<field name="arch" type="xml">
<kanban default_group_by="fsm_stage_id" class="o_kanban_small_column">
<field name="fsm_stage_id"/>
<field name="partner_id"/>
<kanban default_group_by="stage_id" class="o_kanban_small_column">
<field name="stage_id"/>
<field name="name"/>
<field name="customer_id"/>
<field name="fsm_location_id"/>
<templates>
<t t-name="kanban-box">
<div>
<ul>
<li>Record Name: <field name="name"/></li>
<li>Description: <field name="description"/></li>
<li><field name="name"/></li>
<li><field name="customer_id"/></li>
<li><field name="fsm_location_id"/></li>
</ul>
</div>
</t>
Expand All @@ -70,14 +86,59 @@
</field>
</record>

<record id="action_fsm_order" model="ir.actions.act_window">
<field name="name">Service Requests</field>
<record id="action_fsm_dash_order" model="ir.actions.act_window">
<field name="name">Orders</field>
<field name="res_model">fsm.order</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Create a Service Request.
Create an Order.
</p>
</field>
</record>

<record id="action_fsm_operation_order" model="ir.actions.act_window">
<field name="name">Orders</field>
<field name="res_model">fsm.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Create an Order.
</p>
</field>
</record>

<!-- Reporting -->
<record id="fsm_order_graph_view" model="ir.ui.view">
<field name="name">fsm.order.graph</field>
<field name="model">fsm.order</field>
<field name="arch" type="xml">
<graph string="Service Requests" type="bar">
<field name="stage_id" type="row"/>
</graph>
</field>
</record>

<record id="fsm_order_pivot_view" model="ir.ui.view">
<field name="name">fsm.order.pivot</field>
<field name="model">fsm.order</field>
<field name="arch" type="xml">
<pivot string="Service Requests" display_quantity="true">
<field name="stage_id" type="row"/>
</pivot>
</field>
</record>

<record id="action_fsm_report_order" model="ir.actions.act_window">
<field name="name">Orders</field>
<field name="res_model">fsm.order</field>
<field name="view_type">form</field>
<field name="view_mode">graph,pivot</field>
<field name="help" type="html">
<p>
Orders Reports.
</p>
</field>
</record>
Expand Down
13 changes: 9 additions & 4 deletions fieldservice/views/fsm_route.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<tree string="Day Routes">
<field name="fsm_person_id"/>
<field name="date"/>
<field name="fsm_order_ids"/>
</tree>
</field>
</record>
Expand All @@ -21,9 +20,15 @@
<form string="Day Route">
<sheet>
<group>
<field name="fsm_person_id"/>
<field name="date"/>
<field name="fsm_order_ids"/>
<group>
<field name="fsm_person_id"/>
</group>
<group>
<field name="date"/>
</group>
</group>
<group>
<field name="fsm_order_ids" nolabel="1"/>
</group>
</sheet>
</form>
Expand Down
14 changes: 12 additions & 2 deletions fieldservice/views/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
groups="group_fsm_manager"/>

<!-- Dashboard Menu -->
<menuitem id="menu_fsm_dash_order"
name="Orders"
action="action_fsm_dash_order"
parent="dashboard"
sequence="10"/>

<!-- Operations Menu -->
<!-- <menuitem id="menu_fsm_activity"
Expand All @@ -30,9 +35,9 @@
parent="operations"
sequence="10"/> -->

<menuitem id="menu_fsm_order"
<menuitem id="menu_fsm_operation_order"
name="Orders"
action="action_fsm_order"
action="action_fsm_operation_order"
parent="operations"
sequence="30"/>

Expand Down Expand Up @@ -62,6 +67,11 @@
sequence="30"/>

<!-- Reporting Menu -->
<menuitem id="menu_fsm_report_order"
name="Orders"
action="action_fsm_report_order"
parent="reporting"
sequence="10"/>

<!-- Configuration Menu -->
<menuitem id="settings"
Expand Down
Loading