Skip to content

[16.0][ADD] hr_personal_equipment_request_sign_oca: Show S/N in PPE Request Report#137

Open
quirino95 wants to merge 2 commits into
OCA:16.0from
PyTech-SRL:16.0-sn_in_personal_equipment_request_report
Open

[16.0][ADD] hr_personal_equipment_request_sign_oca: Show S/N in PPE Request Report#137
quirino95 wants to merge 2 commits into
OCA:16.0from
PyTech-SRL:16.0-sn_in_personal_equipment_request_report

Conversation

@quirino95
Copy link
Copy Markdown

Depends on #127

Added possibility to show Serial Numbers in PPEs request report file. A related setting is present (default is False).
This also means that Sign request cannot be created on Personal Equipment Request Acceptance, but now it's done only when related pickings are completed.
Furthermore, now in report only "Valid" lines are visible, since showing cancelled lines doesn't make sense.

@quirino95 quirino95 changed the title 16.0 sn in personal equipment request report [16.0][ADD] hr_personal_equipment_request_sign_oca: Show S/N in PPE Request Report Oct 16, 2025
Copy link
Copy Markdown

@HekkiMelody HekkiMelody left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review, just a minor comment, otherwise LGTM

Comment on lines +24 to +30
@api.model
def _default_show_sn_report(self):
return bool(
self.env["ir.config_parameter"]
.sudo()
.get_param("hr_personal_equipment_request_sign_oca.show_sn_report", False)
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: instead of doing this configuration for the entire installation, we could do this per company. What do you think?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, updated settings.

Comment on lines 8 to 11
# flake8: noqa: B950
cls.template = cls.env.ref(
"hr_personal_equipment_request_sign_oca.sign_oca_template_personal_equipment_request_demo"
)
Copy link
Copy Markdown

@HekkiMelody HekkiMelody Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): you can avoid disabling flake with the comment by splitting the string on two lines

cls.template = cls.env.ref(
            "hr_personal_equipment_request_sign_oca."
            "sign_oca_template_personal_equipment_request_demo"
        )

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful, thank you!

@quirino95 quirino95 force-pushed the 16.0-sn_in_personal_equipment_request_report branch from c869182 to fc41970 Compare October 21, 2025 12:05
readonly=False,
)

show_sn_report = fields.Boolean(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore: sorry to nitpick, but settings and company have A LOT of fields from every possible module, so it's good practice to "namespace" the fields by using appropriately specific names. The likelihood of another entirely unrelated module adding a field with this name in the setting is relatively high.

Maybe ppe_report_show_sn?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry, you're absolutely right. Yes, ppe_report_show_sn is good for me too, so I've updated code.

@quirino95 quirino95 force-pushed the 16.0-sn_in_personal_equipment_request_report branch from fc41970 to 846b073 Compare October 21, 2025 13:01
Copy link
Copy Markdown

@HekkiMelody HekkiMelody left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review, LGTM

@github-actions
Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions Bot added the stale label Feb 22, 2026
@HekkiMelody
Copy link
Copy Markdown

@OCA/human-resources-maintainers Hello, we've been using this in prod for months. Could you take a look? We can forward port after the merge. Thanks!

@github-actions github-actions Bot removed the stale label Mar 1, 2026
@anusriNPS anusriNPS force-pushed the 16.0-sn_in_personal_equipment_request_report branch from 846b073 to 3fb2f82 Compare May 11, 2026 13:43
@OCA-git-bot OCA-git-bot added mod:hr_personal_equipment_request_sign_oca Module hr_personal_equipment_request_sign_oca series:16.0 labels May 11, 2026
@anusriNPS anusriNPS force-pushed the 16.0-sn_in_personal_equipment_request_report branch from 3fb2f82 to 40ded60 Compare May 11, 2026 13:46
@anusriNPS
Copy link
Copy Markdown

Depends on #156 which resolves precommit issue seen

Copy link
Copy Markdown

@SirPyTech SirPyTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!
I only reviewed the code and looks like adding the serials' management is editing the original code/flow of the module, please see the comments below.

Comment on lines +8 to +13
"depends": ["sign_oca", "hr_personal_equipment_request", "hr_employee_ppe"],
"depends": [
"sign_oca",
"hr_personal_equipment_request",
"hr_employee_ppe",
"hr_personal_equipment_stock",
],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: If/when #127 is merged, I would avoid adding a new dependency on a merged module because it might break existing installations that do not have the new dependency available.
Please consider adding a bridge module or including this dependency from the beginning, since #127 isn't merged yet.

)
pdf = report._render_qweb_pdf(report.report_name, [self.id])[0]
request_dict.update({"data": base64.b64encode(pdf)})
request_dict.update({"data": self._get_pdf_report()})
Copy link
Copy Markdown

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.

Suggested change
request_dict.update({"data": self._get_pdf_report()})
request_dict.update({"data": item._get_pdf_report()})

Comment on lines +52 to +59
@api.model_create_multi
def create(self, vals_list):
res = super().create(vals_list)
res._generate_sign_oca_request()
return res
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()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: If we aren't managing serial numbers, this sign request should still be generated upon record creation: instead of removing the create override, please add a check on ppe_report_show_sn if the flow should be different.

If we really want to modify the original flow, this change should go in the commit where such flow is added.

_inherit = "stock.picking"

def _action_done(self):
is_return = any(x.origin_returned_move_id for x in self.move_ids)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: _action_done can be called on multiple pickings: some of them can be returns and others maybe are not.
The problem is that is_return is True if at least one of them is a return: please identify which picking is a return and which isn't instead.

return res

def action_cancel(self):
is_return = any(x.origin_returned_move_id for x in self.move_ids)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: action_cancel can be called on multiple pickings: some of them can be return and others maybe are not.
The problem is that is_return is True if at least one of them is a return: please identify which picking is a return and which isn't instead.

Comment on lines +16 to +20
def action_cancel(self):
is_return = any(x.origin_returned_move_id for x in self.move_ids)
res = super().action_cancel()
if self.equipment_request_id and not is_return:
self.equipment_request_id.check_sign_oca_request()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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?

Comment on lines +54 to +59
t-if="line.is_ppe"
t-if="line.is_ppe and line.state == 'valid'"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Why is this needed only when serial numbers are added? Maybe this goes in the 1st commit?

{"name": "Employee Test 2", "user_id": cls.user_2.id}
)

cls.location_employee = cls.env["stock.location"].create(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: This setup is the same as https://github.com/OCA/hr/blob/a2251a13108632bdd9c0c5ad3cb9e1ca60f3116f/hr_personal_equipment_stock/tests/test_hr_personal_equipment_stock.py#L15, please consider adding a common tests setup over there and reusing it here.

Comment on lines +8 to +14
cls.company_id = cls.env.company
cls.template = cls.env.ref(
"hr_personal_equipment_request_sign_oca.sign_oca_template_personal_equipment_request_demo"
"hr_personal_equipment_request_sign_oca."
"sign_oca_template_personal_equipment_request_demo"
)
cls.company = cls.env.company
cls.company.personal_equipment_request_sign_oca_template_id = cls.template
cls.warehouse = cls.env.ref("stock.warehouse0")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore: Most of these changes do not belong here, please move them to the previous commit where this piece of code has been added.

readonly=False,
)

ppe_report_show_sn = fields.Boolean(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 CONFIGURATION fragment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:hr_personal_equipment_request_sign_oca Module hr_personal_equipment_request_sign_oca series:16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants