-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
27 changed files
with
1,112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
==================== | ||
Maintenance Sign Oca | ||
==================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:f4baa62966fafd97bc24efb114692ffd215a02d0e64616ebd10e542294d9d5b7 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fsign-lightgray.png?logo=github | ||
:target: https://github.com/OCA/sign/tree/16.0/maintenance_sign_oca | ||
:alt: OCA/sign | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/sign-16-0/sign-16-0-maintenance_sign_oca | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/sign&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows you to make equipment signature requests manually or | ||
automatically. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
1. Go to Sign > Settings > Roles and create a new one with the following | ||
data: | ||
|
||
- Partner type: Expression | ||
- Expression: ${object.owner_user_id.partner_id.id} | ||
|
||
1. Go to Sign > Templates and create a template with the following data: | ||
|
||
- Model: Maintenance Equipment | ||
- In some of the elements you will have to set the previously created | ||
role. | ||
|
||
1. Go to Maintenance > Configuration > General settings. | ||
2. Defines the template previously created (optional, only for automatic | ||
creation of signature requests). | ||
|
||
Usage | ||
===== | ||
|
||
A smart-button will be displayed on the equipments form view of the | ||
linked Sign Requests. | ||
|
||
Manual Sign Request creation process: - Go to Maintenance > Equipments | ||
and change to list view. - Select the records that you want. - Click on | ||
the "Sign from template" action. - Select a template. - Click on | ||
Generate. - Sign Requests will have been generated (and sent) for the | ||
selected items. | ||
|
||
Automatic Sign Request creation process: - When an owner is assigned to | ||
a equipment, a Sign Request will be created automatically. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sign/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/sign/issues/new?body=module:%20maintenance_sign_oca%0Aversion:%2016.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 | ||
------- | ||
|
||
* Tecnativa | ||
|
||
Contributors | ||
------------ | ||
|
||
- `Tecnativa <https://www.tecnativa.com>`__ | ||
|
||
- Pedro M. Baeza | ||
- Víctor Martínez | ||
|
||
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-victoralmau| image:: https://github.com/victoralmau.png?size=40px | ||
:target: https://github.com/victoralmau | ||
:alt: victoralmau | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-victoralmau| | ||
|
||
This module is part of the `OCA/sign <https://github.com/OCA/sign/tree/16.0/maintenance_sign_oca>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2023 Tecnativa - Víctor Martínez | ||
# Copyright 2023 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Maintenance Sign Oca", | ||
"version": "16.0.1.0.0", | ||
"category": "Maintenance", | ||
"website": "https://github.com/OCA/sign", | ||
"author": "Tecnativa, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"depends": ["sign_oca", "base_maintenance_config"], | ||
"data": [ | ||
"views/maintenance_equipment_views.xml", | ||
"views/res_config_settings_view.xml", | ||
"views/sign_oca_request_views.xml", | ||
], | ||
"demo": [ | ||
"demo/sign_oca_role.xml", | ||
"demo/sign_oca_template.xml", | ||
], | ||
"installable": True, | ||
"maintainers": ["victoralmau"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<odoo> | ||
<record id="role_maintenance_equipment_owner" model="sign.oca.role"> | ||
<field name="name">Equipment owner</field> | ||
<field name="partner_selection_policy">expression</field> | ||
<field name="expression_partner">{{object.owner_user_id.partner_id.id}}</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<odoo> | ||
<record id="sign_oca_template_maintenance_equipment_demo" model="sign.oca.template"> | ||
<field name="name">Maintenance Equipment</field> | ||
<field name="model_id" ref="maintenance.model_maintenance_equipment" /> | ||
<field name="data" type="base64" file="sign_oca/tests/empty.pdf" /> | ||
</record> | ||
<record | ||
id="sign_oca_template_maintenance_equipment_demo_item_0" | ||
model="sign.oca.template.item" | ||
> | ||
<field | ||
name="template_id" | ||
ref="maintenance_sign_oca.sign_oca_template_maintenance_equipment_demo" | ||
/> | ||
<field name="field_id" ref="sign_oca.sign_field_name" /> | ||
<field | ||
name="role_id" | ||
ref="maintenance_sign_oca.role_maintenance_equipment_owner" | ||
/> | ||
<field name="page">1</field> | ||
<field name="position_x">10</field> | ||
<field name="position_y">10</field> | ||
<field name="width">10</field> | ||
<field name="height">10</field> | ||
<field name="required" eval="True" /> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * maintenance_sign_oca | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-03-06 09:56+0000\n" | ||
"PO-Revision-Date: 2024-05-22 16:38+0000\n" | ||
"Last-Translator: Víctor Martínez <[email protected]>\n" | ||
"Language-Team: \n" | ||
"Language: es\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=n != 1;\n" | ||
"X-Generator: Weblate 4.17\n" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model:ir.model,name:maintenance_sign_oca.model_res_company | ||
msgid "Companies" | ||
msgstr "Compañías" | ||
#. module: maintenance_sign_oca | ||
#: model:ir.model,name:maintenance_sign_oca.model_maintenance_equipment | ||
#: model:ir.model.fields,field_description:maintenance_sign_oca.field_sign_oca_request__maintenance_equipment_id | ||
msgid "Maintenance Equipment" | ||
msgstr "Equipo de mantenimiento" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model:ir.model.fields,field_description:maintenance_sign_oca.field_res_company__maintenance_equipment_sign_oca_template_id | ||
#: model:ir.model.fields,field_description:maintenance_sign_oca.field_res_config_settings__maintenance_equipment_sign_oca_template_id | ||
msgid "Sign Oca Template" | ||
msgstr "Plantilla de firma" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model:ir.model,name:maintenance_sign_oca.model_sign_oca_request | ||
msgid "Sign Request" | ||
msgstr "Solicitud de firma" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model:ir.model.fields,field_description:maintenance_sign_oca.field_maintenance_equipment__sign_request_ids | ||
msgid "Sign Requests" | ||
msgstr "Solicitudes de firma" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model:ir.model.fields,field_description:maintenance_sign_oca.field_maintenance_equipment__sign_request_count | ||
msgid "Sign request count" | ||
msgstr "Total solicitudes de firma" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model_terms:ir.ui.view,arch_db:maintenance_sign_oca.res_config_settings_view_form | ||
msgid "Template" | ||
msgstr "Plantilla" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * maintenance_sign_oca | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 15.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model:ir.model,name:maintenance_sign_oca.model_res_company | ||
msgid "Companies" | ||
msgstr "" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model:ir.model,name:maintenance_sign_oca.model_res_config_settings | ||
msgid "Config Settings" | ||
msgstr "" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model_terms:ir.ui.view,arch_db:maintenance_sign_oca.sign_oca_request_search_view | ||
msgid "Equipment" | ||
msgstr "" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model:ir.model,name:maintenance_sign_oca.model_maintenance_equipment | ||
#: model:ir.model.fields,field_description:maintenance_sign_oca.field_sign_oca_request__maintenance_equipment_id | ||
msgid "Maintenance Equipment" | ||
msgstr "" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model:ir.model.fields,field_description:maintenance_sign_oca.field_res_company__maintenance_equipment_sign_oca_template_id | ||
#: model:ir.model.fields,field_description:maintenance_sign_oca.field_res_config_settings__maintenance_equipment_sign_oca_template_id | ||
msgid "Sign Oca Template" | ||
msgstr "" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model:ir.model,name:maintenance_sign_oca.model_sign_oca_request | ||
msgid "Sign Request" | ||
msgstr "" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model:ir.model.fields,field_description:maintenance_sign_oca.field_maintenance_equipment__sign_request_ids | ||
msgid "Sign Requests" | ||
msgstr "" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model:ir.model.fields,field_description:maintenance_sign_oca.field_maintenance_equipment__sign_request_count | ||
msgid "Sign request count" | ||
msgstr "" | ||
|
||
#. module: maintenance_sign_oca | ||
#: model_terms:ir.ui.view,arch_db:maintenance_sign_oca.res_config_settings_view_form | ||
msgid "Template" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from . import maintenance_equipment | ||
from . import res_company | ||
from . import res_config_settings | ||
from . import sign_oca_request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Copyright 2023-2024 Tecnativa - Víctor Martínez | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
from odoo import api, fields, models | ||
|
||
|
||
class MaintenanceEquipment(models.Model): | ||
_inherit = "maintenance.equipment" | ||
|
||
# This field is stored as a help to filter by. | ||
sign_request_ids = fields.One2many( | ||
comodel_name="sign.oca.request", | ||
inverse_name="maintenance_equipment_id", | ||
string="Sign Requests", | ||
) | ||
sign_request_count = fields.Integer( | ||
string="Sign request count", | ||
compute="_compute_sign_request_count", | ||
compute_sudo=True, | ||
store=True, | ||
) | ||
|
||
@api.depends("sign_request_ids") | ||
def _compute_sign_request_count(self): | ||
request_data = self.env["sign.oca.request"].read_group( | ||
[("maintenance_equipment_id", "in", self.ids)], | ||
["maintenance_equipment_id"], | ||
["maintenance_equipment_id"], | ||
) | ||
mapped_data = { | ||
x["maintenance_equipment_id"][0]: x["maintenance_equipment_id_count"] | ||
for x in request_data | ||
} | ||
for item in self: | ||
item.sign_request_count = mapped_data.get(item.id, 0) | ||
|
||
def action_view_sign_requests(self): | ||
self.ensure_one() | ||
result = self.env["ir.actions.act_window"]._for_xml_id( | ||
"sign_oca.sign_oca_request_act_window" | ||
) | ||
result["domain"] = [("id", "in", self.sign_request_ids.ids)] | ||
ctx = dict(self.env.context) | ||
ctx.update( | ||
{ | ||
"default_maintenance_equipment_id": self.id, | ||
"search_default_maintenance_equipment_id": self.id, | ||
} | ||
) | ||
result["context"] = ctx | ||
return result | ||
|
||
def _process_generate_sign_oca_request(self, data): | ||
"""Generate request from template if owner has changed.""" | ||
request_model = self.env["sign.oca.request"].sudo() | ||
for item in self.filtered("owner_user_id"): | ||
sign_template = item.company_id.maintenance_equipment_sign_oca_template_id | ||
old_owner_user_id = data[item.id] if item.id in data else False | ||
if sign_template and item.owner_user_id != old_owner_user_id: | ||
# Apply sudo because the user who creates the record may not have | ||
# permissions on sign.oca.template | ||
sign_template = sign_template.sudo() | ||
request_model.create( | ||
sign_template._prepare_sign_oca_request_vals_from_record(item) | ||
) | ||
|
||
@api.model_create_multi | ||
def create(self, vals_list): | ||
res = super().create(vals_list) | ||
if any(item.owner_user_id for item in res): | ||
res._process_generate_sign_oca_request({}) | ||
return res | ||
|
||
def write(self, vals): | ||
owners = {} | ||
for item in self: | ||
owners[item.id] = item.owner_user_id | ||
res = super().write(vals) | ||
# Fields to be taken into account when trying to create a sign request. | ||
# We don't need to take into account only the owner_user_id field because | ||
# if you have installed hr_maintenance module is a compute field and the | ||
# employee_id field will be taken into account. | ||
if any(vals.get(fname) for fname in ["owner_user_id", "employee_id"]): | ||
self._process_generate_sign_oca_request(owners) | ||
return res |
Oops, something went wrong.