← Back to Pull requests

[19.0][IMP] payroll: prepare retained refund evidence before confirmation #332

Open
votrelec opened this pull request with 68 lines diff across 4 files
View on GitHub
votrelec votrelec commented on Nov 10, 2026 13:10 UTC
Author

An installed localization can keep statutory calculation evidence in copy=False fields. The native full-refund workflow copies the salary lines and immediately confirms the copy without recomputing it. There is currently no narrow extension point to attach the original retained evidence before confirmation validates that copy.

Extract the existing copy operation into _copy_refund_payslip(). Localizations can extend it cooperatively to attach their retained evidence reference. The default copy values, numbering, confirmation and original-to-refund link keep their existing behavior. This does not add a country-specific policy to the payroll engine.

Validation: all 28 native payroll tests pass, including a new workflow regression that extends the hook, checks that preparation occurs before confirmation, changes the current contract wage and verifies that the confirmed refund retains the original salary amounts. Ruff check and format pass for the changed Python files.

Diff: 68 lines (+61 / -7) across 4 files Reviewer: dreispt Review duration: 20544m
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.56) × (1 − Review Confidence (0.91)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.56 · 68 lines diff across 4 files
0.56
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.94 · 2 substantive comment(s)
0.94
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
90%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.253
Sensitive Paths sensitive_paths
0.056
Real PR Conversation Timeline
3 items
OCA-git-bot OCA-git-bot commented on Nov 10, 2026 13:10 UTC
Bot

Hi @appstogrow, @nimarosa,
some modules you are maintaining are being modified, check this out!

dreispt dreispt commented on code on Nov 18, 2026 12:31 UTC
Code Review
payroll/models/hr_payslip.py:1
@@ -227,16 +227,27 @@ def action_payslip_cancel(self):
                     raise UserError(self.env._("Cannot cancel a payslip that is done."))
         return self.write({"state": "cancel"})
 
+    def _copy_refund_payslip(self):
+        """Prepare the full refund copy before it is confirmed.
+
+        Localization modules may extend this step to retain a reference to
+        original calculation evidence that uses copy=False. The refund must
+        preserve the original salary amounts instead of recomputing them
+        from today's employment settings.
+        """
+        self.ensure_one()
+        return self.copy(
+            {
+                "credit_note": True,
+                "name": self.env._("Refund: %(name)s", name=self.name),
+            }
+        )
+
     def refund_sheet(self):
         copied_payslips = self.env["hr.payslip"]
         for payslip in self:
             # Create a refund slip
-            copied_payslip = payslip.copy(
-                {
-                    "credit_note": True,
-                    "name": self.env._("Refund: %(name)s", name=payslip.name),
-                }
-            )
+            copied_payslip = payslip._copy_refund_payslip()

The standard is to use the "prepare" pattern.
Why not use it here?

            refund_values = payslip._prepare_refund_payslip()
            copied_payslip = payslip.copy(refund_values)

Reviewers
Assignees
votrelec votrelec
Labels
risk: low confidence: 90.9% reviewed sensitive_module
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 55.9% (MEDIUM) · Higher = larger blast radius
55.9%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 90.9% · Lower = rushed or shallow review
90.9%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 5.1% · Safe to merge
5.1%
Repository