Browse Source

[11.0][ADD] agreement_fsm module

pull/230/head
Bhavesh Odedra 6 years ago
parent
commit
b376498fe9
  1. 4
      agreement_fsm/__init__.py
  2. 24
      agreement_fsm/__manifest__.py
  3. 4
      agreement_fsm/models/__init__.py
  4. 38
      agreement_fsm/models/agreement.py
  5. 12
      agreement_fsm/models/fsm_order.py
  6. 0
      agreement_fsm/readme/CONFIGURE.rst
  7. 1
      agreement_fsm/readme/CONTRIBUTORS.rst
  8. 3
      agreement_fsm/readme/CREDITS.rst
  9. 7
      agreement_fsm/readme/DESCRIPTION.rst
  10. 0
      agreement_fsm/readme/ROADMAP.rst
  11. 8
      agreement_fsm/readme/USAGE.rst
  12. BIN
      agreement_fsm/static/description/icon.png
  13. 19
      agreement_fsm/views/agreement_view.xml
  14. 17
      agreement_fsm/views/fsm_order_view.xml

4
agreement_fsm/__init__.py

@ -0,0 +1,4 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

24
agreement_fsm/__manifest__.py

@ -0,0 +1,24 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "FSM Agreements",
"summary": "Manage FSM Agreements",
"author": "Open Source Integrators, "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/contract",
"category": "Partner",
"license": "AGPL-3",
"version": "11.0.1.0.0",
"depends": [
"fieldservice",
"agreement",
],
"data": [
"views/agreement_view.xml",
"views/fsm_order_view.xml",
],
"application": True,
"development_status": "Beta",
"maintainers": ["max3903", "bodedra"],
}

4
agreement_fsm/models/__init__.py

@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import fsm_order
from . import agreement

38
agreement_fsm/models/agreement.py

@ -0,0 +1,38 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models, api
class Agreement(models.Model):
_inherit = 'agreement'
service_order_count = fields.Integer(
compute='_compute_service_order_count',
string='# Service Orders'
)
@api.multi
def _compute_service_order_count(self):
for agreement in self:
res = self.env['fsm.order'].search_count(
[('agreement_id', '=', agreement.id)])
agreement.service_order_count = res or 0
@api.multi
def action_view_service_order(self):
for agreement in self:
fsm_order_ids = self.env['fsm.order'].search(
[('agreement_id', '=', agreement.id)])
action = self.env.ref(
'fieldservice.action_fsm_operation_order').read()[0]
if len(fsm_order_ids) > 1:
action['domain'] = [('id', 'in', fsm_order_ids.ids)]
elif len(fsm_order_ids) == 1:
action['views'] = [(
self.env.ref('fieldservice.fsm_order_form').id,
'form')]
action['res_id'] = fsm_order_ids.ids[0]
else:
action = {'type': 'ir.actions.act_window_close'}
return action

12
agreement_fsm/models/fsm_order.py

@ -0,0 +1,12 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields
from odoo.addons.base_geoengine import geo_model
class FSMOrder(geo_model.GeoModel):
_inherit = 'fsm.order'
agreement_id = fields.Many2one('agreement', string='Agreement')

0
agreement_fsm/readme/CONFIGURE.rst

1
agreement_fsm/readme/CONTRIBUTORS.rst

@ -0,0 +1 @@
* Bhavesh Odedra <bodedra@opensourceintegrators.com>

3
agreement_fsm/readme/CREDITS.rst

@ -0,0 +1,3 @@
The development of this module has been financially supported by:
* Open Source Integrators

7
agreement_fsm/readme/DESCRIPTION.rst

@ -0,0 +1,7 @@
Odoo Agreement App does not provide an easy way to access field service orders
related to an agreement. Some organizations needs to have a quick access to
field service orders to track the performance of an agreement.
This module allows you to link a field service order to an agreement and adds a
smart button on the agreement to look at the list of related field service
orders.

0
agreement_fsm/readme/ROADMAP.rst

8
agreement_fsm/readme/USAGE.rst

@ -0,0 +1,8 @@
To use this module:
* Go to Field Service > Operations > Orders
* Select or create a field service order and set the agreement
* Go to Agreement > Agreements
* Open the previous agreement
* Click on the smart button "Service Orders" to see the list of related field
service orders

BIN
agreement_fsm/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

19
agreement_fsm/views/agreement_view.xml

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<odoo>
<!-- Copyright 2018 Open Source Integrators
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<!-- Agreement Form View -->
<record id="agreement_fsm_order_form_view" model="ir.ui.view">
<field name="name">agreement.form.fsm.order.view</field>
<field name="model">agreement</field>
<field name="inherit_id" ref="agreement.partner_agreement_form_view"/>
<field name="arch" type="xml">
<div class="oe_button_box" position="inside">
<button name="action_view_service_order" type="object" class="oe_stat_button" icon="fa-pencil-square-o" attrs="{'invisible': [('service_order_count', '=', 0)]}">
<field name="service_order_count" widget="statinfo" string="Service Orders"/>
</button>
</div>
</field>
</record>
</odoo>

17
agreement_fsm/views/fsm_order_view.xml

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<odoo>
<!-- Copyright 2018 Open Source Integrators
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<!-- Fields Service Orders Form View -->
<record id="fsm_order_agreement_form" model="ir.ui.view">
<field name="name">fsm.order.agreement.form</field>
<field name="model">fsm.order</field>
<field name="inherit_id" ref="fieldservice.fsm_order_form"/>
<field name="arch" type="xml">
<field name="fsm_location_id" position="after">
<field name="agreement_id"/>
</field>
</field>
</record>
</odoo>
Loading…
Cancel
Save