Browse Source

[IMP] agreement_serviceprofile: add stage

- Add stage_type to agreement.stage
- Track stage of service profile
- Add Kanban view for service profiles to the dashboard
- Add product_id field to service profile
pull/368/head
brian10048 6 years ago
committed by OCA-git-bot
parent
commit
1238619887
  1. 9
      agreement_legal/data/agreement_stage.xml
  2. 3
      agreement_legal/models/agreement.py
  3. 5
      agreement_legal/models/agreement_stage.py
  4. 2
      agreement_legal/views/agreement.xml
  5. 2
      agreement_legal/views/agreement_stages.xml
  6. 1
      agreement_serviceprofile/__manifest__.py
  7. 41
      agreement_serviceprofile/data/serviceprofile_stage.xml
  8. 1
      agreement_serviceprofile/models/__init__.py
  9. 17
      agreement_serviceprofile/models/agreement_serviceprofile.py
  10. 12
      agreement_serviceprofile/models/agreement_stage.py
  11. 1
      agreement_serviceprofile/readme/CONTRIBUTORS.rst
  12. 46
      agreement_serviceprofile/views/agreement_serviceprofile.xml

9
agreement_legal/data/agreement_stage.xml

@ -4,46 +4,55 @@
<record id="agreement_stage_new" model="agreement.stage"> <record id="agreement_stage_new" model="agreement.stage">
<field name="name">New</field> <field name="name">New</field>
<field name="sequence">10</field> <field name="sequence">10</field>
<field name="stage_type">agreement</field>
</record> </record>
<record id="agreement_stage_draft" model="agreement.stage"> <record id="agreement_stage_draft" model="agreement.stage">
<field name="name">Draft</field> <field name="name">Draft</field>
<field name="sequence">20</field> <field name="sequence">20</field>
<field name="stage_type">agreement</field>
</record> </record>
<record id="agreement_stage_reviewed" model="agreement.stage"> <record id="agreement_stage_reviewed" model="agreement.stage">
<field name="name">Reviewed</field> <field name="name">Reviewed</field>
<field name="sequence">30</field> <field name="sequence">30</field>
<field name="stage_type">agreement</field>
</record> </record>
<record id="agreement_stage_negotiation" model="agreement.stage"> <record id="agreement_stage_negotiation" model="agreement.stage">
<field name="name">Negotiation</field> <field name="name">Negotiation</field>
<field name="sequence">40</field> <field name="sequence">40</field>
<field name="stage_type">agreement</field>
</record> </record>
<record id="agreement_stage_out" model="agreement.stage"> <record id="agreement_stage_out" model="agreement.stage">
<field name="name">Out for Customer Signature</field> <field name="name">Out for Customer Signature</field>
<field name="sequence">50</field> <field name="sequence">50</field>
<field name="stage_type">agreement</field>
</record> </record>
<record id="agreement_stage_internal" model="agreement.stage"> <record id="agreement_stage_internal" model="agreement.stage">
<field name="name">Waiting Internal Signature</field> <field name="name">Waiting Internal Signature</field>
<field name="sequence">60</field> <field name="sequence">60</field>
<field name="stage_type">agreement</field>
</record> </record>
<record id="agreement_stage_active" model="agreement.stage"> <record id="agreement_stage_active" model="agreement.stage">
<field name="name">Active</field> <field name="name">Active</field>
<field name="sequence">70</field> <field name="sequence">70</field>
<field name="stage_type">agreement</field>
</record> </record>
<record id="agreement_stage_expired" model="agreement.stage"> <record id="agreement_stage_expired" model="agreement.stage">
<field name="name">Expired</field> <field name="name">Expired</field>
<field name="sequence">80</field> <field name="sequence">80</field>
<field name="stage_type">agreement</field>
</record> </record>
<record id="agreement_stage_cancelled" model="agreement.stage"> <record id="agreement_stage_cancelled" model="agreement.stage">
<field name="name">Cancelled</field> <field name="name">Cancelled</field>
<field name="sequence">100</field> <field name="sequence">100</field>
<field name="fold">True</field> <field name="fold">True</field>
<field name="stage_type">agreement</field>
</record> </record>
</odoo> </odoo>

3
agreement_legal/models/agreement.py

@ -309,7 +309,8 @@ class Agreement(models.Model):
# Used for Kanban grouped_by view # Used for Kanban grouped_by view
@api.model @api.model
def _read_group_stage_ids(self, stages, domain, order): def _read_group_stage_ids(self, stages, domain, order):
stage_ids = self.env["agreement.stage"].search([])
stage_ids = self.env["agreement.stage"].search(
[('stage_type', '=', 'agreement')])
return stage_ids return stage_ids
stage_id = fields.Many2one( stage_id = fields.Many2one(

5
agreement_legal/models/agreement_stage.py

@ -24,5 +24,8 @@ class AgreementStage(models.Model):
fold = fields.Boolean( fold = fields.Boolean(
string="Is Folded", string="Is Folded",
required=False, required=False,
help="This stage is folded in the kanban view by deafault.",
help="This stage is folded in the kanban view by default.",
) )
stage_type = fields.Selection(
[('agreement', 'Agreement')],
string='Type', required=True)

2
agreement_legal/views/agreement.xml

@ -36,7 +36,7 @@
<header> <header>
<button string="New Version" type="object" name="create_new_version" class="oe_highlight" attrs="{'invisible': [('state', '=', 'active')]}"/> <button string="New Version" type="object" name="create_new_version" class="oe_highlight" attrs="{'invisible': [('state', '=', 'active')]}"/>
<button string="New Agreement" type="object" name="create_new_agreement" class="oe_highlight" attrs="{'invisible': [('is_template', '=', False)]}"/> <button string="New Agreement" type="object" name="create_new_agreement" class="oe_highlight" attrs="{'invisible': [('is_template', '=', False)]}"/>
<field name="stage_id" widget="statusbar" clickable="True" options="{'fold_field': 'fold'}"/>
<field name="stage_id" widget="statusbar" clickable="True" options="{'fold_field': 'fold'}" domain="[('stage_type', '=', 'agreement')]"/>
</header> </header>
<sheet> <sheet>
<div class="oe_button_box" name="button_box"> <div class="oe_button_box" name="button_box">

2
agreement_legal/views/agreement_stages.xml

@ -9,6 +9,7 @@
<tree default_order='sequence, name'> <tree default_order='sequence, name'>
<field name="sequence" widget="handle"/> <field name="sequence" widget="handle"/>
<field name="name" string="Stage Name"/> <field name="name" string="Stage Name"/>
<field name="stage_type"/>
</tree> </tree>
</field> </field>
</record> </record>
@ -26,6 +27,7 @@
</div> </div>
<group> <group>
<field name="sequence"/> <field name="sequence"/>
<field name="stage_type"/>
<field name="fold"/> <field name="fold"/>
</group> </group>
</sheet> </sheet>

1
agreement_serviceprofile/__manifest__.py

@ -13,6 +13,7 @@
'license': 'AGPL-3', 'license': 'AGPL-3',
'depends': ['agreement_legal'], 'depends': ['agreement_legal'],
'data': [ 'data': [
'data/serviceprofile_stage.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'views/agreement_serviceprofile.xml', 'views/agreement_serviceprofile.xml',
'views/agreement.xml' 'views/agreement.xml'

41
agreement_serviceprofile/data/serviceprofile_stage.xml

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<record id="servpro_stage_draft" model="agreement.stage">
<field name="name">Draft</field>
<field name="sequence">10</field>
<field name="stage_type">serviceprofile</field>
</record>
<record id="servpro_stage_progress" model="agreement.stage">
<field name="name">In Progress</field>
<field name="sequence">20</field>
<field name="stage_type">serviceprofile</field>
</record>
<record id="servpro_stage_suspend" model="agreement.stage">
<field name="name">Suspended</field>
<field name="sequence">30</field>
<field name="stage_type">serviceprofile</field>
</record>
<record id="servpro_stage_renew" model="agreement.stage">
<field name="name">To Renew</field>
<field name="sequence">40</field>
<field name="stage_type">serviceprofile</field>
</record>
<record id="servpro_stage_close" model="agreement.stage">
<field name="name">Closed</field>
<field name="sequence">50</field>
<field name="stage_type">serviceprofile</field>
</record>
<record id="servpro_stage_cancel" model="agreement.stage">
<field name="name">Cancelled</field>
<field name="sequence">60</field>
<field name="fold">True</field>
<field name="stage_type">serviceprofile</field>
</record>
</odoo>

1
agreement_serviceprofile/models/__init__.py

@ -1,2 +1,3 @@
from . import agreement_serviceprofile from . import agreement_serviceprofile
from . import agreement from . import agreement
from . import agreement_stage

17
agreement_serviceprofile/models/agreement_serviceprofile.py

@ -2,14 +2,20 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
from odoo import fields, models, api
class AgreementServiceProfile(models.Model): class AgreementServiceProfile(models.Model):
_name = 'agreement.serviceprofile' _name = 'agreement.serviceprofile'
_description = 'Agreement Service Profiles' _description = 'Agreement Service Profiles'
def _default_stage_id(self):
return self.env.ref('agreement_serviceprofile.servpro_stage_draft')
name = fields.Char(string="Name", required=True) name = fields.Char(string="Name", required=True)
stage_id = fields.Many2one('agreement.stage', string="Stage",
default=_default_stage_id, copy=False,
group_expand='_read_group_stage_ids',)
agreement_id = fields.Many2one('agreement', string="Agreement", agreement_id = fields.Many2one('agreement', string="Agreement",
ondelete="cascade") ondelete="cascade")
active = fields.Boolean(string="Active", active = fields.Boolean(string="Active",
@ -19,3 +25,12 @@ class AgreementServiceProfile(models.Model):
" without removing it.") " without removing it.")
notes = fields.Text(string="Notes") notes = fields.Text(string="Notes")
product_id = fields.Many2one('product.template', 'Service',
domain="[('type', '=', 'service')]")
# Used for Kanban grouped_by view
@api.model
def _read_group_stage_ids(self, stages, domain, order):
stage_ids = self.env["agreement.stage"].search(
[('stage_type', '=', 'serviceprofile')])
return stage_ids

12
agreement_serviceprofile/models/agreement_stage.py

@ -0,0 +1,12 @@
# Copyright (C) 2019 - TODAY, Brian McMaster
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class AgreementStage(models.Model):
_inherit = 'agreement.stage'
stage_type = fields.Selection(
selection_add=[('serviceprofile', 'Service Profile')]
)

1
agreement_serviceprofile/readme/CONTRIBUTORS.rst

@ -4,3 +4,4 @@
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com> * Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
* Sandip Mangukiya <smangukiya@opensourceintegrators.com> * Sandip Mangukiya <smangukiya@opensourceintegrators.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com> * Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
* Brian McMaster <brian@mcmpest.com>

46
agreement_serviceprofile/views/agreement_serviceprofile.xml

@ -9,6 +9,7 @@
<tree string="Service Profiles" default_order='agreement_id'> <tree string="Service Profiles" default_order='agreement_id'>
<field name="name"/> <field name="name"/>
<field name="agreement_id"/> <field name="agreement_id"/>
<field name="product_id"/>
<field name="active" invisible="1"/> <field name="active" invisible="1"/>
</tree> </tree>
</field> </field>
@ -20,6 +21,12 @@
<field name="model">agreement.serviceprofile</field> <field name="model">agreement.serviceprofile</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Service Profile"> <form string="Service Profile">
<header>
<field name="stage_id" widget="statusbar"
clickable="True"
options="{'fold_field': 'fold'}"
domain="[('stage_type', '=', 'serviceprofile')]"/>
</header>
<sheet> <sheet>
<div class="oe_button_box" name="button_box"> <div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" <button name="toggle_active" type="object"
@ -38,7 +45,9 @@
<group> <group>
<field name="agreement_id"/> <field name="agreement_id"/>
</group> </group>
<group></group>
<group>
<field name="product_id"/>
</group>
</group> </group>
<group string="Notes"> <group string="Notes">
<field name="notes" nolabel="1" widget="html"/> <field name="notes" nolabel="1" widget="html"/>
@ -48,6 +57,28 @@
</field> </field>
</record> </record>
<!-- Agreement Service Profile Kanban View -->
<record id="agreement_serviceprofile_kanban" model="ir.ui.view">
<field name="name">Agreement Service Profile Kanban</field>
<field name="model">agreement.serviceprofile</field>
<field name="arch" type="xml">
<kanban default_group_by="stage_id">
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_content">
<div>
<strong class="o_kanban_record_title">
<field name="name"/>
</strong>
</div>
<div class="oe_clear"/>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<!-- Agreement Service Profile Search View --> <!-- Agreement Service Profile Search View -->
<record id="agreement_serviceprofile_search" model="ir.ui.view"> <record id="agreement_serviceprofile_search" model="ir.ui.view">
<field name="name">Agreement Service Profile Search</field> <field name="name">Agreement Service Profile Search</field>
@ -68,6 +99,12 @@
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
</record> </record>
<record id="agreement_serviceprofile_dashboard" model="ir.actions.act_window">
<field name="name">Service Profiles</field>
<field name="res_model">agreement.serviceprofile</field>
<field name="view_mode">kanban,tree,form</field>
</record>
<menuitem <menuitem
name="Service Profiles" name="Service Profiles"
id="agreement_serviceprofiles" id="agreement_serviceprofiles"
@ -75,4 +112,11 @@
sequence="50" sequence="50"
action="agreement_serviceprofile_action"/> action="agreement_serviceprofile_action"/>
<menuitem
name="Service Profiles"
id="dashboard_serviceprofiles"
parent="agreement_legal.agreement_dashboard"
sequence="20"
action="agreement_serviceprofile_dashboard"/>
</odoo> </odoo>
Loading…
Cancel
Save