Skip to content

Commit

Permalink
[IMP] OCA#115 Worker Agreement Smart Button
Browse files Browse the repository at this point in the history
[UPD] README.rst
  • Loading branch information
osi-scampbell authored and szekawong committed Nov 6, 2023
1 parent 0880cea commit e066e17
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 2 deletions.
5 changes: 4 additions & 1 deletion fieldservice_agreement/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,13 @@ promote its widespread use.
.. |maintainer-smangukiya| image:: https:/smangukiya.png?size=40px
:target: https:/smangukiya
:alt: smangukiya
.. |maintainer-osi-scampbell| image:: https:/osi-scampbell.png?size=40px
:target: https:/osi-scampbell
:alt: osi-scampbell

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

|maintainer-max3903| |maintainer-bodedra| |maintainer-smangukiya|
|maintainer-max3903| |maintainer-bodedra| |maintainer-smangukiya| |maintainer-osi-scampbell|

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

Expand Down
2 changes: 2 additions & 0 deletions fieldservice_agreement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
'views/fsm_order_view.xml',
'views/fsm_equipment_view.xml',
'views/agreement_view.xml',
'views/fsm_person.xml'
],
'installable': True,
'development_status': 'Beta',
'maintainers': [
'max3903',
'bodedra',
'smangukiya',
'osi-scampbell'
],
}
1 change: 1 addition & 0 deletions fieldservice_agreement/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
agreement,
fsm_equipment,
fsm_order,
fsm_person
)
31 changes: 31 additions & 0 deletions fieldservice_agreement/models/fsm_person.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (C) 2019 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class FSMPerson(models.Model):
_inherit = 'fsm.person'

agreement_count = fields.Integer(string='Agreements',
compute='_compute_agreements')

def _compute_agreements(self):
self.agreement_count = self.env['agreement'].search_count([
('partner_id', '=', self.name)])

@api.multi
def action_view_agreements(self):
for person in self:
action = self.env.ref('agreement_legal.\
agreement_operations_agreement').read()[0]
agreements = self.env['agreement'].search(
[('partner_id', '=', person.partner_id.id)])
if len(agreements) == 1:
action['views'] = [
(self.env.ref('agreement_legal.\
partner_agreement_form_view').id, 'form')]
action['res_id'] = agreements.id
else:
action['domain'] = [('id', 'in', agreements.ids)]
return action
2 changes: 1 addition & 1 deletion fieldservice_agreement/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ <h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external" href="https:/max3903"><img alt="max3903" src="https:/max3903.png?size=40px" /></a> <a class="reference external" href="https:/bodedra"><img alt="bodedra" src="https:/bodedra.png?size=40px" /></a> <a class="reference external" href="https:/smangukiya"><img alt="smangukiya" src="https:/smangukiya.png?size=40px" /></a></p>
<p><a class="reference external" href="https:/max3903"><img alt="max3903" src="https:/max3903.png?size=40px" /></a> <a class="reference external" href="https:/bodedra"><img alt="bodedra" src="https:/bodedra.png?size=40px" /></a> <a class="reference external" href="https:/smangukiya"><img alt="smangukiya" src="https:/smangukiya.png?size=40px" /></a> <a class="reference external" href="https:/osi-scampbell"><img alt="osi-scampbell" src="https:/osi-scampbell.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https:/OCA/field-service/tree/12.0/fieldservice_agreement">OCA/field-service</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
Expand Down
22 changes: 22 additions & 0 deletions fieldservice_agreement/views/fsm_person.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="fsm_person_form" model="ir.ui.view">
<field name="name">fsm.person.form</field>
<field name="model">fsm.person</field>
<field name="inherit_id" ref="fieldservice.fsm_person_form"/>
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button type="object"
name="action_view_agreements"
class="oe_stat_button"
icon="fa-folder"
groups="base.group_user">
<field name="agreement_count" widget="statinfo"
string="Agreements"/>
</button>
</div>
</field>
</record>

</odoo>

0 comments on commit e066e17

Please sign in to comment.