-
-
Notifications
You must be signed in to change notification settings - Fork 70
[16.0][ADD] hr_personal_equipment_request_sign_oca: Show S/N in PPE Request Report #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 16.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| ====================================== | ||
| Hr Personal Equipment Request Sign Oca | ||
| ====================================== | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:adb18013225c7e07e55f00281a5bf96055ba36b61a11354a582bab7a55a62cd1 | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |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/hr_personal_equipment_request_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-hr_personal_equipment_request_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 generate manual and automatic signature | ||
| requests from Personal Equipment Request to For employees who request | ||
| it. A new PPE sign report has been created in order to manage dynamic | ||
| Personal Equipments' table. | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Configuration | ||
| ============= | ||
|
|
||
| 1. Go to Sign > Settings > Roles and create a role with the following | ||
| data: | ||
|
|
||
| - Partner type: Expression | ||
| - Expression: {{object.employee_id.user_id.partner_id.id}} | ||
|
|
||
| 2. Go to Sign > Templates and create a template with the following data: | ||
|
|
||
| - Model: "This model allows to create a personal equipment request" | ||
| - In one of the fields, you must set the previously created role. | ||
|
|
||
| 3. (Optional) Go to Employees > Configuration > Settings. | ||
|
|
||
| - In the Personal Equipment Request Sign section, define a template to | ||
| enable automatic task sign requests. | ||
| - Use the template previously created. | ||
|
|
||
| Usage | ||
| ===== | ||
|
|
||
| Creating a Signature Request from a Personal Equipment Request: | ||
|
|
||
| - Go to Employees > Personal Equipment > Personal Equipment Request. | ||
| - Create a new Personal Equipment Request. | ||
| - In the list or form view, click on the action "Sign from template". | ||
| - Sign Requests will have been generated (and sent) linked to the | ||
| selected Personal Equipment Request. | ||
|
|
||
| Automatic Signature Request creation: | ||
|
|
||
| - Define a template in Employees > Configuration > Settings. | ||
| - When a Personal Equipment Request is created, or employee in an | ||
| existing one changes, a Sign Request will be created (and sent) | ||
| automatically. | ||
|
|
||
| Viewing Signature Requests: | ||
|
|
||
| - Go to Employees > Personal Equipment > Personal Equipment Request. | ||
| - Open a personal equipment request with an associated signature | ||
| request. | ||
| - Click on the smart-button Sign Requests. | ||
| - Click on any signature request to view its details, status, and | ||
| progress. | ||
| - Alternatively, go to Sign > Requests. | ||
| - Use the Group By feature to group requests by Employess. | ||
|
|
||
| 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:%20hr_personal_equipment_request_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 | ||
| ------- | ||
|
|
||
| * PyTech SRL | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| - `PyTech SRL <https://pytech.it>`__: | ||
|
|
||
| - Quirino Leone <quirino.leone@pytech.it> | ||
|
|
||
| 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. | ||
|
|
||
| This module is part of the `OCA/sign <https://github.com/OCA/sign/tree/16.0/hr_personal_equipment_request_sign_oca>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "name": "Hr Personal Equipment Request Sign Oca", | ||
| "summary": """Hr Personal Equipment Request Sign Oca""", | ||
| "version": "16.0.1.0.0", | ||
| "license": "AGPL-3", | ||
| "author": "PyTech SRL, Odoo Community Association (OCA)", | ||
| "website": "https://github.com/OCA/sign", | ||
| "depends": [ | ||
| "sign_oca", | ||
| "hr_personal_equipment_request", | ||
| "hr_employee_ppe", | ||
| "hr_personal_equipment_stock", | ||
| ], | ||
| "data": [ | ||
| "data/sign_oca_role.xml", | ||
| "data/sign_oca_template.xml", | ||
| "reports/ppe_sign_report.xml", | ||
| "reports/ppe_sign_report_template.xml", | ||
| "views/hr_personal_equipment_request.xml", | ||
| "views/res_config_settings.xml", | ||
| "views/sign_oca_request.xml", | ||
| ], | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <odoo noupdate="1"> | ||
| <record id="role_personal_equipment_request_owner" model="sign.oca.role"> | ||
| <field name="name">Personal Equipment Request owner</field> | ||
| <field name="partner_selection_policy">expression</field> | ||
| <field | ||
| name="expression_partner" | ||
| >{{object.employee_id.user_id.partner_id.id}}</field> | ||
| </record> | ||
| </odoo> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <odoo noupdate="1"> | ||
| <record | ||
| id="sign_oca_template_personal_equipment_request_demo" | ||
| model="sign.oca.template" | ||
| > | ||
| <field name="name">Personal Equipment Request</field> | ||
| <field | ||
| name="model_id" | ||
| ref="hr_personal_equipment_request.model_hr_personal_equipment_request" | ||
| /> | ||
| <field name="data" type="base64" file="sign_oca/tests/empty.pdf" /> | ||
| </record> | ||
| <record | ||
| id="sign_oca_template_personal_equipment_request_demo_item" | ||
| model="sign.oca.template.item" | ||
| > | ||
| <field | ||
| name="template_id" | ||
| ref="hr_personal_equipment_request_sign_oca.sign_oca_template_personal_equipment_request_demo" | ||
| /> | ||
| <field name="field_id" ref="sign_oca.sign_field_signature" /> | ||
| <field | ||
| name="role_id" | ||
| ref="hr_personal_equipment_request_sign_oca.role_personal_equipment_request_owner" | ||
| /> | ||
| <field name="page">1</field> | ||
| <field name="position_x">10</field> | ||
| <field name="position_y">10</field> | ||
| <field name="width">30</field> | ||
| <field name="height">4</field> | ||
| <field name="required" eval="True" /> | ||
| </record> | ||
| </odoo> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from . import hr_personal_equipment_request | ||
| from . import res_company | ||
| from . import res_config_settings | ||
| from . import sign_oca_request | ||
| from . import stock_picking |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import base64 | ||
|
|
||
| from odoo import api, fields, models | ||
|
|
||
|
|
||
| class HrPersonalEquipmentRequest(models.Model): | ||
| _inherit = "hr.personal.equipment.request" | ||
|
|
||
| sign_request_ids = fields.One2many( | ||
| comodel_name="sign.oca.request", | ||
| inverse_name="personal_equipment_request_id", | ||
| string="Sign Requests", | ||
| ) | ||
| sign_request_count = fields.Integer( | ||
| string="Sign request count", | ||
| compute="_compute_sign_request_count", | ||
| store=True, | ||
| ) | ||
|
|
||
| @api.depends("sign_request_ids") | ||
| def _compute_sign_request_count(self): | ||
| for item in self: | ||
| item.sign_request_count = len(item.sign_request_ids) | ||
|
|
||
| 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)] | ||
| return result | ||
|
|
||
| def _get_pdf_report(self): | ||
| report = self.env["ir.actions.report"]._get_report_from_name( | ||
| "hr_personal_equipment_request_sign_oca.ppe_sign_report_template" | ||
| ) | ||
| pdf = report._render_qweb_pdf(report.report_name, [self.id])[0] | ||
| return base64.b64encode(pdf) | ||
|
|
||
| def _generate_sign_oca_request(self): | ||
| sign_request_obj = self.env["sign.oca.request"].sudo() | ||
| for item in self: | ||
| sign_template = ( | ||
| item.employee_id.company_id.personal_equipment_request_sign_oca_template_id | ||
| ) | ||
| if sign_template: | ||
| sign_template = sign_template.sudo() | ||
| request_dict = sign_template._prepare_sign_oca_request_vals_from_record( | ||
| item | ||
| ) | ||
| request_dict.update({"data": self._get_pdf_report()}) | ||
| request = sign_request_obj.create(request_dict) | ||
| request.action_send() | ||
|
|
||
| def check_sign_oca_request(self): | ||
| if all(line.state in ["valid", "cancelled"] for line in self.line_ids) and any( | ||
| line.state == "valid" for line in self.line_ids | ||
| ): | ||
| self._generate_sign_oca_request() | ||
|
|
||
| def write(self, vals): | ||
| if "employee_id" in vals: | ||
| old_employees = {rec.id: rec.employee_id for rec in self} | ||
| res = super().write(vals) | ||
| if "employee_id" in vals: | ||
| for rec in self: | ||
| if rec.employee_id and rec.employee_id != old_employees.get(rec.id): | ||
| rec._generate_sign_oca_request() | ||
| return res | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class ResCompany(models.Model): | ||
| _inherit = "res.company" | ||
|
|
||
| personal_equipment_request_sign_oca_template_id = fields.Many2one( | ||
| comodel_name="sign.oca.template", | ||
| domain="[('model_id.model', '=', 'hr.personal.equipment.request')]", | ||
| string="Personal Equipment Request Sign Oca Template", | ||
| ) | ||
|
|
||
| ppe_report_show_sn = fields.Boolean(string="S/N in PPE Request Report") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class ResConfigSettings(models.TransientModel): | ||
| _inherit = "res.config.settings" | ||
|
|
||
| personal_equipment_request_sign_oca_template_id = fields.Many2one( | ||
| comodel_name="sign.oca.template", | ||
| related="company_id.personal_equipment_request_sign_oca_template_id", | ||
| readonly=False, | ||
| ) | ||
|
|
||
| ppe_report_show_sn = fields.Boolean( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Please add some documentation for the new behavior, for example: this new flag might be added in the |
||
| related="company_id.ppe_report_show_sn", | ||
| readonly=False, | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| from odoo import api, fields, models | ||
|
|
||
|
|
||
| class SignOcaRequest(models.Model): | ||
| _inherit = "sign.oca.request" | ||
|
|
||
| personal_equipment_request_id = fields.Many2one( | ||
| comodel_name="hr.personal.equipment.request", | ||
| string="Personal Equipment Request", | ||
| compute="_compute_personal_equipment_request_id", | ||
| store=True, | ||
| ) | ||
|
|
||
| ppe_employee_id = fields.Many2one( | ||
| comodel_name="hr.employee", | ||
| related="personal_equipment_request_id.employee_id", | ||
| store=True, | ||
| ) | ||
|
|
||
| @api.depends("record_ref") | ||
| def _compute_personal_equipment_request_id(self): | ||
| for item in self: | ||
| if ( | ||
| item.record_ref | ||
| and item.record_ref._name == "hr.personal.equipment.request" | ||
| ): | ||
| item.personal_equipment_request_id = item.record_ref.id | ||
| else: | ||
| item.personal_equipment_request_id = False |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| from odoo import models | ||
|
|
||
|
|
||
| class StockPicking(models.Model): | ||
|
|
||
| _inherit = "stock.picking" | ||
|
|
||
| def _action_done(self): | ||
| is_return = any(x.origin_returned_move_id for x in self.move_ids) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: |
||
| res = super()._action_done() | ||
| if self.equipment_request_id and not is_return: | ||
| self.equipment_request_id.check_sign_oca_request() | ||
|
|
||
| return res | ||
|
|
||
| def action_cancel(self): | ||
| is_return = any(x.origin_returned_move_id for x in self.move_ids) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: |
||
| res = super().action_cancel() | ||
| if self.equipment_request_id and not is_return: | ||
| self.equipment_request_id.check_sign_oca_request() | ||
|
Comment on lines
+16
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Why should we generate a sign request when a picking is cancelled? |
||
|
|
||
| return res | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| 1. Go to Sign > Settings > Roles and create a role with the following data: | ||
|
|
||
| - Partner type: Expression | ||
| - Expression: {{object.employee_id.user_id.partner_id.id}} | ||
|
|
||
| 2. Go to Sign > Templates and create a template with the following data: | ||
|
|
||
| - Model: "This model allows to create a personal equipment request" | ||
| - In one of the fields, you must set the previously created role. | ||
|
|
||
| 3. (Optional) Go to Employees > Configuration > Settings. | ||
|
|
||
| - In the Personal Equipment Request Sign section, define a template to enable automatic task sign requests. | ||
| - Use the template previously created. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - [PyTech SRL](https://pytech.it): | ||
| - Quirino Leone \<<quirino.leone@pytech.it>\> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| This module allows you to generate manual and automatic signature requests from Personal Equipment Request to For employees who request it. | ||
| A new PPE sign report has been created in order to manage dynamic Personal Equipments' table. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: The PDF report should be generated from the single PPE request in the loop.