← Back to Pull requests

[16.0][FIX] l10n_it_intrastat: port #4256 for use of sale or purchase fp #5334

Open
sergiocorato opened this pull request with 264 lines diff across 8 files
View on GitHub
sergiocorato sergiocorato commented on Sep 21, 2026 08:48 UTC
Author

  • [16.0][IMP] add ability to set intrastat only for in_ or out_ invoices in l10n_it_intrastat

  • [IMP] adapt migration script to v.16 with possible v.14 updated instances
  • Diff: 264 lines (+116 / -148) across 8 files Reviewer: MaurizioPellegrinet Review duration: 109168m
    All Vouch review confidence checks passed
    Residual risk 0.06 = Change Risk (0.54) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.54 · 264 lines diff across 8 files
    0.54
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.89 · 5 substantive comment(s)
    0.89
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    88%
    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.334
    Real PR Conversation Timeline
    12 items
    MaurizioPellegrinet MaurizioPellegrinet approved these changes on Sep 21, 2026 09:02 UTC
    Approved Reviewer

    Test funzionale: OK

    monen17 monen17 commented on code on Oct 30, 2026 09:31 UTC
    Code Review
    l10n_it_intrastat/models/account.py:1
    @@ -307,13 +313,24 @@ def _onchange_partner_id(self):
         @api.model_create_multi
         def create(self, vals_list):
             for val in vals_list:
    -            if "intrastat" not in val and "fiscal_position_id" in val:
    -                intrastat = (
    -                    self.env["account.fiscal.position"]
    -                    .browse(val["fiscal_position_id"])
    -                    .intrastat
    +            if "fiscal_position_id" in val:
    +                fiscal_position = self.env["account.fiscal.position"].browse(
    +                    val["fiscal_position_id"]
                     )
    -                val.update({"intrastat": intrastat})
    +                if "intrastat" not in val:
    +                    intrastat = False
    +                    if "move_type" in val and val.get("move_type"):

    Il move_type potrebbe non essere in vals ma essere comunque valorizzato nella fattura creata, ad esempio con default_move_type.
    In questo caso intrastat resterebbe False.
    Secondo me è da gestire perché in tanti punti si usa default_move_type invece di assegnarlo direttamente.

    monen17 monen17 commented on code on Oct 30, 2026 09:36 UTC
    Code Review
    l10n_it_intrastat/tests/test_intrastat.py:1
    @@ -70,15 +70,16 @@ def test_invoice_totals(self):
             )
             self.assertEqual(total_intrastat_amount, invoice.amount_untaxed)
     
    -    def test_invoice_fiscal_postion(self):
    +    def _test_invoice_fiscal_position(self, intrastat_type):
             self.partner01.property_account_position_id = self.fp_model.create(
                 {
    -                "name": "F.P subjected to intrastat",
    -                "intrastat": True,
    +                "name": "F.P subjected to intrastat on %s" % intrastat_type,
    +                "intrastat_sale": True if intrastat_type == "sale" else False,
    +                "intrastat_purchase": True if intrastat_type == "purchase" else False,

                    "intrastat_sale": intrastat_type == "sale",
                    "intrastat_purchase": intrastat_type == "purchase",
    

    monen17 monen17 commented on code on Oct 30, 2026 09:36 UTC
    Code Review
    l10n_it_intrastat/tests/test_intrastat.py:1
    @@ -70,15 +70,16 @@ def test_invoice_totals(self):
             )
             self.assertEqual(total_intrastat_amount, invoice.amount_untaxed)
     
    -    def test_invoice_fiscal_postion(self):
    +    def _test_invoice_fiscal_position(self, intrastat_type):

    Bell'idea 👏

    monen17 monen17 commented on code on Oct 30, 2026 09:39 UTC
    Code Review
    l10n_it_intrastat/tests/test_intrastat.py:1
    @@ -88,6 +89,17 @@ def test_invoice_fiscal_postion(self):
             invoice.compute_intrastat_lines()
             self.assertEqual(invoice.intrastat, True)
     
    +        invoice_purchase = self.init_invoice(
    +            "in_invoice" if intrastat_type == "sale" else "out_invoice",
    +            partner=self.partner01,
    +            products=self.product01,
    +            taxes=self.tax22,

    Va anche presa un'imposta per acquisti/vendite a seconda del tipo di documento, self.tax22 è sale.
    Non direi però che questo è bloccante.

    monen17 monen17 commented on code on Oct 30, 2026 09:43 UTC
    Code Review
    l10n_it_intrastat/migrations/16.0.1.2.2/pre-migrate.py:1

    Manca la versione corrispondente nel manifest

    monen17 monen17 commented on code on Oct 30, 2026 09:48 UTC
    Code Review
    l10n_it_intrastat/models/account.py:1
    @@ -296,7 +297,12 @@ class AccountMove(models.Model):
     
         @api.onchange("fiscal_position_id")
         def change_fiscal_position(self):
    -        self.intrastat = self.fiscal_position_id.intrastat
    +        self.intrastat = (
    +            self.is_sale_document()

    Quindi non serve per le ricevute? Altrimenti ci vorrebbe include_receipts=True

    monen17 monen17 commented on code on Oct 30, 2026 09:50 UTC
    Code Review
    l10n_it_intrastat/models/account.py:1
    @@ -296,7 +297,12 @@ class AccountMove(models.Model):
     
         @api.onchange("fiscal_position_id")
         def change_fiscal_position(self):
    -        self.intrastat = self.fiscal_position_id.intrastat
    +        self.intrastat = (
    +            self.is_sale_document()
    +            and self.fiscal_position_id.intrastat_sale
    +            or self.is_purchase_document()
    +            and self.fiscal_position_id.intrastat_purchase

    Forse sarebbe più leggibile un bel if/elif/else

    monen17 monen17 commented on code on Oct 30, 2026 09:53 UTC
    Code Review
    l10n_it_intrastat/views/account.xml:1
    @@ -11,7 +11,8 @@
                     <xpath expr="//field[@name='note']" position="before">
                         <separator string="Intrastat" />
                         <group colspan="4">
    -                        <field name="intrastat" />
    +                        <field name="intrastat_purchase" />
    +                        <field name="intrastat_sale" />

    Va aggiornata anche la documentazione dove veniva menzionato il campo rimosso

    monen17 monen17 requested changes on Oct 30, 2026 09:54 UTC
    Changes Requested Reviewer

    Grazie della PR!
    Sembra una bella feature da aggiungere al modulo, vedi per favore i commenti qui sotto

    Aggiungo (da https://github.com/OCA/l10n-italy/pull/4256#pullrequestreview-2520864497):
    Potresti seguire il formato [TAG] module: title indicato nelle linee guida https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#71commit-message?

    [FIX] website: remove unused alert div

    Così la storia dei commit risulta più omogenea

    sergiocorato sergiocorato commented on Nov 06, 2026 17:06 UTC
    Author

    @monen17 ho fatto le modifiche, grazie

    Assignees
    sergiocorato sergiocorato
    Labels
    risk: low confidence: 88.6% reviewed
    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: 53.6% (MEDIUM) · Higher = larger blast radius
    53.6%
    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: 88.6% · Lower = rushed or shallow review
    88.6%
    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: 6.1% · Safe to merge
    6.1%
    Repository