Skip to content

Commit

Permalink
[WIP][ADD] fsm_server_action
Browse files Browse the repository at this point in the history
[ADD] Templates

[WIP] Testing

[IMP] FSM Emails

[ADD] FSM Stage Server Action

[IMP] ir.server.action in pavlov_media

[IMP] Remove dependency conflict

[IMP] Cite OCA manifest

[IMP] Remove Dependency

[IMP] Auto Config for User

[IMP] Small changes

[FIX] fieldservice (PM OCA#515 and OCA#577) (OCA#230)

[IMP] fieldservice: Add notes on location (PM OCA#596) (OCA#231)

[FIX] fieldservice_agreement (OCA#232)

[ADD] fieldservice_stage_server_action
  • Loading branch information
osi-scampbell committed Jun 11, 2019
1 parent c57c61e commit 22323d6
Show file tree
Hide file tree
Showing 22 changed files with 922 additions and 4 deletions.
1 change: 1 addition & 0 deletions fieldservice/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'web_timeline',
'resource',
'contacts',
'partner_fax'
],
'data': [
'data/ir_sequence.xml',
Expand Down
10 changes: 10 additions & 0 deletions fieldservice/models/fsm_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,16 @@ def _check_location_recursion(self):
raise ValidationError(_('You cannot create recursive location.'))
return True

@api.onchange('country_id')
def _onchange_country_id(self):
if self.country_id and self.country_id != self.state_id.country_id:
self.state_id = False

@api.onchange('state_id')
def _onchange_state(self):
if self.state_id.country_id:
self.country_id = self.state_id.country_id


class FSMPerson(models.Model):
_inherit = 'fsm.person'
Expand Down
4 changes: 4 additions & 0 deletions fieldservice/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (C) 2019 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_fsm_wizard
111 changes: 111 additions & 0 deletions fieldservice/tests/test_fsm_wizard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Copyright (C) 2019 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests.common import TransactionCase


class FieldServiceTransactionCase(TransactionCase):
"""
Test used to check that the base functionalities of Field Service.
- test_convert_location: tests that a res.partner can be converted
into a fsm.location.
- test_convert_person: tests that a res.partner can be converted into
a fsm.person.
- test_convert_sublocation: tests that the sub-contacts on a
res.partner are converted into Other Addresses.
"""
def setUp(self):
super(FieldServiceTransactionCase, self).setUp()
# create a Res Partner
self.test_partner = self.env['res.partner'].\
create({
'name': 'Test Partner',
'phone': '123',
'email': 'tp@email.com',
})
# create a Res Partner to be converted to FSM Location/Person
self.test_loc_partner = self.env['res.partner'].\
create({
'name': 'Test Loc Partner',
'phone': 'ABC',
'email': 'tlp@email.com',
})
# create expected FSM Location to compare to converted FSM Location
self.test_location = self.env['fsm.location'].\
create({
'name': 'Test Location',
'phone': '123',
'email': 'tp@email.com',
'partner_id': self.test_loc_partner.id,
'owner_id': self.test_loc_partner.id,
'customer_id': self.test_loc_partner.id,
})
# create expected FSM Person to compare to converted FSM Person
self.test_person = self.env['fsm.person'].\
create({
'name': 'Test Person',
'phone': '123',
'email': 'tp@email.com',
})
self.test_wizard = self.env['fsm.wizard']

def test_convert_location(self):
# convert test_partner to FSM Location
self.test_wizard.action_convert_location(self.test_partner)

# check if there is a new FSM Location with name 'Test Partner'
self.wiz_location = self.env['fsm.location'].\
search([('name', '=', 'Test Partner')])

# check if 'Test Partner' creation successful and fields copied over
self.assertEqual(self.test_location.phone, self.wiz_location.phone)
self.assertEqual(self.test_location.email, self.wiz_location.email)

def test_convert_person(self):
# convert test_partner to FSM Person
self.test_wizard.action_convert_person(self.test_partner)

# check if there is a new FSM Person with name 'Test Partner'
self.wiz_person = self.env['fsm.person'].\
search([('name', '=', 'Test Partner')])

# check if 'Test Partner' creation successful and fields copied over
self.assertEqual(self.test_person.phone, self.wiz_person.phone)
self.assertEqual(self.test_person.email, self.wiz_person.email)

def test_convert_sublocation(self):
# create 4 Res Partners each with different type
s1 = self.env['res.partner'].create({
'name': 'sub partner 1',
'type': 'contact'
})
s2 = self.env['res.partner'].create({
'name': 'sub partner 2',
'type': 'invoice'
})
s3 = self.env['res.partner'].create({
'name': 'sub partner 3',
'type': 'delivery'
})
s4 = self.env['res.partner'].create({
'name': 'sub partner 4',
'type': 'private'
})

# create parent Res Partner and assign its children
children = [s1.id, s2.id, s3.id, s4.id]
parent = s1 = self.env['res.partner'].create({
'name': 'Parent Partner',
'child_ids': [(6, 0, children)]
})

# convert Parent Partner to FSM Location
self.test_wizard.action_convert_location(parent)

# check if 'Parent Partner' creation successful and fields copied over
wiz_parent = self.env['fsm.location'].\
search([('name', '=', 'Parent Partner')])

# check all children were assigned type 'other'
for child in wiz_parent.child_ids:
self.assertEqual(child.type, 'other')
8 changes: 7 additions & 1 deletion fieldservice/views/fsm_location.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
<field name="owner_id"/>
<field name="customer_id"/>
<field name="contact_id" context="{'default_service_location_id': active_id, 'default_street': street, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id}"/>
<field name="phone" widget="phone"/>
<field name="fax" widget="phone"/>
<field name="email" widget="email"/>
<label for="street" string="Address"/>
<div class="o_address_format">
<field name="street" placeholder="Street..." class="o_address_street"/>
Expand All @@ -89,9 +92,12 @@
<field name="description"/>
<field name="tz"/>
<field name="calendar_id"/>
<field name="category_id" widget="many2many_tags" options="{'color_field': 'color'}"/>
<field name="category_id" widget="many2many_tags" options="{'color_field': 'color'}" required="True"/>
</group>
</group>
<group string="General Notes">
<field name="notes" nolabel="1" widget="html"/>
</group>
<notebook>
<page string="Directions">
<field name="direction" nolabel="1" widget="html"/>
Expand Down
2 changes: 1 addition & 1 deletion fieldservice/views/fsm_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
<field name="arch" type="xml">
<search string="Orders">
<field name="name"
filter_domain="['|', ('name', 'ilike', self), ('code', '=like', str(self) + '%')]"
filter_domain="['|', ('name', 'ilike', self), ('name', '=like', str(self) + '%')]"
string="FSM Order Name"/>
<field name="location_id"/>
<field name="branch_id"/>
Expand Down
5 changes: 5 additions & 0 deletions fieldservice/wizard/fsm_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def action_convert_location(self, partner):
'customer_id': partner.id}
self.env['fsm.location'].create(vals)
partner.write({'fsm_location': True})
self.action_other_address(partner)
else:
raise UserError(_('A Field Service Location related to that'
' partner already exists.'))
Expand All @@ -50,3 +51,7 @@ def action_convert_person(self, partner):
else:
raise UserError(_('A Field Service Worker related to that'
' partner already exists.'))

def action_other_address(self, partner):
for child in partner.child_ids:
child.type = 'other'
3 changes: 2 additions & 1 deletion fieldservice_agreement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
'views/fsm_order_view.xml',
'views/fsm_equipment_view.xml',
'views/agreement_view.xml',
'views/fsm_person.xml'
'views/fsm_person.xml',
'views/fsm_location.xml'
],
'installable': True,
'development_status': 'Beta',
Expand Down
3 changes: 2 additions & 1 deletion fieldservice_agreement/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from . import (
agreement,
fsm_equipment,
fsm_location,
fsm_order,
fsm_person
fsm_person,
)
26 changes: 26 additions & 0 deletions fieldservice_agreement/models/fsm_location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class FSMLocation(models.Model):
_inherit = 'fsm.location'

serviceprofile_ids = fields.Many2many('agreement.serviceprofile',
string="Service Profiles",
compute='_compute_service_ids')

@api.multi
def _compute_service_ids(self):
for loc in self:
agreements = self.env['agreement'].\
search([('fsm_location_id', '=', self.name)])
ids = []
for agree in agreements:
servpros = self.env['agreement.serviceprofile'].\
search([('agreement_id', '=', agree.id)])
for ser in servpros:
if ser.id not in ids:
ids.append(ser.id)
self.serviceprofile_ids = ids
24 changes: 24 additions & 0 deletions fieldservice_agreement/views/fsm_location.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Copyright 2019 Open Source Integrators
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -->
<odoo>

<record id="fsm_location_agreement_serviceprofile" model="ir.ui.view">
<field name="name">fsm.location.agreement.serviceprofile</field>
<field name="model">fsm.location</field>
<field name="inherit_id" ref="fieldservice.fsm_location_form_view"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Service Profiles">
<field name="serviceprofile_ids">
<tree>
<field name="name"/>
<field name="agreement_id"/>
<field name="notes"/>
</tree>
</field>
</page>
</notebook>
</field>
</record>

</odoo>
120 changes: 120 additions & 0 deletions fieldservice_stage_server_action/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
===================================
Field Service - Stage Server Action
===================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ffield--service-lightgray.png?logo=github
:target: https://github.com/OCA/field-service/tree/12.0/fieldservice_skill
:alt: OCA/field-service
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/field-service-12-0/field-service-12-0-fieldservice_skill
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/264/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|



**Table of contents**

.. contents::
:local:

Installation
============

To install Field Service and have the mapping features, you need to install GeoEngine.

Please refer to the installation instructions available at:
https://github.com/OCA/geospatial/tree/12.0/base_geoengine

Configuration
=============

To configure this module, you need to:



Usage
=====

To use this module, you need to:


Known issues / Roadmap
======================

The roadmap of the Field Service application is documented on
`Github <https://github.com/OCA/field-service/issues/1>`_.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/field-service/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/field-service/issues/new?body=module:%20fieldservice_skill%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Open Source Integrators

Contributors
~~~~~~~~~~~~

* Wolfgang Hall <whall@opensourceintegrators.com>
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
* Steve Campbell <scampbell@opensourceintegrators.com>

Other credits
~~~~~~~~~~~~~

The development of this module has been financially supported by:

* Open Source Integrators <https://opensourceintegrators.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-osi-scampbell| image:: https://github.com/osi-scampbell.png?size=40px
:target: https://github.com/osi-scampbell
:alt: osi-scampbell
.. |maintainer-max3903| image:: https://github.com/max3903.png?size=40px
:target: https://github.com/max3903
:alt: max3903

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-osi-scampbell| |maintainer-max3903|

This module is part of the `OCA/field-service <https://github.com/OCA/field-service/tree/12.0/fieldservice_skill>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions fieldservice_stage_server_action/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (C) 2019 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
Loading

0 comments on commit 22323d6

Please sign in to comment.