diff --git a/AGENTS.md b/AGENTS.md index 75d3235..9a9fb60 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -43,6 +43,8 @@ Guide rapide pour les agents qui codent dans ce repository. - Preferer des proprietes Python simples exposees par le modele plutot que des expressions Genshi complexes dans le template. - Dans les placeholders XML, utiliser `"` et `'` plutot que des antislashs type `\'`. - Si un document facture depend fortement d'une vente/achat, ajouter au besoin un petit pont Python pour exposer des `report_*` stables au template. + - Si plusieurs actions de report pointent vers `report_name = 'account.invoice'`, verifier aussi le cache `invoice_report_cache` dans `modules/account_invoice/invoice.py`: un mauvais cache peut faire croire que plusieurs actions utilisent le meme `.fodt`. + - Avant de conclure qu'un template ou une action est faux, verifier si le report alternatif doit bypasser le cache standard. ## 5) Workflow de modification (obligatoire) diff --git a/modules/account_invoice/invoice_ict.fodt b/modules/account_invoice/invoice_ict.fodt index 4a15179..ea4efe9 100644 --- a/modules/account_invoice/invoice_ict.fodt +++ b/modules/account_invoice/invoice_ict.fodt @@ -5,16 +5,16 @@ Provisional Invoice willen 2018-12-09T16:20:00 - 2026-03-26T20:24:09.299000000 + 2026-03-26T20:52:14.851000000 2007-08-28T18:19:00 LibreOffice/7.6.0.3$Windows_X86_64 LibreOffice_project/69edd8b8ebc41d00b4de3915dc82f8f0fc3b6265 - PT3H1M50S - 4 + PT3H14M56S + 6 - + - 22049 + 16316 0 27264 13187 @@ -23,12 +23,12 @@ view2 - 11920 - 24352 + 18336 + 21340 0 - 22049 + 16316 27263 - 35234 + 29501 0 0 false @@ -101,7 +101,7 @@ false false false - 147570 + 215514 84510 false false @@ -172,7 +172,7 @@ - + @@ -625,102 +625,106 @@ + + + + - + - + - + - + - - - - - + - + - + - + - + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -729,22 +733,10 @@ - - - - - - - - - - - - - + - + @@ -3829,7 +3821,7 @@ - + @@ -3843,24 +3835,24 @@ - - Provisional Invoice + + Provisional Invoice - - <invoice.number> + + <invoice.number> - Contract N° + Contract N° - <invoice.report_contract_number> + <invoice.report_contract_number> - + @@ -3869,7 +3861,7 @@ Name of the vessel - <invoice.report_shipment or ''> + <invoice.report_vessel or ''> @@ -3877,7 +3869,7 @@ N° of Bill of Lading - <invoice.reference or ''> + <invoice.report_bl_nb or ''> @@ -3899,28 +3891,28 @@ - + - Goods description + Goods description - QUANTITY: <format_number(invoice.report_lbs, invoice.party.lang) if invoice.report_lbs != '' else ''>LBS (<format_number(invoice.report_net, invoice.party.lang) if invoice.report_net != '' else ''> MTS) - <invoice.report_product_description>CROP <invoice.report_crop_name> - <invoice.report_attributes_name> - - <invoice.report_incoterm> - ALL DETAILS AND SPECIFICATIONS AS PER BENEFICIARY - PROFORMA INVOICE NO. <invoice.report_proforma_invoice_number>DATED <format_date(invoice.report_proforma_invoice_date, invoice.party.lang) if invoice.report_proforma_invoice_date else ''>. - + QUANTITY: <format_number(invoice.report_lbs, invoice.party.lang) if invoice.report_lbs != '' else ''>LBS (<format_number(invoice.report_net, invoice.party.lang) if invoice.report_net != '' else ''> MTS) + <invoice.report_product_description>CROP <invoice.report_crop_name> + <invoice.report_attributes_name> + + <invoice.report_incoterm> + ALL DETAILS AND SPECIFICATIONS AS PER BENEFICIARY + PROFORMA INVOICE NO. <invoice.report_proforma_invoice_number>DATED <format_date(invoice.report_proforma_invoice_date, invoice.party.lang) if invoice.report_proforma_invoice_date else ''>. + - + @@ -3928,16 +3920,16 @@ BALES - Gross KGS + Gross KGS NET KGS - + - + @@ -3948,13 +3940,13 @@ <format_number(invoice.report_gross, invoice.party.lang) if invoice.report_gross != '' else ''> - <format_number(invoice.report_net, invoice.party.lang) if invoice.report_net != '' else ''> + <format_number(invoice.report_net, invoice.party.lang) if invoice.report_net != '' else ''> - + @@ -3975,11 +3967,11 @@ <format_number(invoice.report_lbs, invoice.party.lang) if invoice.report_lbs != '' else ''> - + - + @@ -3989,14 +3981,14 @@ FREIGHT VALUE: <invoice.currency.symbol if invoice.currency else 'USD'><format_number(invoice.freight_amount, invoice.party.lang) if hasattr(invoice, 'freight_amount') else ''> - WE CERTIFY THAT THE MERCHANDISE IS OF <invoice.report_origin or ''>ORIGIN - L/C NUMBER <invoice.reference or ''> - + WE CERTIFY THAT THE MERCHANDISE IS OF <invoice.report_origin or ''>ORIGIN + L/C NUMBER <invoice.reference or ''> + - <invoice.currency.symbol if invoice.currency else 'USD'><format_currency(invoice.total_amount, invoice.party.lang, invoice.currency)> - - + <format_currency(invoice.total_amount, invoice.party.lang, invoice.currency)> + + @@ -4005,19 +3997,19 @@ - NET LANDED WEIGHTS, ACTUAL TARE, NO FRANCHISE - + NET LANDED WEIGHTS, ACTUAL TARE, NO FRANCHISE + - <for each="tax in invoice.taxes"> - V.A.T. <tax.description or ''>RATE - </for> + <for each="tax in invoice.taxes"> + V.A.T. <tax.description or ''>RATE + </for> - + @@ -4028,17 +4020,17 @@ Controller Name - <invoice.report_si_number> - - <invoice.report_controller_name> + <invoice.report_si_number> + + <invoice.report_controller_name> - + - + @@ -4053,12 +4045,12 @@ </if> - ICT TRADING S.A. + ICT TRADING S.A. - <invoice.report_trader_initial>/ <invoice.report_operator_initial> + <invoice.report_trader_initial>/ <invoice.report_operator_initial> @@ -4073,7 +4065,7 @@ - + \ No newline at end of file diff --git a/modules/account_invoice/invoice_ict_final.fodt b/modules/account_invoice/invoice_ict_final.fodt index 0ea65e7..e22e6bf 100644 --- a/modules/account_invoice/invoice_ict_final.fodt +++ b/modules/account_invoice/invoice_ict_final.fodt @@ -14,21 +14,21 @@ - 30868 + 0 0 27264 - 13187 + 13804 true false view2 - 5639 - 34064 + 5131 + 1251 0 - 30868 + 0 27263 - 44053 + 13802 0 0 false @@ -101,7 +101,7 @@ false false false - 426446 + 467517 84510 false false @@ -172,7 +172,7 @@ - + @@ -625,102 +625,114 @@ - - + + - + - - + + - + + + + + + + + + - + - - - - - - - - - + - + - + - - + + - + - + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + @@ -729,30 +741,10 @@ - - - - - - - - - - - - - - - - - - - - - + - + @@ -3837,7 +3829,7 @@ - + @@ -3851,24 +3843,24 @@ - - Final Invoice + + Final Invoice - - <invoice.number> + + <invoice.number> - Contract N° + Contract N° - <invoice.report_contract_number> + <invoice.report_contract_number> - + @@ -3877,7 +3869,7 @@ Name of the vessel - <invoice.report_shipment or ''> + <invoice.report_shipment or ''> @@ -3907,36 +3899,36 @@ - + - Goods description + Goods description - <for each="line in invoice.lines"> - <if test="line.type == 'line'"> - <if test="line.description"> - <for each="description in line.description.split('\n')"> - <description> - </for> - </if> - QUANTITY <format_number(line.report_lbs, invoice.party.lang) if line.report_lbs != '' else ''>LBS (<format_number(line.report_net, invoice.party.lang) if line.report_net != '' else ''> MTS) - <line.report_product_description or line.product_name or ''>CROP <line.report_crop_name> - <line.report_attributes_name> - </if> - </for> - <invoice.report_incoterm> - ALL DETAILS AND SPECIFICATIONS AS PER BENEFICIARY - PROFORMA INVOICE NO. <invoice.report_proforma_invoice_number>DATED <format_date(invoice.report_proforma_invoice_date, invoice.party.lang) if invoice.report_proforma_invoice_date else ''>. - + <for each="line in invoice.lines"> + <if test="line.type == 'line'"> + <if test="line.description"> + <for each="description in line.description.split('\n')"> + <description> + </for> + </if> + QUANTITY <format_number(line.report_lbs, invoice.party.lang) if line.report_lbs != '' else ''>LBS (<format_number(line.report_net, invoice.party.lang) if line.report_net != '' else ''> MTS) + <line.report_product_description or line.product_name or ''>CROP <line.report_crop_name> + <line.report_attributes_name> + </if> + </for> + <invoice.report_incoterm> + ALL DETAILS AND SPECIFICATIONS AS PER BENEFICIARY + PROFORMA INVOICE NO. <invoice.report_proforma_invoice_number>DATED <format_date(invoice.report_proforma_invoice_date, invoice.party.lang) if invoice.report_proforma_invoice_date else ''>. + - + @@ -3944,16 +3936,16 @@ BALES - Gross KGS + Gross KGS NET KGS - + - + @@ -3964,13 +3956,13 @@ <format_number(invoice.report_gross, invoice.party.lang) if invoice.report_gross != '' else ''> - <format_number(invoice.report_net, invoice.party.lang) if invoice.report_net != '' else ''> + <format_number(invoice.report_net, invoice.party.lang) if invoice.report_net != '' else ''> - + @@ -3991,11 +3983,11 @@ <format_number(invoice.report_lbs, invoice.party.lang) if invoice.report_lbs != '' else ''> - + - + @@ -4005,14 +3997,14 @@ FREIGHT VALUE: <invoice.currency.symbol if invoice.currency else 'USD'><format_number(invoice.freight_amount, invoice.party.lang) if hasattr(invoice, 'freight_amount') else ''> - WE CERTIFY THAT THE MERCHANDISE IS OF <invoice.report_origin or ''>ORIGIN - L/C NUMBER <invoice.reference or ''> - + WE CERTIFY THAT THE MERCHANDISE IS OF <invoice.report_origin or ''>ORIGIN + L/C NUMBER <invoice.reference or ''> + - <format_currency(invoice.total_amount, invoice.party.lang, invoice.currency)> - - + <format_currency(invoice.total_amount, invoice.party.lang, invoice.currency)> + + @@ -4021,19 +4013,19 @@ - NET LANDED WEIGHTS, ACTUAL TARE, NO FRANCHISE - + NET LANDED WEIGHTS, ACTUAL TARE, NO FRANCHISE + - <for each="tax in invoice.taxes"> - V.A.T. <tax.description or ''>RATE - </for> + <for each="tax in invoice.taxes"> + V.A.T. <tax.description or ''>RATE + </for> - + @@ -4044,17 +4036,17 @@ Controller Name - <invoice.report_si_number> - - <invoice.report_controller_name> + <invoice.report_si_number> + + <invoice.report_controller_name> - + - + @@ -4069,12 +4061,12 @@ </if> - ICT TRADING S.A. + ICT TRADING S.A. - <invoice.report_trader_initial>/ <invoice.report_operator_initial> + <invoice.report_trader_initial>/ <invoice.report_operator_initial> @@ -4089,7 +4081,7 @@ - + \ No newline at end of file diff --git a/modules/purchase_trade/docs/template-rules.md b/modules/purchase_trade/docs/template-rules.md index 885fd88..04ec891 100644 --- a/modules/purchase_trade/docs/template-rules.md +++ b/modules/purchase_trade/docs/template-rules.md @@ -82,6 +82,17 @@ Derniere mise a jour: `2026-03-26` - `report_payment_date` - `report_shipment` +### TR-006 - Penser au cache des reports facture avant d'accuser le `.fodt` + +- Les actions de report `account.invoice` peuvent partager le meme moteur de rendu. +- Dans `modules/account_invoice/invoice.py`, le champ `invoice_report_cache` peut reutiliser un document deja genere. +- Symptome typique: + - plusieurs actions differentes (`Provisional Invoice`, `Final Invoice`, `Prepayment`, etc.) semblent ouvrir le meme template ou le meme rendu +- Reflexe a avoir: + - verifier si le probleme vient du cache avant de modifier le `.fodt` + - pour un report alternatif, ne pas reutiliser le cache du report standard `account_invoice/invoice.fodt` + - si besoin, bypasser la lecture/ecriture du cache pour les templates alternatifs + ## 4) Workflow recommande pour corriger un template en erreur 1. Identifier le placeholder exact qui provoque l'erreur Relatorio. @@ -90,6 +101,7 @@ Derniere mise a jour: `2026-03-26` 4. Si l'expression devient trop longue, la deplacer dans une propriete Python `report_*`. 5. Ne modifier que les placeholders necessaires. 6. Regenerer le document pour verifier la prochaine erreur eventuelle. +7. Si plusieurs actions affichent le meme rendu, verifier ensuite le cache `invoice_report_cache`. ## 5) Cas documentes dans ce repo diff --git a/modules/purchase_trade/invoice.py b/modules/purchase_trade/invoice.py index dd696f7..4aa627b 100644 --- a/modules/purchase_trade/invoice.py +++ b/modules/purchase_trade/invoice.py @@ -192,6 +192,18 @@ class Invoice(metaclass=PoolMeta): if shipment: return shipment.bl_date + @property + def report_bl_nb(self): + shipment = self._get_report_shipment() + if shipment: + return shipment.bl_number + + @property + def report_vessel(self): + shipment = self._get_report_shipment() + if shipment and shipment.vessel: + return shipment.vessel.vessel_name + @property def report_loading_port(self): shipment = self._get_report_shipment()