From 90ff6e936ee3f93f683056f81da39c60fe6e2043 Mon Sep 17 00:00:00 2001 From: sergiocorato Date: Fri, 18 Jan 2019 14:45:54 +0100 Subject: [PATCH 01/27] [10.0] Add ability to fatturapa to export xml with DatiRitenuta and Enasarco in AltriDatiGestionali [FIX] tax value and translation issues [FIX] set default [FIX] view --- l10n_it_fatturapa_out_wt/README.rst | 83 ++++ l10n_it_fatturapa_out_wt/__init__.py | 5 + l10n_it_fatturapa_out_wt/__manifest__.py | 28 ++ l10n_it_fatturapa_out_wt/models/__init__.py | 4 + .../models/withholding_tax.py | 16 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 11 + .../static/description/icon.png | Bin 0 -> 4829 bytes .../static/description/index.html | 424 ++++++++++++++++++ .../views/withholding_tax_view.xml | 19 + l10n_it_fatturapa_out_wt/wizard/__init__.py | 4 + .../wizard/wizard_export_fatturapa.py | 60 +++ 12 files changed, 655 insertions(+) create mode 100644 l10n_it_fatturapa_out_wt/README.rst create mode 100644 l10n_it_fatturapa_out_wt/__init__.py create mode 100644 l10n_it_fatturapa_out_wt/__manifest__.py create mode 100644 l10n_it_fatturapa_out_wt/models/__init__.py create mode 100644 l10n_it_fatturapa_out_wt/models/withholding_tax.py create mode 100644 l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst create mode 100644 l10n_it_fatturapa_out_wt/readme/DESCRIPTION.rst create mode 100644 l10n_it_fatturapa_out_wt/static/description/icon.png create mode 100644 l10n_it_fatturapa_out_wt/static/description/index.html create mode 100644 l10n_it_fatturapa_out_wt/views/withholding_tax_view.xml create mode 100644 l10n_it_fatturapa_out_wt/wizard/__init__.py create mode 100644 l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py diff --git a/l10n_it_fatturapa_out_wt/README.rst b/l10n_it_fatturapa_out_wt/README.rst new file mode 100644 index 000000000000..ba09c46a3a32 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/README.rst @@ -0,0 +1,83 @@ +================================================================== +Italian Localization - Fattura elettronica - Integrazione ritenuta +================================================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-italy/tree/10.0/l10n_it_fatturapa_out_wt + :alt: OCA/l10n-italy +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-italy-10-0/l10n-italy-10-0-l10n_it_fatturapa_out_wt + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/122/10.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +**Italiano** + +Modulo ponte tra emissione fatture elettroniche e ritenute. + +Con questo modulo, l'elemento XML DatiRitenuta verrà correttamente valorizzato. + +**English** + +Bridge module within e-invoice emission and withholding tax. + +With this module, XML element DatiRitenuta will be correctly filled. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Sergio Corato + +Contributors +~~~~~~~~~~~~ + +* Sergio Corato + +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/l10n-italy `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_it_fatturapa_out_wt/__init__.py b/l10n_it_fatturapa_out_wt/__init__.py new file mode 100644 index 000000000000..4218e821ce1c --- /dev/null +++ b/l10n_it_fatturapa_out_wt/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models +from . import wizard diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py new file mode 100644 index 000000000000..aae7a819e58e --- /dev/null +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Author(s): Andrea Colangelo (andreacolangelo@openforce.it) +# Copyright 2018 Openforce Srls Unipersonale (www.openforce.it) +# Copyright 2018 Sergio Corato (https://efatto.it) +# Copyright 2018-2019 Lorenzo Battistini +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + 'name': 'Italian Localization - Fattura elettronica - Integrazione ' + 'ritenuta', + 'summary': 'Modulo ponte tra emissione fatture elettroniche e ritenute.', + 'version': '10.0.1.0.0', + 'development_status': 'Beta', + 'category': 'Hidden', + 'website': 'https://github.com/OCA/l10n-italy', + 'author': 'Sergio Corato, Odoo Community Association (OCA)', + 'license': 'LGPL-3', + 'depends': [ + 'l10n_it_fatturapa', + 'l10n_it_fatturapa_out', + 'l10n_it_withholding_tax', + 'l10n_it_withholding_tax_causali', + ], + 'data': [ + 'views/withholding_tax_view.xml', + ], + 'installable': True, + 'auto_install': True, +} diff --git a/l10n_it_fatturapa_out_wt/models/__init__.py b/l10n_it_fatturapa_out_wt/models/__init__.py new file mode 100644 index 000000000000..48de5b6fc21f --- /dev/null +++ b/l10n_it_fatturapa_out_wt/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import withholding_tax diff --git a/l10n_it_fatturapa_out_wt/models/withholding_tax.py b/l10n_it_fatturapa_out_wt/models/withholding_tax.py new file mode 100644 index 000000000000..eee91aa4470b --- /dev/null +++ b/l10n_it_fatturapa_out_wt/models/withholding_tax.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Author(s): Sergio Corato (https://efatto.it) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openerp import fields, models + + +class WithholdingTax(models.Model): + _inherit = 'withholding.tax' + + welfare_fund_type_id = fields.Many2one( + 'welfare.fund.type', 'Welfare Fund Type') + wt_types = fields.Selection([ + ('enasarco', 'Enasarco tax'), + ('ritenuta', 'Withholding tax'), + ], 'Withholding tax type', required=True, default='ritenuta') diff --git a/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst b/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..feb5b093f570 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sergio Corato diff --git a/l10n_it_fatturapa_out_wt/readme/DESCRIPTION.rst b/l10n_it_fatturapa_out_wt/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..5d02045793b5 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/readme/DESCRIPTION.rst @@ -0,0 +1,11 @@ +**Italiano** + +Modulo ponte tra emissione fatture elettroniche e ritenute. + +Con questo modulo, l'elemento XML DatiRitenuta verrà correttamente valorizzato. + +**English** + +Bridge module within e-invoice emission and withholding tax. + +With this module, XML element DatiRitenuta will be correctly filled. diff --git a/l10n_it_fatturapa_out_wt/static/description/icon.png b/l10n_it_fatturapa_out_wt/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1f07394c3b7990a313c758a4aaf6eab53e23e072 GIT binary patch literal 4829 zcmZ`-cQ_l|7mlK0r}iEdvy_@qdlNf+Myg7cR<(%LsJ*GyUbQJj&1j93*rTe%s8D;S zipJjKm+$%h{@wSv_uS|Fb?-UveeQWroSBIpEfoh9005vh(AS0$t=Yd5c$2s$+}f)q znwyUe^|S%k|Dq66mP+(cdg|MH0|3;F|4tG>b}k#yN#SE)tV1zR!OqCaO)9&d3ji=Y zH_+CwL{4vK`zNjaQsVo-1v8L@W2O4^Z5p;2&DX5Gyfaix6NT1fn_xs1vmKA4Z}9G5*bP>lYs0l_86{-EfemL$wYtEX~XFx(6Qx0z}MQ_X8yQ)<{$_5%>mlWCZ#N>H?O@k12f83Q?X?mNv z#HYs~2E5I{ERY+ui$c)xsv0rr5R?CXO&ad@8pDIJPlO~Gq(q|8in-qU6)4=&IX}i; zt#|h_RI^AQMCQ{ncU4;^2dx;VDD1vPrkZDxBk~4#gBK*5V_Ym!YFkQ&4f6&31~h(;ym$rC=OmP`=DBt?8Ao-ms#nh zMy95W(fr=t-aoKd`jj>MTD^R{w)w(mToO`BIf5PatA7%Iz&VG>AR9T&8 z2yhq&;LfnBY{-Tvm_zT$V3L)wuCg5ZqOJ{aHYXcf+afa&DHRo3^-`G5rqgTy0RzDk zk7HzPO#3O74=9oj1siClfJx~Ol|9T*${Z_2!47+~lGtUo5=+a<4@4@A$&&LKFv!1{ zQU{Set419mRq_6+O0V)Gyc3kM#J9P&=3J6SWOxG$c7I2i7(xof!KghaePbPr%G8a8 zWgUepN_!j_n0p%KPsgqJ<75?_o-B5}z0eOWGbToYsv90}%gl>we2SSboO53xCz;-# zY6?+9%K=4q19=rj{JAc|m(bU=^lw+#)PN&Urz&R`7t$^RJ0-^;RQOX3h=#wH%4dqi zq{Mg94F~~X7*nNiMYt}eb3W)i>wWfK8YgyxtPvz|- z8-c*R@bSDGtq;x3eNveOGvbVW*EB|_+^Q^`P9-c`n&RTK0!(cAE&c@1XAtR2s;Wu# zx7i~jqG@*MS8wRcOto7N4?x4AsX)}EZX}0N3MTDW5m_|wG>PV~x zc#Eyt%|hc;IBns*wB4SGq^%fkzoFkj*W2`|Gj(kq34~2Pt!{ zj`iP0RbtSHUC_9B@|^;I5_5+s!Js2Q3Dy{L_v>};S-3~Nd;K@Vf(y10p4ytkLb$CI_D>NAOk$>2geHq)mdvkW8y1vrE^rg9^Q5O@Fgk=GR*&op| zF34^}-uNHlW0|tcZ`CeOth26g^!^NtKBR-ks(u2SlFFIelI_3^o<5elk>vODdLAs#JHfja?ri2qG96>epj}QA7bzq#5ju96?JoApY zWRplVd3YfJm&{3;yiPdAcG1&^mGPS(htpXRzb%^f@&k^wd{d~03szG-f+#)CcC1fY zLQd#wuD6bCW&JWimPI> z5!v-sgh1foS4mHQ72$m<<>T&2&+d6!E7b$zVu8<0FS;Je6^$J;m?xKdb|+tzFRmZv7(@(O$0Bwq zV`+KY|1w{!OXkINqkhV_o@*(1{i4qRefhQbXYiNrp#}RO!~E%XOY;tk);?#`K9=`_ zA+z<|`C#m=zH1c|y#cX8jRFNpzL4ASQF`JE9W(CG$LXlzUvhMw@+@a99o7c1UQ0J7 zBv%cU>h3>ybS30n%3+>smdVn7f1s@W=wZI!m9G7jVIu!V--w=eE=LLR1O9|;qgQ8n zY6E_MPZ$hJs7_oMZkZ1x_qdLz^`3hiVft4wl!Ypp;}1$8fqwt2vS8qgWO83!aPhap z+P1g&t!dqLu)+eWKp|vHD500T?PRiPZ}wph#OZZ-;^parj9>RFQFK<<=?t=K#$Nx; z63x=?8~R7xnKdUOruX4Xe>dCuewohou8zNQ*k>}_0fqjVcB{qsRi{}%Z|RUHaOL%~ zB{Ek+au1PL7VkHIY0CQq@YHw`xs-}6u@eXS6#lqA^89!~&q?s(efhY7=@U4AWZ#pFa(T^ac&Fot zW^#|>bgF(Sg3c%-rH3-ly=yAg)CDXS>j?uH#BqOtNDNcL$Zp1b20e=tR&VBt;n+%$ z#hy(hfcQGJ_)VYvdF2&f3+AAvd&~3;|LhB`$LS@Ok>Ft_o$%A!2Sb-?A7+?;tbI42 z)4dN$-qwugxmv{(xNKrRgL@H;KU|D_GtBQgZPq^OSu1#bN66T`vSq#Gp`x3_Fo$&N zy>^J<=Qe%Z1Ag%YDS5?r1oF3*dT4?$#Z>(ojSD?@4|U-8R7MAJZ)$3$uB39dQTHZx zUS467fM@)5u22-4W0Wpc7-(c$P@i9fjN_@yTdH$29!pvX*Knv!!1u6JcQg5;f^P_u z<&rLbGk<6?vt+$yLfWOZN3Rd%rr zc($V7pz(yiKE-=O_)$MvGT{ESjoIE4p5OW@S-jULdX{>hZ1`iT_#t|g6I%+Y(0@|E z&NYgLXq%6)8Z$8_TX?PjjaGP_decnl%!ZV-w5Fv<9pU$li9aH1u=kHG)u$TPQ-u-& zAoy6Ss9@K%v*Kvq%M}w(yCMWc{8IG|0Q|a83GRl{4F8?!_MOVo9irQp|0;;mx1ZmO zH?j<68%{^#LXr@8txAQF@8rynp$Xhln|~wn(@Z~*OPcYCz3vMyAwQ$N!2*AZyMYc% zuQW|d)M`dId_Xq!&GAP!J}S6>{8c5Rrk0rYM%Rh*sl-gwP!-qYv{F_dmnuTUeV?3M#yMrV$nOoWdsNmSw zS(8PkmN7!YlSOI8;~O;5VK|O8H){LM4sKRXb4hSrkNiDUf|MP9LI9hS`6o$?LXIJu6S49q>KkY&15rhx(N09=nv|2~SEf@m z;^Ey-nS%$fF&cLkwH2@NFWs)T$jGE`7j~RUa8A{q|DcfaQg;`J z59pB*N>*Otvcs&2I&c{xGzbgtc#1$IYsJtJX>;e!ovm4P>cBu;ThHpT1#p2n3AS{8 z^*sAFh11JRMDvP8RXdPC3aS+IGeFAT-!I`Rv46xTBPvEHlX3gh1iSw1hWv({na080 zuZOmYmR*K-qKQ0#QZZHb1wzouY3qn{y-IkJd}kN!U` r8aiT|hVCWM^FKV(3jG&l)t9W+$TKay + + + + + +Italian Localization - Fattura elettronica - Integrazione ritenuta + + + +
+

Italian Localization - Fattura elettronica - Integrazione ritenuta

+ + +

Beta License: LGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

+

Italiano

+

Modulo ponte tra emissione fatture elettroniche e ritenute.

+

Con questo modulo, l’elemento XML DatiRitenuta verrà correttamente valorizzato.

+

English

+

Bridge module within e-invoice emission and withholding tax.

+

With this module, XML element DatiRitenuta will be correctly filled.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Sergio Corato
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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/l10n-italy project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/l10n_it_fatturapa_out_wt/views/withholding_tax_view.xml b/l10n_it_fatturapa_out_wt/views/withholding_tax_view.xml new file mode 100644 index 000000000000..f4233680f6c6 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/views/withholding_tax_view.xml @@ -0,0 +1,19 @@ + + + + view.withholding.tax.form.fatturapa.wt + withholding.tax + + + + + + + + + {'invisible': [('wt_types', '!=', 'ritenuta')]} + + + + + diff --git a/l10n_it_fatturapa_out_wt/wizard/__init__.py b/l10n_it_fatturapa_out_wt/wizard/__init__.py new file mode 100644 index 000000000000..be4e4d181cb5 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/wizard/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from . import wizard_export_fatturapa diff --git a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py new file mode 100644 index 000000000000..f6df6be13d3b --- /dev/null +++ b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo import models +from odoo.tools.translate import _ +from odoo.exceptions import Warning as UserError +from odoo.addons.l10n_it_fatturapa.bindings.fatturapa import ( + DatiRitenutaType, + AltriDatiGestionaliType, +) + + +class WizardExportFatturapa(models.TransientModel): + _inherit = "wizard.export.fatturapa" + + def setDatiGeneraliDocumento(self, invoice, body): + res = super(WizardExportFatturapa, self).setDatiGeneraliDocumento( + invoice, body) + ritenuta_lines = invoice.withholding_tax_line_ids.filtered( + lambda x: x.withholding_tax_id.wt_types == 'ritenuta') + if len(ritenuta_lines) > 1: + raise UserError( + _("More than one withholding tax in invoice!")) + for wt_line in ritenuta_lines: + if not wt_line.withholding_tax_id.causale_pagamento_id.code: + raise UserError(_('Missing causale pagamento for ' + 'withholding tax %s!') + % wt_line.withholding_tax_id.name) + body.DatiGenerali.DatiGeneraliDocumento.DatiRitenuta\ + = DatiRitenutaType( + TipoRitenuta="RT02" if invoice.partner_id.is_company + else "RT01", # RT02 persona giuridica + ImportoRitenuta='%.2f' % wt_line.tax, + AliquotaRitenuta='%.2f' % ( + wt_line.tax / wt_line.base * 100), + CausalePagamento=wt_line.withholding_tax_id. + causale_pagamento_id.code + ) + return res + + def setDettaglioLinee(self, invoice, body): + res = super(WizardExportFatturapa, self).setDettaglioLinee( + invoice, body) + enasarco_lines = invoice.withholding_tax_line_ids.filtered( + lambda x: x.withholding_tax_id.wt_types == 'enasarco') + if len(enasarco_lines) > 1: + raise UserError( + _("More than one Enasarco tax in invoice!")) + for wt_line in enasarco_lines: + # tmp put values in the first line + # todo split values for lines with withholding type enasarco + body.DatiBeniServizi.DettaglioLinee[0].AltriDatiGestionali.append( + AltriDatiGestionaliType( + TipoDato="CASSA-PREV", + RiferimentoTesto='ENASARCO %s' % wt_line. + withholding_tax_id.welfare_fund_type_id.name, + RiferimentoNumero='%.2f' % wt_line.tax, + ) + ) + return res From fdfee10b2b1a890d33275eeb9733c4ae31fe05e4 Mon Sep 17 00:00:00 2001 From: Roberto Fichera Date: Mon, 16 Sep 2019 12:28:33 +0200 Subject: [PATCH 02/27] [10.0][l10n_it_withholding_tax] Move welfare fund type and withholding tax types from l10n_it_fatturapa_out_wt --- l10n_it_fatturapa_out_wt/__init__.py | 1 - l10n_it_fatturapa_out_wt/__manifest__.py | 4 +--- l10n_it_fatturapa_out_wt/models/__init__.py | 4 ---- .../models/withholding_tax.py | 16 ---------------- .../views/withholding_tax_view.xml | 19 ------------------- 5 files changed, 1 insertion(+), 43 deletions(-) delete mode 100644 l10n_it_fatturapa_out_wt/models/__init__.py delete mode 100644 l10n_it_fatturapa_out_wt/models/withholding_tax.py delete mode 100644 l10n_it_fatturapa_out_wt/views/withholding_tax_view.xml diff --git a/l10n_it_fatturapa_out_wt/__init__.py b/l10n_it_fatturapa_out_wt/__init__.py index 4218e821ce1c..3ee39aaa7d1e 100644 --- a/l10n_it_fatturapa_out_wt/__init__.py +++ b/l10n_it_fatturapa_out_wt/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from . import models from . import wizard diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py index aae7a819e58e..fb375eac679a 100644 --- a/l10n_it_fatturapa_out_wt/__manifest__.py +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -20,9 +20,7 @@ 'l10n_it_withholding_tax', 'l10n_it_withholding_tax_causali', ], - 'data': [ - 'views/withholding_tax_view.xml', - ], + 'data': [], 'installable': True, 'auto_install': True, } diff --git a/l10n_it_fatturapa_out_wt/models/__init__.py b/l10n_it_fatturapa_out_wt/models/__init__.py deleted file mode 100644 index 48de5b6fc21f..000000000000 --- a/l10n_it_fatturapa_out_wt/models/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - -from . import withholding_tax diff --git a/l10n_it_fatturapa_out_wt/models/withholding_tax.py b/l10n_it_fatturapa_out_wt/models/withholding_tax.py deleted file mode 100644 index eee91aa4470b..000000000000 --- a/l10n_it_fatturapa_out_wt/models/withholding_tax.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Author(s): Sergio Corato (https://efatto.it) -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - -from openerp import fields, models - - -class WithholdingTax(models.Model): - _inherit = 'withholding.tax' - - welfare_fund_type_id = fields.Many2one( - 'welfare.fund.type', 'Welfare Fund Type') - wt_types = fields.Selection([ - ('enasarco', 'Enasarco tax'), - ('ritenuta', 'Withholding tax'), - ], 'Withholding tax type', required=True, default='ritenuta') diff --git a/l10n_it_fatturapa_out_wt/views/withholding_tax_view.xml b/l10n_it_fatturapa_out_wt/views/withholding_tax_view.xml deleted file mode 100644 index f4233680f6c6..000000000000 --- a/l10n_it_fatturapa_out_wt/views/withholding_tax_view.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - view.withholding.tax.form.fatturapa.wt - withholding.tax - - - - - - - - - {'invisible': [('wt_types', '!=', 'ritenuta')]} - - - - - From 134c151e30814ddc4f1e6f186d225cb68a756278 Mon Sep 17 00:00:00 2001 From: eLBati Date: Wed, 9 Oct 2019 15:28:40 +0200 Subject: [PATCH 03/27] porting l10n_it_fatturapa_out_wt to 12 --- l10n_it_fatturapa_out_wt/__init__.py | 1 - l10n_it_fatturapa_out_wt/__manifest__.py | 3 +-- l10n_it_fatturapa_out_wt/wizard/__init__.py | 1 - l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/l10n_it_fatturapa_out_wt/__init__.py b/l10n_it_fatturapa_out_wt/__init__.py index 3ee39aaa7d1e..4b25b9723083 100644 --- a/l10n_it_fatturapa_out_wt/__init__.py +++ b/l10n_it_fatturapa_out_wt/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from . import wizard diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py index fb375eac679a..1b64959619f3 100644 --- a/l10n_it_fatturapa_out_wt/__manifest__.py +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Author(s): Andrea Colangelo (andreacolangelo@openforce.it) # Copyright 2018 Openforce Srls Unipersonale (www.openforce.it) # Copyright 2018 Sergio Corato (https://efatto.it) @@ -8,7 +7,7 @@ 'name': 'Italian Localization - Fattura elettronica - Integrazione ' 'ritenuta', 'summary': 'Modulo ponte tra emissione fatture elettroniche e ritenute.', - 'version': '10.0.1.0.0', + 'version': '12.0.1.0.0', 'development_status': 'Beta', 'category': 'Hidden', 'website': 'https://github.com/OCA/l10n-italy', diff --git a/l10n_it_fatturapa_out_wt/wizard/__init__.py b/l10n_it_fatturapa_out_wt/wizard/__init__.py index be4e4d181cb5..867b656accc2 100644 --- a/l10n_it_fatturapa_out_wt/wizard/__init__.py +++ b/l10n_it_fatturapa_out_wt/wizard/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). from . import wizard_export_fatturapa diff --git a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py index f6df6be13d3b..2000f64e9dde 100644 --- a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py +++ b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). from odoo import models From 9cc9191f135cbc55180f88adc5f4bc84d5ea70b9 Mon Sep 17 00:00:00 2001 From: eLBati Date: Wed, 9 Oct 2019 17:17:04 +0200 Subject: [PATCH 04/27] REF l10n_it_withholding_tax, l10n_it_fatturapa_out_wt, l10n_it_fatturapa_in removing welfare_fund_type_id --- l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py index 2000f64e9dde..e7d9f61509e0 100644 --- a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py +++ b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py @@ -51,8 +51,7 @@ def setDettaglioLinee(self, invoice, body): body.DatiBeniServizi.DettaglioLinee[0].AltriDatiGestionali.append( AltriDatiGestionaliType( TipoDato="CASSA-PREV", - RiferimentoTesto='ENASARCO %s' % wt_line. - withholding_tax_id.welfare_fund_type_id.name, + RiferimentoTesto='ENASARCO TC07', RiferimentoNumero='%.2f' % wt_line.tax, ) ) From 3fb4c517ab5b8832d20891e949b3b16ec01c54f7 Mon Sep 17 00:00:00 2001 From: eLBati Date: Thu, 10 Oct 2019 08:43:29 +0200 Subject: [PATCH 05/27] REF l10n_it_fatturapa_out_wt and l10n_it_fatturapa_out to export ENASARCO lines ADD option to fill DatiCassaPrevidenziale with enasarco data ADD tests FIX payment terms FIX missing in lines --- l10n_it_fatturapa_out_wt/__manifest__.py | 2 +- .../i18n/l10n_it_fatturapa_out_wt.pot | 34 +++ l10n_it_fatturapa_out_wt/tests/__init__.py | 3 + .../tests/data/IT06363391001_00011.xml | 103 ++++++++ .../tests/data/IT06363391001_00014.xml | 108 +++++++++ .../tests/data/IT06363391001_00015.xml | 124 ++++++++++ .../tests/data/IT06363391001_00016.xml | 120 ++++++++++ .../tests/test_fatturapa_wt.py | 226 ++++++++++++++++++ .../wizard/wizard_export_fatturapa.py | 99 ++++++-- 9 files changed, 799 insertions(+), 20 deletions(-) create mode 100644 l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot create mode 100644 l10n_it_fatturapa_out_wt/tests/__init__.py create mode 100644 l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00011.xml create mode 100644 l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml create mode 100644 l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml create mode 100644 l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml create mode 100644 l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py index 1b64959619f3..02f8c17d08bc 100644 --- a/l10n_it_fatturapa_out_wt/__manifest__.py +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -4,7 +4,7 @@ # Copyright 2018-2019 Lorenzo Battistini # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { - 'name': 'Italian Localization - Fattura elettronica - Integrazione ' + 'name': 'ITA - Fattura elettronica - Integrazione ' 'ritenuta', 'summary': 'Modulo ponte tra emissione fatture elettroniche e ritenute.', 'version': '12.0.1.0.0', diff --git a/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot b/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot new file mode 100644 index 000000000000..ee31eee47b44 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_fatturapa_out_wt +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-10-21 10:49+0000\n" +"PO-Revision-Date: 2019-10-21 10:49+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_it_fatturapa_out_wt +#: model:ir.model,name:l10n_it_fatturapa_out_wt.model_wizard_export_fatturapa +msgid "Export E-invoice" +msgstr "" + +#. module: l10n_it_fatturapa_out_wt +#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:27 +#, python-format +msgid "Missing causale pagamento for withholding tax %s!" +msgstr "" + +#. module: l10n_it_fatturapa_out_wt +#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:24 +#, python-format +msgid "More than one withholding tax in invoice!" +msgstr "" + diff --git a/l10n_it_fatturapa_out_wt/tests/__init__.py b/l10n_it_fatturapa_out_wt/tests/__init__.py new file mode 100644 index 000000000000..596933ddb061 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/__init__.py @@ -0,0 +1,3 @@ +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from . import test_fatturapa_wt diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00011.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00011.xml new file mode 100644 index 000000000000..750a2cf681ee --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00011.xml @@ -0,0 +1,103 @@ + + + + + IT + 06363391001 + + 00011 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0013 + + RT02 + 2.00 + 20.00 + A + + 12.20 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 22.00 + SI + + + 22.00 + 10.00 + 2.20 + + + + TP02 + + MP05 + 2019-02-28 + 10.20 + + + + diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml new file mode 100644 index 000000000000..365f5ed0d81e --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml @@ -0,0 +1,108 @@ + + + + + IT + 06363391001 + + 00014 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0014 + + RT02 + 2.00 + 20.00 + A + + 12.20 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 22.00 + SI + + CASSA-PREV + ENASARCO TC07 (8.25%) + 0.83 + + + + 22.00 + 10.00 + 2.20 + + + + TP02 + + MP05 + 2019-02-28 + 9.37 + + + + \ No newline at end of file diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml new file mode 100644 index 000000000000..9169c047d7c3 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml @@ -0,0 +1,124 @@ + + + + + IT + 06363391001 + + 00015 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0015 + + RT02 + 2.00 + 20.00 + A + + + TC07 + 8.25 + 0.83 + 0.00 + N2 + + 12.20 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 22.00 + SI + + CASSA-PREV + ENASARCO TC07 (8.25%) + 0.83 + + + + 22.00 + 10.00 + 2.20 + + + 0.00 + N2 + 0.83 + 0.00 + Escluso Art. 13 5C DPR 633/72 + + + + TP02 + + MP05 + 2019-02-28 + 9.37 + + + + \ No newline at end of file diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml new file mode 100644 index 000000000000..ef6d31bbf1db --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml @@ -0,0 +1,120 @@ + + + + + IT + 06363391001 + + 00016 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0016 + + RT02 + 2.00 + 20.00 + A + + + TC07 + 8.25 + 0.83 + 0.00 + N2 + + 10.00 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 0.00 + SI + N2 + + CASSA-PREV + ENASARCO TC07 (8.25%) + 0.83 + + + + 0.00 + N2 + 10.83 + 0.00 + Escluso Art. 13 5C DPR 633/72 + + + + TP02 + + MP05 + 2019-02-28 + 7.17 + + + + \ No newline at end of file diff --git a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py new file mode 100644 index 000000000000..598dacd1182f --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py @@ -0,0 +1,226 @@ +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +import base64 +from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import ( + FatturaPACommon) + + +class TestInvoiceWT(FatturaPACommon): + + def setUp(self): + super(TestInvoiceWT, self).setUp() + type_payable = self.env.ref('account.data_account_type_payable') + type_receivable = self.env.ref('account.data_account_type_receivable') + self.tax_0 = self.env.ref('l10n_it_fatturapa.tax_00_enas') + self.wt_account_payable = self.env['account.account'].create({ + 'name': 'Debiti per ritenute da versare', + 'code': 'WT_001', + 'user_type_id': type_payable.id, + 'reconcile': True, + }) + self.wt_account_receivable = self.env['account.account'].create({ + 'name': 'Crediti per ritenute subite', + 'code': 'WT_002', + 'user_type_id': type_receivable.id, + 'reconcile': True, + }) + self.journal_misc = self.env['account.journal'].search( + [('type', '=', 'general')])[0] + vals_payment = { + 'name': "", + 'line_ids': [(0, 0, {'value': 'balance', 'days': 15})] + } + self.payment_term_15 = self.env['account.payment.term'].create( + vals_payment) + wt_vals = { + 'name': 'Code 1040', + 'code': '1040', + 'certification': True, + 'account_receivable_id': self.wt_account_receivable.id, + 'account_payable_id': self.wt_account_payable.id, + 'journal_id': self.journal_misc.id, + 'payment_term': self.payment_term_15.id, + 'causale_pagamento_id': self.env.ref( + 'l10n_it_causali_pagamento.a').id, + 'rate_ids': [(0, 0, { + 'tax': 20, + 'base': 1, + })] + } + self.wt1040 = self.env['withholding.tax'].create(wt_vals) + wt_vals = { + 'name': 'Enasarco', + 'code': 'Enasarco', + 'account_receivable_id': self.wt_account_receivable.id, + 'account_payable_id': self.wt_account_payable.id, + 'journal_id': self.journal_misc.id, + 'wt_types': 'enasarco', + 'payment_term': self.payment_term_15.id, + 'rate_ids': [(0, 0, { + 'tax': 8.25, + 'base': 1, + })] + } + self.enasarco = self.env['withholding.tax'].create(wt_vals) + + def test_e_invoice_wt(self): + self.set_sequences(13, '2019-01-07') + invoice = self.invoice_model.create({ + 'date_invoice': '2019-01-07', + 'partner_id': self.res_partner_fatturapa_2.id, + 'journal_id': self.sales_journal.id, + 'account_id': self.a_recv.id, + 'payment_term_id': self.account_payment_term.id, + 'user_id': self.user_demo.id, + 'type': 'out_invoice', + 'currency_id': self.EUR.id, + 'invoice_line_ids': [ + (0, 0, { + 'account_id': self.a_sale.id, + 'name': 'Service', + 'quantity': 1, + 'uom_id': self.product_uom_unit.id, + 'price_unit': 10, + 'invoice_line_tax_ids': [(6, 0, [self.tax_22.id])], + 'invoice_line_tax_wt_ids': [(6, 0, [self.wt1040.id])] + }), + ], + }) + invoice._onchange_invoice_line_wt_ids() + invoice.action_invoice_open() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res['res_id']) + self.set_e_invoice_file_id(attachment, 'IT06363391001_00011.xml') + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, 'IT06363391001_00011.xml', + module_name='l10n_it_fatturapa_out_wt') + + def test_e_invoice_wt_enas_0(self): + self.set_sequences(14, '2019-01-07') + invoice = self.invoice_model.create({ + 'date_invoice': '2019-01-07', + 'partner_id': self.res_partner_fatturapa_2.id, + 'journal_id': self.sales_journal.id, + 'account_id': self.a_recv.id, + 'payment_term_id': self.account_payment_term.id, + 'user_id': self.user_demo.id, + 'type': 'out_invoice', + 'currency_id': self.EUR.id, + 'invoice_line_ids': [ + (0, 0, { + 'account_id': self.a_sale.id, + 'name': 'Service', + 'quantity': 1, + 'uom_id': self.product_uom_unit.id, + 'price_unit': 10, + 'invoice_line_tax_ids': [(6, 0, [self.tax_22.id])], + 'invoice_line_tax_wt_ids': [(6, 0, [ + self.wt1040.id, + self.enasarco.id, + ])] + }), + ], + }) + invoice._onchange_invoice_line_wt_ids() + invoice.action_invoice_open() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res['res_id']) + self.set_e_invoice_file_id(attachment, 'IT06363391001_00014.xml') + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, 'IT06363391001_00014.xml', + module_name='l10n_it_fatturapa_out_wt') + + def test_e_invoice_wt_enas_1(self): + """ + Fill DatiCassaPrevidenziale with Enasarco data + """ + self.set_sequences(15, '2019-01-07') + self.enasarco.use_daticassaprev_for_enasarco = True + invoice = self.invoice_model.create({ + 'date_invoice': '2019-01-07', + 'partner_id': self.res_partner_fatturapa_2.id, + 'journal_id': self.sales_journal.id, + 'account_id': self.a_recv.id, + 'payment_term_id': self.account_payment_term.id, + 'user_id': self.user_demo.id, + 'type': 'out_invoice', + 'currency_id': self.EUR.id, + 'invoice_line_ids': [ + (0, 0, { + 'account_id': self.a_sale.id, + 'name': 'Service', + 'quantity': 1, + 'uom_id': self.product_uom_unit.id, + 'price_unit': 10, + 'invoice_line_tax_ids': [(6, 0, [self.tax_22.id])], + 'invoice_line_tax_wt_ids': [(6, 0, [ + self.wt1040.id, + self.enasarco.id, + ])] + }), + ], + }) + invoice._onchange_invoice_line_wt_ids() + invoice.action_invoice_open() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res['res_id']) + self.set_e_invoice_file_id(attachment, 'IT06363391001_00015.xml') + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, 'IT06363391001_00015.xml', + module_name='l10n_it_fatturapa_out_wt') + + def test_e_invoice_wt_enas_2(self): + """ + Fill DatiCassaPrevidenziale with Enasarco data, + when DatiRiepilogo already has 0 VAT + """ + self.set_sequences(16, '2019-01-07') + self.enasarco.use_daticassaprev_for_enasarco = True + invoice = self.invoice_model.create({ + 'date_invoice': '2019-01-07', + 'partner_id': self.res_partner_fatturapa_2.id, + 'journal_id': self.sales_journal.id, + 'account_id': self.a_recv.id, + 'payment_term_id': self.account_payment_term.id, + 'user_id': self.user_demo.id, + 'type': 'out_invoice', + 'currency_id': self.EUR.id, + 'invoice_line_ids': [ + (0, 0, { + 'account_id': self.a_sale.id, + 'name': 'Service', + 'quantity': 1, + 'uom_id': self.product_uom_unit.id, + 'price_unit': 10, + 'invoice_line_tax_ids': [(6, 0, [self.tax_0.id])], + 'invoice_line_tax_wt_ids': [(6, 0, [ + self.wt1040.id, + self.enasarco.id, + ])] + }), + ], + }) + invoice._onchange_invoice_line_wt_ids() + invoice.action_invoice_open() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res['res_id']) + self.set_e_invoice_file_id(attachment, 'IT06363391001_00016.xml') + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, 'IT06363391001_00016.xml', + module_name='l10n_it_fatturapa_out_wt') diff --git a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py index e7d9f61509e0..f12ec8c17aaf 100644 --- a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py +++ b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py @@ -6,6 +6,8 @@ from odoo.addons.l10n_it_fatturapa.bindings.fatturapa import ( DatiRitenutaType, AltriDatiGestionaliType, + DatiCassaPrevidenzialeType, + DatiRiepilogoType ) @@ -22,7 +24,7 @@ def setDatiGeneraliDocumento(self, invoice, body): _("More than one withholding tax in invoice!")) for wt_line in ritenuta_lines: if not wt_line.withholding_tax_id.causale_pagamento_id.code: - raise UserError(_('Missing causale pagamento for ' + raise UserError(_('Missing payment reason for ' 'withholding tax %s!') % wt_line.withholding_tax_id.name) body.DatiGenerali.DatiGeneraliDocumento.DatiRitenuta\ @@ -30,29 +32,88 @@ def setDatiGeneraliDocumento(self, invoice, body): TipoRitenuta="RT02" if invoice.partner_id.is_company else "RT01", # RT02 persona giuridica ImportoRitenuta='%.2f' % wt_line.tax, - AliquotaRitenuta='%.2f' % ( - wt_line.tax / wt_line.base * 100), + AliquotaRitenuta='%.2f' % wt_line.withholding_tax_id.tax, CausalePagamento=wt_line.withholding_tax_id. causale_pagamento_id.code ) + enasarco_lines = invoice.withholding_tax_line_ids.filtered( + lambda x: x.withholding_tax_id.wt_types == 'enasarco') + for enas_line in enasarco_lines: + if enas_line.withholding_tax_id.use_daticassaprev_for_enasarco: + body.DatiGenerali.DatiGeneraliDocumento.\ + DatiCassaPrevidenziale.append( + DatiCassaPrevidenzialeType( + TipoCassa='TC07', + AlCassa='%.2f' % enas_line.withholding_tax_id.tax, + ImportoContributoCassa='%.2f' % enas_line.tax, + AliquotaIVA='0.00', + Natura='N2' + ) + ) return res - def setDettaglioLinee(self, invoice, body): - res = super(WizardExportFatturapa, self).setDettaglioLinee( + def get_n2_tax_riepilogo(self, body): + for riepilogo in body.DatiBeniServizi.DatiRiepilogo: + if float(riepilogo.AliquotaIVA) == 0 and riepilogo.Natura == 'N2': + return riepilogo + + def setDatiRiepilogo(self, invoice, body): + res = super(WizardExportFatturapa, self).setDatiRiepilogo( invoice, body) - enasarco_lines = invoice.withholding_tax_line_ids.filtered( - lambda x: x.withholding_tax_id.wt_types == 'enasarco') - if len(enasarco_lines) > 1: - raise UserError( - _("More than one Enasarco tax in invoice!")) - for wt_line in enasarco_lines: - # tmp put values in the first line - # todo split values for lines with withholding type enasarco - body.DatiBeniServizi.DettaglioLinee[0].AltriDatiGestionali.append( - AltriDatiGestionaliType( - TipoDato="CASSA-PREV", - RiferimentoTesto='ENASARCO TC07', - RiferimentoNumero='%.2f' % wt_line.tax, + enasarco_lines_to_write = invoice.withholding_tax_line_ids.filtered( + lambda x: x.withholding_tax_id.wt_types == 'enasarco' and + x.withholding_tax_id.use_daticassaprev_for_enasarco + ) + if enasarco_lines_to_write: + n2_riepilogo = self.get_n2_tax_riepilogo(body) + enasarco_base = sum(enasarco_lines_to_write.mapped('tax')) + if n2_riepilogo: + base_amount = float(n2_riepilogo.ImponibileImporto) + base_amount += enasarco_base + n2_riepilogo.ImponibileImporto = '%.2f' % base_amount + else: + riepilogo = DatiRiepilogoType( + AliquotaIVA='0.00', + ImponibileImporto='%.2f' % enasarco_base, + Imposta='0.00', + Natura='N2', + RiferimentoNormativo='Escluso Art. 13 5C DPR 633/72', ) - ) + body.DatiBeniServizi.DatiRiepilogo.append(riepilogo) + return res + + def setDettaglioLinea( + self, line_no, line, body, price_precision, uom_precision + ): + DettaglioLinea = super(WizardExportFatturapa, self).setDettaglioLinea( + line_no, line, body, price_precision, uom_precision + ) + for wt in line.invoice_line_tax_wt_ids: + if wt.wt_types == 'enasarco': + amount = wt.compute_tax(line.price_subtotal)['tax'] + DettaglioLinea.AltriDatiGestionali.append( + AltriDatiGestionaliType( + TipoDato="CASSA-PREV", + RiferimentoTesto=('ENASARCO TC07 (%s%%)' % wt.tax), + RiferimentoNumero='%.2f' % amount, + ) + ) + else: + DettaglioLinea.Ritenuta = 'SI' + return DettaglioLinea + + def setDatiPagamento(self, invoice, body): + res = super(WizardExportFatturapa, self).setDatiPagamento( + invoice, body) + if invoice.withholding_tax_line_ids and invoice.payment_term_id: + payment_line_ids = invoice.get_receivable_line_ids() + index = 0 + rate = invoice.amount_net_pay / invoice.amount_total + move_line_pool = self.env['account.move.line'] + for move_line_id in payment_line_ids: + move_line = move_line_pool.browse(move_line_id) + body.DatiPagamento[0].DettaglioPagamento[index].\ + ImportoPagamento = '%.2f' % ( + (move_line.amount_currency or move_line.debit) * rate) + index += 1 return res From 81e18ff35e816cf88867896021ad57e43eeafad6 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Fri, 25 Oct 2019 09:33:08 +0000 Subject: [PATCH 06/27] [UPD] Update l10n_it_fatturapa_out_wt.pot --- l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot b/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot index ee31eee47b44..68e13a53578a 100644 --- a/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot +++ b/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot @@ -6,8 +6,6 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-10-21 10:49+0000\n" -"PO-Revision-Date: 2019-10-21 10:49+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -23,7 +21,7 @@ msgstr "" #. module: l10n_it_fatturapa_out_wt #: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:27 #, python-format -msgid "Missing causale pagamento for withholding tax %s!" +msgid "Missing payment reason for withholding tax %s!" msgstr "" #. module: l10n_it_fatturapa_out_wt From 0d7335ce457470de1b3d515059efbb98f95328b4 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Fri, 25 Oct 2019 13:14:34 +0000 Subject: [PATCH 07/27] [UPD] README.rst --- l10n_it_fatturapa_out_wt/README.rst | 16 ++++++++-------- .../static/description/index.html | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/l10n_it_fatturapa_out_wt/README.rst b/l10n_it_fatturapa_out_wt/README.rst index ba09c46a3a32..1ac3e86aa5e9 100644 --- a/l10n_it_fatturapa_out_wt/README.rst +++ b/l10n_it_fatturapa_out_wt/README.rst @@ -1,6 +1,6 @@ -================================================================== -Italian Localization - Fattura elettronica - Integrazione ritenuta -================================================================== +================================================= +ITA - Fattura elettronica - Integrazione ritenuta +================================================= .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! @@ -14,13 +14,13 @@ Italian Localization - Fattura elettronica - Integrazione ritenuta :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github - :target: https://github.com/OCA/l10n-italy/tree/10.0/l10n_it_fatturapa_out_wt + :target: https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_fatturapa_out_wt :alt: OCA/l10n-italy .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/l10n-italy-10-0/l10n-italy-10-0-l10n_it_fatturapa_out_wt + :target: https://translation.odoo-community.org/projects/l10n-italy-12-0/l10n-italy-12-0-l10n_it_fatturapa_out_wt :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/122/10.0 + :target: https://runbot.odoo-community.org/runbot/122/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -48,7 +48,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -78,6 +78,6 @@ 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/l10n-italy `_ project on GitHub. +This module is part of the `OCA/l10n-italy `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_it_fatturapa_out_wt/static/description/index.html b/l10n_it_fatturapa_out_wt/static/description/index.html index d24bd6fd5301..f5d916d0f01a 100644 --- a/l10n_it_fatturapa_out_wt/static/description/index.html +++ b/l10n_it_fatturapa_out_wt/static/description/index.html @@ -3,8 +3,8 @@ - -Italian Localization - Fattura elettronica - Integrazione ritenuta + +ITA - Fattura elettronica - Integrazione ritenuta -
-

Italian Localization - Fattura elettronica - Integrazione ritenuta

+
+

ITA - Fattura elettronica - Integrazione ritenuta

-

Beta License: LGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

+

Beta License: LGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

Italiano

Modulo ponte tra emissione fatture elettroniche e ritenute.

Con questo modulo, l’elemento XML DatiRitenuta verrà correttamente valorizzato.

@@ -391,7 +391,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -415,7 +415,7 @@

Maintainers

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/l10n-italy project on GitHub.

+

This module is part of the OCA/l10n-italy project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

From 1bcd62ffa0a1822d1158f929b7e287bdf65ab2c0 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Fri, 25 Oct 2019 13:14:42 +0000 Subject: [PATCH 08/27] l10n_it_fatturapa_out_wt 12.0.1.1.0 --- l10n_it_fatturapa_out_wt/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py index 02f8c17d08bc..106e4e164acc 100644 --- a/l10n_it_fatturapa_out_wt/__manifest__.py +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -7,7 +7,7 @@ 'name': 'ITA - Fattura elettronica - Integrazione ' 'ritenuta', 'summary': 'Modulo ponte tra emissione fatture elettroniche e ritenute.', - 'version': '12.0.1.0.0', + 'version': '12.0.1.1.0', 'development_status': 'Beta', 'category': 'Hidden', 'website': 'https://github.com/OCA/l10n-italy', From 0ef1b211831e832aaaf9d98bb76e963a98069902 Mon Sep 17 00:00:00 2001 From: eLBati Date: Tue, 14 Jan 2020 16:57:21 +0100 Subject: [PATCH 09/27] Use float_round from odoo because in python 3 "Exact halfway cases are now rounded to the nearest even result instead of away from zero". See https://docs.python.org/3/whatsnew/3.0.html#builtins Examples: >>> '%.2f' % 75.845 '75.84' >>> '%.2f' % 75.855 '75.86' >>> round(2.5) 2 >>> round(3.5) 4 --- .../wizard/wizard_export_fatturapa.py | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py index f12ec8c17aaf..a4e003f0ba15 100644 --- a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py +++ b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py @@ -3,6 +3,7 @@ from odoo import models from odoo.tools.translate import _ from odoo.exceptions import Warning as UserError +from odoo.tools.float_utils import float_round from odoo.addons.l10n_it_fatturapa.bindings.fatturapa import ( DatiRitenutaType, AltriDatiGestionaliType, @@ -31,8 +32,9 @@ def setDatiGeneraliDocumento(self, invoice, body): = DatiRitenutaType( TipoRitenuta="RT02" if invoice.partner_id.is_company else "RT01", # RT02 persona giuridica - ImportoRitenuta='%.2f' % wt_line.tax, - AliquotaRitenuta='%.2f' % wt_line.withholding_tax_id.tax, + ImportoRitenuta='%.2f' % float_round(wt_line.tax, 2), + AliquotaRitenuta='%.2f' % float_round( + wt_line.withholding_tax_id.tax, 2), CausalePagamento=wt_line.withholding_tax_id. causale_pagamento_id.code ) @@ -44,8 +46,10 @@ def setDatiGeneraliDocumento(self, invoice, body): DatiCassaPrevidenziale.append( DatiCassaPrevidenzialeType( TipoCassa='TC07', - AlCassa='%.2f' % enas_line.withholding_tax_id.tax, - ImportoContributoCassa='%.2f' % enas_line.tax, + AlCassa='%.2f' % float_round( + enas_line.withholding_tax_id.tax, 2), + ImportoContributoCassa='%.2f' % float_round( + enas_line.tax, 2), AliquotaIVA='0.00', Natura='N2' ) @@ -70,11 +74,11 @@ def setDatiRiepilogo(self, invoice, body): if n2_riepilogo: base_amount = float(n2_riepilogo.ImponibileImporto) base_amount += enasarco_base - n2_riepilogo.ImponibileImporto = '%.2f' % base_amount + n2_riepilogo.ImponibileImporto = '%.2f' % float_round(base_amount, 2) else: riepilogo = DatiRiepilogoType( AliquotaIVA='0.00', - ImponibileImporto='%.2f' % enasarco_base, + ImponibileImporto='%.2f' % float_round(enasarco_base, 2), Imposta='0.00', Natura='N2', RiferimentoNormativo='Escluso Art. 13 5C DPR 633/72', @@ -95,7 +99,7 @@ def setDettaglioLinea( AltriDatiGestionaliType( TipoDato="CASSA-PREV", RiferimentoTesto=('ENASARCO TC07 (%s%%)' % wt.tax), - RiferimentoNumero='%.2f' % amount, + RiferimentoNumero='%.2f' % float_round(amount, 2), ) ) else: @@ -113,7 +117,7 @@ def setDatiPagamento(self, invoice, body): for move_line_id in payment_line_ids: move_line = move_line_pool.browse(move_line_id) body.DatiPagamento[0].DettaglioPagamento[index].\ - ImportoPagamento = '%.2f' % ( - (move_line.amount_currency or move_line.debit) * rate) + ImportoPagamento = '%.2f' % float_round( + (move_line.amount_currency or move_line.debit) * rate, 2) index += 1 return res From 3ea693352586a89695ff7b6b0648b9bcbeecb2af Mon Sep 17 00:00:00 2001 From: oca-travis Date: Wed, 15 Jan 2020 11:09:57 +0000 Subject: [PATCH 10/27] [UPD] Update l10n_it_fatturapa_out_wt.pot --- l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot b/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot index 68e13a53578a..8975a8ab14b5 100644 --- a/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot +++ b/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot @@ -19,13 +19,13 @@ msgid "Export E-invoice" msgstr "" #. module: l10n_it_fatturapa_out_wt -#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:27 +#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:28 #, python-format msgid "Missing payment reason for withholding tax %s!" msgstr "" #. module: l10n_it_fatturapa_out_wt -#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:24 +#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:25 #, python-format msgid "More than one withholding tax in invoice!" msgstr "" From dac8e1af3769fd213021db470758e91c77bbff7f Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Wed, 15 Jan 2020 12:06:28 +0000 Subject: [PATCH 11/27] l10n_it_fatturapa_out_wt 12.0.1.1.1 --- l10n_it_fatturapa_out_wt/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py index 106e4e164acc..5e3375717a2f 100644 --- a/l10n_it_fatturapa_out_wt/__manifest__.py +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -7,7 +7,7 @@ 'name': 'ITA - Fattura elettronica - Integrazione ' 'ritenuta', 'summary': 'Modulo ponte tra emissione fatture elettroniche e ritenute.', - 'version': '12.0.1.1.0', + 'version': '12.0.1.1.1', 'development_status': 'Beta', 'category': 'Hidden', 'website': 'https://github.com/OCA/l10n-italy', From 27506801924aadfac7644417425683dfc02dfdde Mon Sep 17 00:00:00 2001 From: Lara Baggio Date: Wed, 13 May 2020 18:03:37 +0200 Subject: [PATCH 12/27] merge PR 1264 1717 1728 1737 1739 --- l10n_it_fatturapa_out_wt/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py index 5e3375717a2f..7984b17aa0ac 100644 --- a/l10n_it_fatturapa_out_wt/__manifest__.py +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -7,7 +7,7 @@ 'name': 'ITA - Fattura elettronica - Integrazione ' 'ritenuta', 'summary': 'Modulo ponte tra emissione fatture elettroniche e ritenute.', - 'version': '12.0.1.1.1', + 'version': '12.0.1.1.2', 'development_status': 'Beta', 'category': 'Hidden', 'website': 'https://github.com/OCA/l10n-italy', From 95cdbab543b697c618da959bad3d2cbef30d9a9a Mon Sep 17 00:00:00 2001 From: eLBati Date: Thu, 10 Sep 2020 16:39:49 +0200 Subject: [PATCH 13/27] FIX license compatibility --- l10n_it_fatturapa_out_wt/__manifest__.py | 2 +- l10n_it_fatturapa_out_wt/tests/__init__.py | 1 - l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py | 1 - l10n_it_fatturapa_out_wt/wizard/__init__.py | 1 - l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py | 1 - 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py index 7984b17aa0ac..abcca4cd0053 100644 --- a/l10n_it_fatturapa_out_wt/__manifest__.py +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -12,7 +12,7 @@ 'category': 'Hidden', 'website': 'https://github.com/OCA/l10n-italy', 'author': 'Sergio Corato, Odoo Community Association (OCA)', - 'license': 'LGPL-3', + 'license': 'AGPL-3', 'depends': [ 'l10n_it_fatturapa', 'l10n_it_fatturapa_out', diff --git a/l10n_it_fatturapa_out_wt/tests/__init__.py b/l10n_it_fatturapa_out_wt/tests/__init__.py index 596933ddb061..0b572b5283b1 100644 --- a/l10n_it_fatturapa_out_wt/tests/__init__.py +++ b/l10n_it_fatturapa_out_wt/tests/__init__.py @@ -1,3 +1,2 @@ -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). from . import test_fatturapa_wt diff --git a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py index 598dacd1182f..57e9f1bd2232 100644 --- a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py +++ b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py @@ -1,4 +1,3 @@ -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). import base64 from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import ( diff --git a/l10n_it_fatturapa_out_wt/wizard/__init__.py b/l10n_it_fatturapa_out_wt/wizard/__init__.py index 867b656accc2..a5be93d64228 100644 --- a/l10n_it_fatturapa_out_wt/wizard/__init__.py +++ b/l10n_it_fatturapa_out_wt/wizard/__init__.py @@ -1,3 +1,2 @@ -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). from . import wizard_export_fatturapa diff --git a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py index a4e003f0ba15..63d1c5c00cb6 100644 --- a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py +++ b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py @@ -1,4 +1,3 @@ -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). from odoo import models from odoo.tools.translate import _ From 3c2655837b74c079341b6d14ef17b803a55ec0bd Mon Sep 17 00:00:00 2001 From: oca-travis Date: Mon, 14 Sep 2020 10:11:08 +0000 Subject: [PATCH 14/27] [UPD] Update l10n_it_fatturapa_out_wt.pot --- l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot b/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot index 8975a8ab14b5..68e13a53578a 100644 --- a/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot +++ b/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot @@ -19,13 +19,13 @@ msgid "Export E-invoice" msgstr "" #. module: l10n_it_fatturapa_out_wt -#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:28 +#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:27 #, python-format msgid "Missing payment reason for withholding tax %s!" msgstr "" #. module: l10n_it_fatturapa_out_wt -#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:25 +#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:24 #, python-format msgid "More than one withholding tax in invoice!" msgstr "" From bfc01b15538d1ea2ffd1cd152ce95f02ea4416ed Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Mon, 14 Sep 2020 10:45:29 +0000 Subject: [PATCH 15/27] [UPD] README.rst --- l10n_it_fatturapa_out_wt/README.rst | 6 +++--- l10n_it_fatturapa_out_wt/static/description/index.html | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/l10n_it_fatturapa_out_wt/README.rst b/l10n_it_fatturapa_out_wt/README.rst index 1ac3e86aa5e9..cb8a5dac843d 100644 --- a/l10n_it_fatturapa_out_wt/README.rst +++ b/l10n_it_fatturapa_out_wt/README.rst @@ -10,9 +10,9 @@ ITA - Fattura elettronica - Integrazione ritenuta .. |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-LGPL--3-blue.png - :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html - :alt: License: LGPL-3 +.. |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%2Fl10n--italy-lightgray.png?logo=github :target: https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_fatturapa_out_wt :alt: OCA/l10n-italy diff --git a/l10n_it_fatturapa_out_wt/static/description/index.html b/l10n_it_fatturapa_out_wt/static/description/index.html index f5d916d0f01a..37e54814c979 100644 --- a/l10n_it_fatturapa_out_wt/static/description/index.html +++ b/l10n_it_fatturapa_out_wt/static/description/index.html @@ -367,7 +367,7 @@

ITA - Fattura elettronica - Integrazione ritenuta

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: LGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

Italiano

Modulo ponte tra emissione fatture elettroniche e ritenute.

Con questo modulo, l’elemento XML DatiRitenuta verrà correttamente valorizzato.

From 3c0e23de774f8a48fe91096e8bc25418b82a6911 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Mon, 14 Sep 2020 10:45:39 +0000 Subject: [PATCH 16/27] l10n_it_fatturapa_out_wt 12.0.1.1.3 --- l10n_it_fatturapa_out_wt/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py index abcca4cd0053..4c5507735bef 100644 --- a/l10n_it_fatturapa_out_wt/__manifest__.py +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -7,7 +7,7 @@ 'name': 'ITA - Fattura elettronica - Integrazione ' 'ritenuta', 'summary': 'Modulo ponte tra emissione fatture elettroniche e ritenute.', - 'version': '12.0.1.1.2', + 'version': '12.0.1.1.3', 'development_status': 'Beta', 'category': 'Hidden', 'website': 'https://github.com/OCA/l10n-italy', From f47888d94710fa88f10033ab16b0e711573bdcc4 Mon Sep 17 00:00:00 2001 From: Ciro Urselli Date: Fri, 11 Sep 2020 14:19:00 +0200 Subject: [PATCH 17/27] 12.0 nuovi dati ritenuta fe (#1876) * [IMP] extend wt_types selection with new code and add tax_id for daticassa * [IMP] use causale_pagamento for all withholding tax type * [IMP] improve wizard_export_fatturapa with new 1.6 xml tack specific --- .../tests/data/IT06363391001_00014.xml | 11 +- .../tests/data/IT06363391001_00015.xml | 11 +- .../tests/data/IT06363391001_00016.xml | 11 +- .../tests/data/IT06363391001_00017.xml | 109 +++++++++++++ .../tests/data/IT06363391001_00018.xml | 125 ++++++++++++++ .../tests/data/IT06363391001_00019.xml | 121 ++++++++++++++ .../tests/test_fatturapa_wt.py | 153 +++++++++++++++++- .../wizard/wizard_export_fatturapa.py | 107 ++++++------ 8 files changed, 585 insertions(+), 63 deletions(-) create mode 100644 l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00017.xml create mode 100644 l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml create mode 100644 l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml index 365f5ed0d81e..62e62d11764d 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml @@ -70,6 +70,12 @@ 20.00 A + + RT04 + 0.83 + 8.25 + A + 12.20 SI @@ -84,11 +90,6 @@ 10.00 22.00 SI - - CASSA-PREV - ENASARCO TC07 (8.25%) - 0.83 - 22.00 diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml index 9169c047d7c3..499f80b90df4 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml @@ -72,6 +72,12 @@ 20.00 A + + RT04 + 0.83 + 8.25 + A + TC07 8.25 @@ -93,11 +99,6 @@ 10.00 22.00 SI - - CASSA-PREV - ENASARCO TC07 (8.25%) - 0.83 - 22.00 diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml index ef6d31bbf1db..e4a0d31db6d5 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml @@ -71,6 +71,12 @@ 2.00 20.00 A + + + RT04 + 0.83 + 8.25 + A TC07 @@ -94,11 +100,6 @@ 0.00 SI N2 - - CASSA-PREV - ENASARCO TC07 (8.25%) - 0.83 - 0.00 diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00017.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00017.xml new file mode 100644 index 000000000000..24d061d89797 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00017.xml @@ -0,0 +1,109 @@ + + + + + IT + 06363391001 + + 00014 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0017 + + RT02 + 2.00 + 20.00 + A + + + RT03 + 0.53 + 5.25 + A + + 12.20 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 22.00 + SI + + + 22.00 + 10.00 + 2.20 + + + + TP02 + + MP05 + 2019-02-28 + 9.67 + + + + \ No newline at end of file diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml new file mode 100644 index 000000000000..9f83d464bfcf --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml @@ -0,0 +1,125 @@ + + + + + IT + 06363391001 + + 00015 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0018 + + RT02 + 2.00 + 20.00 + A + + + RT03 + 0.53 + 5.25 + A + + + TC22 + 5.25 + 0.53 + 0.00 + N2 + + 12.20 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 22.00 + SI + + + 22.00 + 10.00 + 2.20 + + + 0.00 + N2 + 0.83 + 0.00 + Escluso Art. 13 5C DPR 633/72 + + + + TP02 + + MP05 + 2019-02-28 + 9.67 + + + + \ No newline at end of file diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml new file mode 100644 index 000000000000..cb3baaf639b5 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml @@ -0,0 +1,121 @@ + + + + + IT + 06363391001 + + 00016 + FPR12 + 0000000 + + 06543534343 + info@yourcompany.example.com + + test@pec.it + + + + + IT + 06363391001 + + + YourCompany + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 07973780013 + + 07973780013 + + B2B Customer + + + + Via Roma, 1 + 16100 + Genova + AK + IT + + + + + + + TD01 + EUR + 2019-01-07 + INV/2019/0019 + + RT02 + 2.00 + 20.00 + A + + + RT03 + 0.53 + 5.25 + A + + + TC22 + 5.25 + 0.53 + 0.00 + N2 + + 10.00 + SI + + + + + 1 + Service + 1.000 + Unit(s) + 10.00000 + 10.00 + 0.00 + SI + N2 + + + 0.00 + N2 + 10.83 + 0.00 + Escluso Art. 13 5C DPR 633/72 + + + + TP02 + + MP05 + 2019-02-28 + 7.47 + + + + \ No newline at end of file diff --git a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py index 57e9f1bd2232..8d6e7369d156 100644 --- a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py +++ b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py @@ -55,12 +55,30 @@ def setUp(self): 'journal_id': self.journal_misc.id, 'wt_types': 'enasarco', 'payment_term': self.payment_term_15.id, + 'causale_pagamento_id': self.env.ref( + 'l10n_it_causali_pagamento.a').id, 'rate_ids': [(0, 0, { 'tax': 8.25, 'base': 1, })] } self.enasarco = self.env['withholding.tax'].create(wt_vals) + wt_vals = { + 'name': 'INPS', + 'code': 'INPS', + 'account_receivable_id': self.wt_account_receivable.id, + 'account_payable_id': self.wt_account_payable.id, + 'journal_id': self.journal_misc.id, + 'wt_types': 'enasarco', + 'payment_term': self.payment_term_15.id, + 'causale_pagamento_id': self.env.ref( + 'l10n_it_causali_pagamento.a').id, + 'rate_ids': [(0, 0, { + 'tax': 5.25, + 'base': 1, + })] + } + self.inps = self.env['withholding.tax'].create(wt_vals) def test_e_invoice_wt(self): self.set_sequences(13, '2019-01-07') @@ -142,7 +160,8 @@ def test_e_invoice_wt_enas_1(self): Fill DatiCassaPrevidenziale with Enasarco data """ self.set_sequences(15, '2019-01-07') - self.enasarco.use_daticassaprev_for_enasarco = True + self.enasarco.use_daticassaprev = True + self.enasarco.daticassprev_tax_id = self.tax_0 invoice = self.invoice_model.create({ 'date_invoice': '2019-01-07', 'partner_id': self.res_partner_fatturapa_2.id, @@ -186,7 +205,8 @@ def test_e_invoice_wt_enas_2(self): when DatiRiepilogo already has 0 VAT """ self.set_sequences(16, '2019-01-07') - self.enasarco.use_daticassaprev_for_enasarco = True + self.enasarco.use_daticassaprev = True + self.enasarco.daticassprev_tax_id = self.tax_0 invoice = self.invoice_model.create({ 'date_invoice': '2019-01-07', 'partner_id': self.res_partner_fatturapa_2.id, @@ -223,3 +243,132 @@ def test_e_invoice_wt_enas_2(self): self.check_content( xml_content, 'IT06363391001_00016.xml', module_name='l10n_it_fatturapa_out_wt') + +def test_e_invoice_wt_inps_0(self): + self.set_sequences(17, '2019-01-07') + invoice = self.invoice_model.create({ + 'date_invoice': '2019-01-07', + 'partner_id': self.res_partner_fatturapa_2.id, + 'journal_id': self.sales_journal.id, + 'account_id': self.a_recv.id, + 'payment_term_id': self.account_payment_term.id, + 'user_id': self.user_demo.id, + 'type': 'out_invoice', + 'currency_id': self.EUR.id, + 'invoice_line_ids': [ + (0, 0, { + 'account_id': self.a_sale.id, + 'name': 'Service', + 'quantity': 1, + 'uom_id': self.product_uom_unit.id, + 'price_unit': 10, + 'invoice_line_tax_ids': [(6, 0, [self.tax_22.id])], + 'invoice_line_tax_wt_ids': [(6, 0, [ + self.wt1040.id, + self.inps.id, + ])] + }), + ], + }) + invoice._onchange_invoice_line_wt_ids() + invoice.action_invoice_open() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res['res_id']) + self.set_e_invoice_file_id(attachment, 'IT06363391001_00017.xml') + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, 'IT06363391001_00017.xml', + module_name='l10n_it_fatturapa_out_wt') + +def test_e_invoice_wt_inps_1(self): + """ + Fill DatiCassaPrevidenziale with INPS data + """ + self.set_sequences(18, '2019-01-07') + self.inps.use_daticassaprev = True + self.inps.daticassprev_tax_id = self.tax_0 + invoice = self.invoice_model.create({ + 'date_invoice': '2019-01-07', + 'partner_id': self.res_partner_fatturapa_2.id, + 'journal_id': self.sales_journal.id, + 'account_id': self.a_recv.id, + 'payment_term_id': self.account_payment_term.id, + 'user_id': self.user_demo.id, + 'type': 'out_invoice', + 'currency_id': self.EUR.id, + 'invoice_line_ids': [ + (0, 0, { + 'account_id': self.a_sale.id, + 'name': 'Service', + 'quantity': 1, + 'uom_id': self.product_uom_unit.id, + 'price_unit': 10, + 'invoice_line_tax_ids': [(6, 0, [self.tax_22.id])], + 'invoice_line_tax_wt_ids': [(6, 0, [ + self.wt1040.id, + self.inps.id, + ])] + }), + ], + }) + invoice._onchange_invoice_line_wt_ids() + invoice.action_invoice_open() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res['res_id']) + self.set_e_invoice_file_id(attachment, 'IT06363391001_00018.xml') + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, 'IT06363391001_00018.xml', + module_name='l10n_it_fatturapa_out_wt') + +def test_e_invoice_wt_inps_2(self): + """ + Fill DatiCassaPrevidenziale with INPS data, + when DatiRiepilogo already has 0 VAT + """ + self.set_sequences(19, '2019-01-07') + self.inps.use_daticassaprev = True + self.inps.daticassprev_tax_id = self.tax_0 + invoice = self.invoice_model.create({ + 'date_invoice': '2019-01-07', + 'partner_id': self.res_partner_fatturapa_2.id, + 'journal_id': self.sales_journal.id, + 'account_id': self.a_recv.id, + 'payment_term_id': self.account_payment_term.id, + 'user_id': self.user_demo.id, + 'type': 'out_invoice', + 'currency_id': self.EUR.id, + 'invoice_line_ids': [ + (0, 0, { + 'account_id': self.a_sale.id, + 'name': 'Service', + 'quantity': 1, + 'uom_id': self.product_uom_unit.id, + 'price_unit': 10, + 'invoice_line_tax_ids': [(6, 0, [self.tax_0.id])], + 'invoice_line_tax_wt_ids': [(6, 0, [ + self.wt1040.id, + self.inps.id, + ])] + }), + ], + }) + invoice._onchange_invoice_line_wt_ids() + invoice.action_invoice_open() + res = self.run_wizard(invoice.id) + + attachment = self.attach_model.browse(res['res_id']) + self.set_e_invoice_file_id(attachment, 'IT06363391001_00019.xml') + + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, 'IT06363391001_00019.xml', + module_name='l10n_it_fatturapa_out_wt') + \ No newline at end of file diff --git a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py index 63d1c5c00cb6..5f397dfe0997 100644 --- a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py +++ b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py @@ -10,77 +10,102 @@ DatiRiepilogoType ) +WT_TAX_CODE = { + 'inps': 'RT03', + 'enasarco': 'RT04', + 'enpam': 'RT05', + 'other': 'RT06' +} + +TC_CODE = { + 'inps': 'TC22', + 'enasarco': 'TC07', + 'enpam': 'TC09', +} class WizardExportFatturapa(models.TransientModel): _inherit = "wizard.export.fatturapa" - + + def getTipoRitenuta(self, wt_types, partner): + if wt_types == 'ritenuta': + if partner.is_company: + tipoRitenuta = 'RT02' + else: + tipoRitenuta = 'RT01' + else: + tipoRitenuta = WT_TAX_CODE[wt_types] + return tipoRitenuta + def setDatiGeneraliDocumento(self, invoice, body): res = super(WizardExportFatturapa, self).setDatiGeneraliDocumento( invoice, body) - ritenuta_lines = invoice.withholding_tax_line_ids.filtered( - lambda x: x.withholding_tax_id.wt_types == 'ritenuta') - if len(ritenuta_lines) > 1: - raise UserError( - _("More than one withholding tax in invoice!")) + ritenuta_lines = invoice.withholding_tax_line_ids + # if len(ritenuta_lines) > 1: + # raise UserError( + # _("More than one withholding tax in invoice!")) for wt_line in ritenuta_lines: if not wt_line.withholding_tax_id.causale_pagamento_id.code: raise UserError(_('Missing payment reason for ' 'withholding tax %s!') % wt_line.withholding_tax_id.name) - body.DatiGenerali.DatiGeneraliDocumento.DatiRitenuta\ - = DatiRitenutaType( - TipoRitenuta="RT02" if invoice.partner_id.is_company - else "RT01", # RT02 persona giuridica + tipoRitenuta = self.getTipoRitenuta( + wt_line.withholding_tax_id.wt_types, + invoice.partner_id + ) + body.DatiGenerali.DatiGeneraliDocumento.DatiRitenuta.append( + DatiRitenutaType( + TipoRitenuta=tipoRitenuta, ImportoRitenuta='%.2f' % float_round(wt_line.tax, 2), AliquotaRitenuta='%.2f' % float_round( wt_line.withholding_tax_id.tax, 2), CausalePagamento=wt_line.withholding_tax_id. causale_pagamento_id.code - ) - enasarco_lines = invoice.withholding_tax_line_ids.filtered( - lambda x: x.withholding_tax_id.wt_types == 'enasarco') - for enas_line in enasarco_lines: - if enas_line.withholding_tax_id.use_daticassaprev_for_enasarco: + )) + if wt_line.withholding_tax_id.use_daticassaprev: + tax_id = wt_line.withholding_tax_id.daticassprev_tax_id + tax_kind = tax_id.kind_id.code body.DatiGenerali.DatiGeneraliDocumento.\ DatiCassaPrevidenziale.append( DatiCassaPrevidenzialeType( - TipoCassa='TC07', + TipoCassa=TC_CODE[wt_line.withholding_tax_id.wt_types], AlCassa='%.2f' % float_round( - enas_line.withholding_tax_id.tax, 2), + wt_line.withholding_tax_id.tax, 2), ImportoContributoCassa='%.2f' % float_round( - enas_line.tax, 2), + wt_line.tax, 2), AliquotaIVA='0.00', - Natura='N2' + Natura=tax_kind, ) ) return res - def get_n2_tax_riepilogo(self, body): + def get_tax_riepilogo(self, body, tax_id): for riepilogo in body.DatiBeniServizi.DatiRiepilogo: - if float(riepilogo.AliquotaIVA) == 0 and riepilogo.Natura == 'N2': + if float(riepilogo.AliquotaIVA) == 0.0 \ + and riepilogo.Natura == tax_id.kind_id.code: return riepilogo def setDatiRiepilogo(self, invoice, body): res = super(WizardExportFatturapa, self).setDatiRiepilogo( invoice, body) - enasarco_lines_to_write = invoice.withholding_tax_line_ids.filtered( - lambda x: x.withholding_tax_id.wt_types == 'enasarco' and - x.withholding_tax_id.use_daticassaprev_for_enasarco + wt_lines_to_write = invoice.withholding_tax_line_ids.filtered( + lambda x: x.withholding_tax_id.wt_types not in ('ritenuta', 'other') + and x.withholding_tax_id.use_daticassaprev ) - if enasarco_lines_to_write: - n2_riepilogo = self.get_n2_tax_riepilogo(body) - enasarco_base = sum(enasarco_lines_to_write.mapped('tax')) - if n2_riepilogo: - base_amount = float(n2_riepilogo.ImponibileImporto) - base_amount += enasarco_base - n2_riepilogo.ImponibileImporto = '%.2f' % float_round(base_amount, 2) + for wt_line in wt_lines_to_write: + tax_id = wt_line.withholding_tax_id.daticassprev_tax_id + tax_riepilogo = self.get_tax_riepilogo(body, tax_id) + if tax_riepilogo: + base_amount = float(tax_riepilogo.ImponibileImporto) + base_amount += wt_line.tax + tax_riepilogo.ImponibileImporto = '%.2f' % float_round( + base_amount, 2) else: riepilogo = DatiRiepilogoType( AliquotaIVA='0.00', - ImponibileImporto='%.2f' % float_round(enasarco_base, 2), + ImponibileImporto='%.2f' % float_round(wt_line.tax, 2), Imposta='0.00', - Natura='N2', - RiferimentoNormativo='Escluso Art. 13 5C DPR 633/72', + Natura=tax_id.kind_id.code, + RiferimentoNormativo=tax_id.law_reference, ) body.DatiBeniServizi.DatiRiepilogo.append(riepilogo) return res @@ -91,18 +116,8 @@ def setDettaglioLinea( DettaglioLinea = super(WizardExportFatturapa, self).setDettaglioLinea( line_no, line, body, price_precision, uom_precision ) - for wt in line.invoice_line_tax_wt_ids: - if wt.wt_types == 'enasarco': - amount = wt.compute_tax(line.price_subtotal)['tax'] - DettaglioLinea.AltriDatiGestionali.append( - AltriDatiGestionaliType( - TipoDato="CASSA-PREV", - RiferimentoTesto=('ENASARCO TC07 (%s%%)' % wt.tax), - RiferimentoNumero='%.2f' % float_round(amount, 2), - ) - ) - else: - DettaglioLinea.Ritenuta = 'SI' + if any([wt for wt in line.invoice_line_tax_wt_ids]): + DettaglioLinea.Ritenuta = 'SI' return DettaglioLinea def setDatiPagamento(self, invoice, body): From bb12b9c5fc72904f47f28b9915ce6eee8ed2d278 Mon Sep 17 00:00:00 2001 From: Sergio Corato Date: Fri, 18 Sep 2020 12:31:00 +0200 Subject: [PATCH 18/27] [12.0][FIX] fatturapa withholding tax invoice received e-invoice 1.6 (#1878) * [12.0][FIX] fatturapa withholding tax invoice received - e-invoice 1.6 * [FIX] l10n_it_fatturapa_out_wt pep8 fixes This reverts commit 421ef9e51634383263638e9b52ea4038829f62ec. * [IMP] migration script * [FIX] l10n_it_fatturapa_out_wt: Fixed ordering in DatiRitenuta generation, according to XML test file. Otherwise: 2020-09-17 07:34:14,789 7808 ERROR openerp_test odoo.addons.l10n_it_fatturapa_out_wt.tests.test_fatturapa_wt: ` AssertionError: b'RT022.00' != b'RT040.83' Co-authored-by: SimoRubi --- .../tests/test_fatturapa_wt.py | 22 ++++++++++--------- .../wizard/wizard_export_fatturapa.py | 17 +++++++------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py index 8d6e7369d156..bb975efe5a3d 100644 --- a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py +++ b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py @@ -58,9 +58,9 @@ def setUp(self): 'causale_pagamento_id': self.env.ref( 'l10n_it_causali_pagamento.a').id, 'rate_ids': [(0, 0, { - 'tax': 8.25, - 'base': 1, - })] + 'tax': 8.25, + 'base': 1, + })] } self.enasarco = self.env['withholding.tax'].create(wt_vals) wt_vals = { @@ -74,9 +74,9 @@ def setUp(self): 'causale_pagamento_id': self.env.ref( 'l10n_it_causali_pagamento.a').id, 'rate_ids': [(0, 0, { - 'tax': 5.25, - 'base': 1, - })] + 'tax': 5.25, + 'base': 1, + })] } self.inps = self.env['withholding.tax'].create(wt_vals) @@ -243,7 +243,8 @@ def test_e_invoice_wt_enas_2(self): self.check_content( xml_content, 'IT06363391001_00016.xml', module_name='l10n_it_fatturapa_out_wt') - + + def test_e_invoice_wt_inps_0(self): self.set_sequences(17, '2019-01-07') invoice = self.invoice_model.create({ @@ -282,7 +283,8 @@ def test_e_invoice_wt_inps_0(self): self.check_content( xml_content, 'IT06363391001_00017.xml', module_name='l10n_it_fatturapa_out_wt') - + + def test_e_invoice_wt_inps_1(self): """ Fill DatiCassaPrevidenziale with INPS data @@ -326,7 +328,8 @@ def test_e_invoice_wt_inps_1(self): self.check_content( xml_content, 'IT06363391001_00018.xml', module_name='l10n_it_fatturapa_out_wt') - + + def test_e_invoice_wt_inps_2(self): """ Fill DatiCassaPrevidenziale with INPS data, @@ -371,4 +374,3 @@ def test_e_invoice_wt_inps_2(self): self.check_content( xml_content, 'IT06363391001_00019.xml', module_name='l10n_it_fatturapa_out_wt') - \ No newline at end of file diff --git a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py index 5f397dfe0997..3fed0f0cd457 100644 --- a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py +++ b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py @@ -5,7 +5,6 @@ from odoo.tools.float_utils import float_round from odoo.addons.l10n_it_fatturapa.bindings.fatturapa import ( DatiRitenutaType, - AltriDatiGestionaliType, DatiCassaPrevidenzialeType, DatiRiepilogoType ) @@ -23,9 +22,10 @@ 'enpam': 'TC09', } + class WizardExportFatturapa(models.TransientModel): _inherit = "wizard.export.fatturapa" - + def getTipoRitenuta(self, wt_types, partner): if wt_types == 'ritenuta': if partner.is_company: @@ -35,14 +35,13 @@ def getTipoRitenuta(self, wt_types, partner): else: tipoRitenuta = WT_TAX_CODE[wt_types] return tipoRitenuta - + def setDatiGeneraliDocumento(self, invoice, body): res = super(WizardExportFatturapa, self).setDatiGeneraliDocumento( invoice, body) - ritenuta_lines = invoice.withholding_tax_line_ids - # if len(ritenuta_lines) > 1: - # raise UserError( - # _("More than one withholding tax in invoice!")) + # Get consistent ordering for file generation for compare with test XML + ritenuta_lines = invoice.withholding_tax_line_ids.sorted( + key=lambda l: l.withholding_tax_id.code) for wt_line in ritenuta_lines: if not wt_line.withholding_tax_id.causale_pagamento_id.code: raise UserError(_('Missing payment reason for ' @@ -81,14 +80,14 @@ def setDatiGeneraliDocumento(self, invoice, body): def get_tax_riepilogo(self, body, tax_id): for riepilogo in body.DatiBeniServizi.DatiRiepilogo: if float(riepilogo.AliquotaIVA) == 0.0 \ - and riepilogo.Natura == tax_id.kind_id.code: + and riepilogo.Natura == tax_id.kind_id.code: return riepilogo def setDatiRiepilogo(self, invoice, body): res = super(WizardExportFatturapa, self).setDatiRiepilogo( invoice, body) wt_lines_to_write = invoice.withholding_tax_line_ids.filtered( - lambda x: x.withholding_tax_id.wt_types not in ('ritenuta', 'other') + lambda x: x.withholding_tax_id.wt_types not in ('ritenuta', 'other') and x.withholding_tax_id.use_daticassaprev ) for wt_line in wt_lines_to_write: From d8b55f48aeb5223d4211589c3b0ed362e9419e03 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Fri, 2 Oct 2020 13:46:34 +0000 Subject: [PATCH 19/27] [UPD] Update l10n_it_fatturapa_out_wt.pot --- .../i18n/l10n_it_fatturapa_out_wt.pot | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot b/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot index 68e13a53578a..92b3c46337c4 100644 --- a/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot +++ b/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot @@ -19,14 +19,8 @@ msgid "Export E-invoice" msgstr "" #. module: l10n_it_fatturapa_out_wt -#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:27 +#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:47 #, python-format msgid "Missing payment reason for withholding tax %s!" msgstr "" -#. module: l10n_it_fatturapa_out_wt -#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:24 -#, python-format -msgid "More than one withholding tax in invoice!" -msgstr "" - From 1bde3500c8012104f14023fe1e42283647f134db Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Fri, 2 Oct 2020 14:23:50 +0000 Subject: [PATCH 20/27] l10n_it_fatturapa_out_wt 12.0.2.0.0 --- l10n_it_fatturapa_out_wt/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py index 4c5507735bef..e784fcba3ad1 100644 --- a/l10n_it_fatturapa_out_wt/__manifest__.py +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -7,7 +7,7 @@ 'name': 'ITA - Fattura elettronica - Integrazione ' 'ritenuta', 'summary': 'Modulo ponte tra emissione fatture elettroniche e ritenute.', - 'version': '12.0.1.1.3', + 'version': '12.0.2.0.0', 'development_status': 'Beta', 'category': 'Hidden', 'website': 'https://github.com/OCA/l10n-italy', From 7b79cff8ae49c9aee4c8b0d79d2f8ed8792cf49a Mon Sep 17 00:00:00 2001 From: sergiocorato Date: Thu, 4 Feb 2021 12:42:57 +0100 Subject: [PATCH 21/27] [FIX] demo nature data remove no more selectable --- .../tests/data/IT06363391001_00015.xml | 6 +++--- .../tests/data/IT06363391001_00016.xml | 8 ++++---- .../tests/data/IT06363391001_00018.xml | 6 +++--- .../tests/data/IT06363391001_00019.xml | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml index 499f80b90df4..1c71b747f7e8 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml @@ -83,7 +83,7 @@ 8.25 0.83 0.00 - N2 + N2.2 12.20 SI @@ -107,7 +107,7 @@ 0.00 - N2 + N2.2 0.83 0.00 Escluso Art. 13 5C DPR 633/72 @@ -122,4 +122,4 @@ - \ No newline at end of file + diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml index e4a0d31db6d5..aedfe4b84235 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml @@ -83,7 +83,7 @@ 8.25 0.83 0.00 - N2 + N2.2 10.00 SI @@ -99,11 +99,11 @@ 10.00 0.00 SI - N2 + N2.2 0.00 - N2 + N2.2 10.83 0.00 Escluso Art. 13 5C DPR 633/72 @@ -118,4 +118,4 @@ - \ No newline at end of file + diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml index 9f83d464bfcf..8c0ee6a0ad2f 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml @@ -83,7 +83,7 @@ 5.25 0.53 0.00 - N2 + N2.2 12.20 SI @@ -107,7 +107,7 @@ 0.00 - N2 + N2.2 0.83 0.00 Escluso Art. 13 5C DPR 633/72 @@ -122,4 +122,4 @@ - \ No newline at end of file + diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml index cb3baaf639b5..b7371ebfed45 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml @@ -83,7 +83,7 @@ 5.25 0.53 0.00 - N2 + N2.2 10.00 SI @@ -99,11 +99,11 @@ 10.00 0.00 SI - N2 + N2.2 0.00 - N2 + N2.2 10.83 0.00 Escluso Art. 13 5C DPR 633/72 @@ -118,4 +118,4 @@ - \ No newline at end of file + From 5c7bd0ab805c738a428b0c53186699b2fcb63e60 Mon Sep 17 00:00:00 2001 From: Sergio Corato Date: Mon, 31 May 2021 17:25:37 +0000 Subject: [PATCH 22/27] Added translation using Weblate (Italian) --- l10n_it_fatturapa_out_wt/i18n/it.po | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 l10n_it_fatturapa_out_wt/i18n/it.po diff --git a/l10n_it_fatturapa_out_wt/i18n/it.po b/l10n_it_fatturapa_out_wt/i18n/it.po new file mode 100644 index 000000000000..a9e84217b808 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/i18n/it.po @@ -0,0 +1,26 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_fatturapa_out_wt +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#. module: l10n_it_fatturapa_out_wt +#: model:ir.model,name:l10n_it_fatturapa_out_wt.model_wizard_export_fatturapa +msgid "Export E-invoice" +msgstr "" + +#. module: l10n_it_fatturapa_out_wt +#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:47 +#, python-format +msgid "Missing payment reason for withholding tax %s!" +msgstr "" From 7a8b441bdb25488d4f38453f01e21d1fc6f734f3 Mon Sep 17 00:00:00 2001 From: Sergio Corato Date: Mon, 31 May 2021 17:26:26 +0000 Subject: [PATCH 23/27] Translated using Weblate (Italian) Currently translated at 100.0% (2 of 2 strings) Translation: l10n-italy-12.0/l10n-italy-12.0-l10n_it_fatturapa_out_wt Translate-URL: https://translation.odoo-community.org/projects/l10n-italy-12-0/l10n-italy-12-0-l10n_it_fatturapa_out_wt/it/ --- l10n_it_fatturapa_out_wt/i18n/it.po | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/l10n_it_fatturapa_out_wt/i18n/it.po b/l10n_it_fatturapa_out_wt/i18n/it.po index a9e84217b808..ff89d7dc2134 100644 --- a/l10n_it_fatturapa_out_wt/i18n/it.po +++ b/l10n_it_fatturapa_out_wt/i18n/it.po @@ -6,21 +6,23 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2021-05-31 19:48+0000\n" +"Last-Translator: Sergio Corato \n" "Language-Team: none\n" "Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" #. module: l10n_it_fatturapa_out_wt #: model:ir.model,name:l10n_it_fatturapa_out_wt.model_wizard_export_fatturapa msgid "Export E-invoice" -msgstr "" +msgstr "Esporta E-fattura" #. module: l10n_it_fatturapa_out_wt #: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:47 #, python-format msgid "Missing payment reason for withholding tax %s!" -msgstr "" +msgstr "Causale di pagamento mancante per la ritenuta d'acconto %s!" From b6dc8d79de8569ac989b6c6ea868c38655804916 Mon Sep 17 00:00:00 2001 From: Ciro Urselli Date: Fri, 6 Aug 2021 09:50:47 +0200 Subject: [PATCH 24/27] [IMP] : black, isort, prettier --- l10n_it_fatturapa_out_wt/__manifest__.py | 33 +- l10n_it_fatturapa_out_wt/tests/__init__.py | 1 - .../tests/data/IT06363391001_00011.xml | 5 +- .../tests/data/IT06363391001_00014.xml | 7 +- .../tests/data/IT06363391001_00015.xml | 8 +- .../tests/data/IT06363391001_00016.xml | 8 +- .../tests/data/IT06363391001_00017.xml | 7 +- .../tests/data/IT06363391001_00018.xml | 8 +- .../tests/data/IT06363391001_00019.xml | 8 +- .../tests/test_fatturapa_wt.py | 695 ++++++++++-------- l10n_it_fatturapa_out_wt/wizard/__init__.py | 1 - .../wizard/wizard_export_fatturapa.py | 117 ++- .../odoo/addons/l10n_it_fatturapa_out_wt | 1 + setup/l10n_it_fatturapa_out_wt/setup.py | 6 + 14 files changed, 510 insertions(+), 395 deletions(-) create mode 120000 setup/l10n_it_fatturapa_out_wt/odoo/addons/l10n_it_fatturapa_out_wt create mode 100644 setup/l10n_it_fatturapa_out_wt/setup.py diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py index e784fcba3ad1..ceeb5720521e 100644 --- a/l10n_it_fatturapa_out_wt/__manifest__.py +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -4,22 +4,21 @@ # Copyright 2018-2019 Lorenzo Battistini # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { - 'name': 'ITA - Fattura elettronica - Integrazione ' - 'ritenuta', - 'summary': 'Modulo ponte tra emissione fatture elettroniche e ritenute.', - 'version': '12.0.2.0.0', - 'development_status': 'Beta', - 'category': 'Hidden', - 'website': 'https://github.com/OCA/l10n-italy', - 'author': 'Sergio Corato, Odoo Community Association (OCA)', - 'license': 'AGPL-3', - 'depends': [ - 'l10n_it_fatturapa', - 'l10n_it_fatturapa_out', - 'l10n_it_withholding_tax', - 'l10n_it_withholding_tax_causali', + "name": "ITA - Fattura elettronica - Integrazione " "ritenuta", + "summary": "Modulo ponte tra emissione fatture elettroniche e ritenute.", + "version": "12.0.2.0.0", + "development_status": "Beta", + "category": "Hidden", + "website": "https://github.com/OCA/l10n-italy", + "author": "Sergio Corato, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": [ + "l10n_it_fatturapa", + "l10n_it_fatturapa_out", + "l10n_it_withholding_tax", + "l10n_it_withholding_tax_causali", ], - 'data': [], - 'installable': True, - 'auto_install': True, + "data": [], + "installable": True, + "auto_install": True, } diff --git a/l10n_it_fatturapa_out_wt/tests/__init__.py b/l10n_it_fatturapa_out_wt/tests/__init__.py index 0b572b5283b1..b980725c5efc 100644 --- a/l10n_it_fatturapa_out_wt/tests/__init__.py +++ b/l10n_it_fatturapa_out_wt/tests/__init__.py @@ -1,2 +1 @@ - from . import test_fatturapa_wt diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00011.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00011.xml index 750a2cf681ee..3fd495be61f7 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00011.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00011.xml @@ -1,4 +1,7 @@ - + diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml index 62e62d11764d..98e59404a04c 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00014.xml @@ -1,4 +1,7 @@ - + @@ -106,4 +109,4 @@ - \ No newline at end of file + diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml index 1c71b747f7e8..10540db330ee 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00015.xml @@ -1,6 +1,7 @@ + xmlns:ns1="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" + versione="FPR12" +> @@ -110,7 +111,8 @@ N2.2 0.83 0.00 - Escluso Art. 13 5C DPR 633/72 + Escluso Art. 13 5C DPR 633/72 diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml index aedfe4b84235..b681bab41589 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00016.xml @@ -1,6 +1,7 @@ + xmlns:ns1="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" + versione="FPR12" +> @@ -106,7 +107,8 @@ N2.2 10.83 0.00 - Escluso Art. 13 5C DPR 633/72 + Escluso Art. 13 5C DPR 633/72 diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00017.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00017.xml index 24d061d89797..8085a287fea8 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00017.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00017.xml @@ -1,4 +1,7 @@ - + @@ -106,4 +109,4 @@ - \ No newline at end of file + diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml index 8c0ee6a0ad2f..17e4438e7fa7 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00018.xml @@ -1,6 +1,7 @@ + xmlns:ns1="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" + versione="FPR12" +> @@ -110,7 +111,8 @@ N2.2 0.83 0.00 - Escluso Art. 13 5C DPR 633/72 + Escluso Art. 13 5C DPR 633/72 diff --git a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml index b7371ebfed45..2121e0b77bd5 100644 --- a/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml +++ b/l10n_it_fatturapa_out_wt/tests/data/IT06363391001_00019.xml @@ -1,6 +1,7 @@ + xmlns:ns1="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" + versione="FPR12" +> @@ -106,7 +107,8 @@ N2.2 10.83 0.00 - Escluso Art. 13 5C DPR 633/72 + Escluso Art. 13 5C DPR 633/72 diff --git a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py index bb975efe5a3d..fb473b7ecf65 100644 --- a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py +++ b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py @@ -1,376 +1,479 @@ - import base64 -from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import ( - FatturaPACommon) +from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import FatturaPACommon -class TestInvoiceWT(FatturaPACommon): +class TestInvoiceWT(FatturaPACommon): def setUp(self): super(TestInvoiceWT, self).setUp() - type_payable = self.env.ref('account.data_account_type_payable') - type_receivable = self.env.ref('account.data_account_type_receivable') - self.tax_0 = self.env.ref('l10n_it_fatturapa.tax_00_enas') - self.wt_account_payable = self.env['account.account'].create({ - 'name': 'Debiti per ritenute da versare', - 'code': 'WT_001', - 'user_type_id': type_payable.id, - 'reconcile': True, - }) - self.wt_account_receivable = self.env['account.account'].create({ - 'name': 'Crediti per ritenute subite', - 'code': 'WT_002', - 'user_type_id': type_receivable.id, - 'reconcile': True, - }) - self.journal_misc = self.env['account.journal'].search( - [('type', '=', 'general')])[0] - vals_payment = { - 'name': "", - 'line_ids': [(0, 0, {'value': 'balance', 'days': 15})] + type_payable = self.env.ref("account.data_account_type_payable") + type_receivable = self.env.ref("account.data_account_type_receivable") + self.tax_0 = self.env.ref("l10n_it_fatturapa.tax_00_enas") + self.wt_account_payable = self.env["account.account"].create( + { + "name": "Debiti per ritenute da versare", + "code": "WT_001", + "user_type_id": type_payable.id, + "reconcile": True, + } + ) + self.wt_account_receivable = self.env["account.account"].create( + { + "name": "Crediti per ritenute subite", + "code": "WT_002", + "user_type_id": type_receivable.id, + "reconcile": True, } - self.payment_term_15 = self.env['account.payment.term'].create( - vals_payment) + ) + self.journal_misc = self.env["account.journal"].search( + [("type", "=", "general")] + )[0] + vals_payment = { + "name": "", + "line_ids": [(0, 0, {"value": "balance", "days": 15})], + } + self.payment_term_15 = self.env["account.payment.term"].create(vals_payment) wt_vals = { - 'name': 'Code 1040', - 'code': '1040', - 'certification': True, - 'account_receivable_id': self.wt_account_receivable.id, - 'account_payable_id': self.wt_account_payable.id, - 'journal_id': self.journal_misc.id, - 'payment_term': self.payment_term_15.id, - 'causale_pagamento_id': self.env.ref( - 'l10n_it_causali_pagamento.a').id, - 'rate_ids': [(0, 0, { - 'tax': 20, - 'base': 1, - })] + "name": "Code 1040", + "code": "1040", + "certification": True, + "account_receivable_id": self.wt_account_receivable.id, + "account_payable_id": self.wt_account_payable.id, + "journal_id": self.journal_misc.id, + "payment_term": self.payment_term_15.id, + "causale_pagamento_id": self.env.ref("l10n_it_causali_pagamento.a").id, + "rate_ids": [ + ( + 0, + 0, + { + "tax": 20, + "base": 1, + }, + ) + ], } - self.wt1040 = self.env['withholding.tax'].create(wt_vals) + self.wt1040 = self.env["withholding.tax"].create(wt_vals) wt_vals = { - 'name': 'Enasarco', - 'code': 'Enasarco', - 'account_receivable_id': self.wt_account_receivable.id, - 'account_payable_id': self.wt_account_payable.id, - 'journal_id': self.journal_misc.id, - 'wt_types': 'enasarco', - 'payment_term': self.payment_term_15.id, - 'causale_pagamento_id': self.env.ref( - 'l10n_it_causali_pagamento.a').id, - 'rate_ids': [(0, 0, { - 'tax': 8.25, - 'base': 1, - })] - } - self.enasarco = self.env['withholding.tax'].create(wt_vals) + "name": "Enasarco", + "code": "Enasarco", + "account_receivable_id": self.wt_account_receivable.id, + "account_payable_id": self.wt_account_payable.id, + "journal_id": self.journal_misc.id, + "wt_types": "enasarco", + "payment_term": self.payment_term_15.id, + "causale_pagamento_id": self.env.ref("l10n_it_causali_pagamento.a").id, + "rate_ids": [ + ( + 0, + 0, + { + "tax": 8.25, + "base": 1, + }, + ) + ], + } + self.enasarco = self.env["withholding.tax"].create(wt_vals) wt_vals = { - 'name': 'INPS', - 'code': 'INPS', - 'account_receivable_id': self.wt_account_receivable.id, - 'account_payable_id': self.wt_account_payable.id, - 'journal_id': self.journal_misc.id, - 'wt_types': 'enasarco', - 'payment_term': self.payment_term_15.id, - 'causale_pagamento_id': self.env.ref( - 'l10n_it_causali_pagamento.a').id, - 'rate_ids': [(0, 0, { - 'tax': 5.25, - 'base': 1, - })] - } - self.inps = self.env['withholding.tax'].create(wt_vals) + "name": "INPS", + "code": "INPS", + "account_receivable_id": self.wt_account_receivable.id, + "account_payable_id": self.wt_account_payable.id, + "journal_id": self.journal_misc.id, + "wt_types": "enasarco", + "payment_term": self.payment_term_15.id, + "causale_pagamento_id": self.env.ref("l10n_it_causali_pagamento.a").id, + "rate_ids": [ + ( + 0, + 0, + { + "tax": 5.25, + "base": 1, + }, + ) + ], + } + self.inps = self.env["withholding.tax"].create(wt_vals) def test_e_invoice_wt(self): - self.set_sequences(13, '2019-01-07') - invoice = self.invoice_model.create({ - 'date_invoice': '2019-01-07', - 'partner_id': self.res_partner_fatturapa_2.id, - 'journal_id': self.sales_journal.id, - 'account_id': self.a_recv.id, - 'payment_term_id': self.account_payment_term.id, - 'user_id': self.user_demo.id, - 'type': 'out_invoice', - 'currency_id': self.EUR.id, - 'invoice_line_ids': [ - (0, 0, { - 'account_id': self.a_sale.id, - 'name': 'Service', - 'quantity': 1, - 'uom_id': self.product_uom_unit.id, - 'price_unit': 10, - 'invoice_line_tax_ids': [(6, 0, [self.tax_22.id])], - 'invoice_line_tax_wt_ids': [(6, 0, [self.wt1040.id])] - }), - ], - }) + self.set_sequences(13, "2019-01-07") + invoice = self.invoice_model.create( + { + "date_invoice": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "account_id": self.a_recv.id, + "payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "uom_id": self.product_uom_unit.id, + "price_unit": 10, + "invoice_line_tax_ids": [(6, 0, [self.tax_22.id])], + "invoice_line_tax_wt_ids": [(6, 0, [self.wt1040.id])], + }, + ), + ], + } + ) invoice._onchange_invoice_line_wt_ids() invoice.action_invoice_open() res = self.run_wizard(invoice.id) - attachment = self.attach_model.browse(res['res_id']) - self.set_e_invoice_file_id(attachment, 'IT06363391001_00011.xml') + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00011.xml") # XML doc to be validated xml_content = base64.decodebytes(attachment.datas) self.check_content( - xml_content, 'IT06363391001_00011.xml', - module_name='l10n_it_fatturapa_out_wt') + xml_content, + "IT06363391001_00011.xml", + module_name="l10n_it_fatturapa_out_wt", + ) def test_e_invoice_wt_enas_0(self): - self.set_sequences(14, '2019-01-07') - invoice = self.invoice_model.create({ - 'date_invoice': '2019-01-07', - 'partner_id': self.res_partner_fatturapa_2.id, - 'journal_id': self.sales_journal.id, - 'account_id': self.a_recv.id, - 'payment_term_id': self.account_payment_term.id, - 'user_id': self.user_demo.id, - 'type': 'out_invoice', - 'currency_id': self.EUR.id, - 'invoice_line_ids': [ - (0, 0, { - 'account_id': self.a_sale.id, - 'name': 'Service', - 'quantity': 1, - 'uom_id': self.product_uom_unit.id, - 'price_unit': 10, - 'invoice_line_tax_ids': [(6, 0, [self.tax_22.id])], - 'invoice_line_tax_wt_ids': [(6, 0, [ - self.wt1040.id, - self.enasarco.id, - ])] - }), - ], - }) + self.set_sequences(14, "2019-01-07") + invoice = self.invoice_model.create( + { + "date_invoice": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "account_id": self.a_recv.id, + "payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "uom_id": self.product_uom_unit.id, + "price_unit": 10, + "invoice_line_tax_ids": [(6, 0, [self.tax_22.id])], + "invoice_line_tax_wt_ids": [ + ( + 6, + 0, + [ + self.wt1040.id, + self.enasarco.id, + ], + ) + ], + }, + ), + ], + } + ) invoice._onchange_invoice_line_wt_ids() invoice.action_invoice_open() res = self.run_wizard(invoice.id) - attachment = self.attach_model.browse(res['res_id']) - self.set_e_invoice_file_id(attachment, 'IT06363391001_00014.xml') + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00014.xml") # XML doc to be validated xml_content = base64.decodebytes(attachment.datas) self.check_content( - xml_content, 'IT06363391001_00014.xml', - module_name='l10n_it_fatturapa_out_wt') + xml_content, + "IT06363391001_00014.xml", + module_name="l10n_it_fatturapa_out_wt", + ) def test_e_invoice_wt_enas_1(self): """ Fill DatiCassaPrevidenziale with Enasarco data """ - self.set_sequences(15, '2019-01-07') + self.set_sequences(15, "2019-01-07") self.enasarco.use_daticassaprev = True self.enasarco.daticassprev_tax_id = self.tax_0 - invoice = self.invoice_model.create({ - 'date_invoice': '2019-01-07', - 'partner_id': self.res_partner_fatturapa_2.id, - 'journal_id': self.sales_journal.id, - 'account_id': self.a_recv.id, - 'payment_term_id': self.account_payment_term.id, - 'user_id': self.user_demo.id, - 'type': 'out_invoice', - 'currency_id': self.EUR.id, - 'invoice_line_ids': [ - (0, 0, { - 'account_id': self.a_sale.id, - 'name': 'Service', - 'quantity': 1, - 'uom_id': self.product_uom_unit.id, - 'price_unit': 10, - 'invoice_line_tax_ids': [(6, 0, [self.tax_22.id])], - 'invoice_line_tax_wt_ids': [(6, 0, [ - self.wt1040.id, - self.enasarco.id, - ])] - }), - ], - }) + invoice = self.invoice_model.create( + { + "date_invoice": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "account_id": self.a_recv.id, + "payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "uom_id": self.product_uom_unit.id, + "price_unit": 10, + "invoice_line_tax_ids": [(6, 0, [self.tax_22.id])], + "invoice_line_tax_wt_ids": [ + ( + 6, + 0, + [ + self.wt1040.id, + self.enasarco.id, + ], + ) + ], + }, + ), + ], + } + ) invoice._onchange_invoice_line_wt_ids() invoice.action_invoice_open() res = self.run_wizard(invoice.id) - attachment = self.attach_model.browse(res['res_id']) - self.set_e_invoice_file_id(attachment, 'IT06363391001_00015.xml') + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00015.xml") # XML doc to be validated xml_content = base64.decodebytes(attachment.datas) self.check_content( - xml_content, 'IT06363391001_00015.xml', - module_name='l10n_it_fatturapa_out_wt') + xml_content, + "IT06363391001_00015.xml", + module_name="l10n_it_fatturapa_out_wt", + ) def test_e_invoice_wt_enas_2(self): """ Fill DatiCassaPrevidenziale with Enasarco data, when DatiRiepilogo already has 0 VAT """ - self.set_sequences(16, '2019-01-07') + self.set_sequences(16, "2019-01-07") self.enasarco.use_daticassaprev = True self.enasarco.daticassprev_tax_id = self.tax_0 - invoice = self.invoice_model.create({ - 'date_invoice': '2019-01-07', - 'partner_id': self.res_partner_fatturapa_2.id, - 'journal_id': self.sales_journal.id, - 'account_id': self.a_recv.id, - 'payment_term_id': self.account_payment_term.id, - 'user_id': self.user_demo.id, - 'type': 'out_invoice', - 'currency_id': self.EUR.id, - 'invoice_line_ids': [ - (0, 0, { - 'account_id': self.a_sale.id, - 'name': 'Service', - 'quantity': 1, - 'uom_id': self.product_uom_unit.id, - 'price_unit': 10, - 'invoice_line_tax_ids': [(6, 0, [self.tax_0.id])], - 'invoice_line_tax_wt_ids': [(6, 0, [ - self.wt1040.id, - self.enasarco.id, - ])] - }), - ], - }) + invoice = self.invoice_model.create( + { + "date_invoice": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "account_id": self.a_recv.id, + "payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "uom_id": self.product_uom_unit.id, + "price_unit": 10, + "invoice_line_tax_ids": [(6, 0, [self.tax_0.id])], + "invoice_line_tax_wt_ids": [ + ( + 6, + 0, + [ + self.wt1040.id, + self.enasarco.id, + ], + ) + ], + }, + ), + ], + } + ) invoice._onchange_invoice_line_wt_ids() invoice.action_invoice_open() res = self.run_wizard(invoice.id) - attachment = self.attach_model.browse(res['res_id']) - self.set_e_invoice_file_id(attachment, 'IT06363391001_00016.xml') + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00016.xml") # XML doc to be validated xml_content = base64.decodebytes(attachment.datas) self.check_content( - xml_content, 'IT06363391001_00016.xml', - module_name='l10n_it_fatturapa_out_wt') + xml_content, + "IT06363391001_00016.xml", + module_name="l10n_it_fatturapa_out_wt", + ) def test_e_invoice_wt_inps_0(self): - self.set_sequences(17, '2019-01-07') - invoice = self.invoice_model.create({ - 'date_invoice': '2019-01-07', - 'partner_id': self.res_partner_fatturapa_2.id, - 'journal_id': self.sales_journal.id, - 'account_id': self.a_recv.id, - 'payment_term_id': self.account_payment_term.id, - 'user_id': self.user_demo.id, - 'type': 'out_invoice', - 'currency_id': self.EUR.id, - 'invoice_line_ids': [ - (0, 0, { - 'account_id': self.a_sale.id, - 'name': 'Service', - 'quantity': 1, - 'uom_id': self.product_uom_unit.id, - 'price_unit': 10, - 'invoice_line_tax_ids': [(6, 0, [self.tax_22.id])], - 'invoice_line_tax_wt_ids': [(6, 0, [ - self.wt1040.id, - self.inps.id, - ])] - }), + self.set_sequences(17, "2019-01-07") + invoice = self.invoice_model.create( + { + "date_invoice": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "account_id": self.a_recv.id, + "payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "uom_id": self.product_uom_unit.id, + "price_unit": 10, + "invoice_line_tax_ids": [(6, 0, [self.tax_22.id])], + "invoice_line_tax_wt_ids": [ + ( + 6, + 0, + [ + self.wt1040.id, + self.inps.id, + ], + ) + ], + }, + ), ], - }) - invoice._onchange_invoice_line_wt_ids() - invoice.action_invoice_open() - res = self.run_wizard(invoice.id) + } + ) + invoice._onchange_invoice_line_wt_ids() + invoice.action_invoice_open() + res = self.run_wizard(invoice.id) - attachment = self.attach_model.browse(res['res_id']) - self.set_e_invoice_file_id(attachment, 'IT06363391001_00017.xml') + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00017.xml") - # XML doc to be validated - xml_content = base64.decodebytes(attachment.datas) - self.check_content( - xml_content, 'IT06363391001_00017.xml', - module_name='l10n_it_fatturapa_out_wt') + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, "IT06363391001_00017.xml", module_name="l10n_it_fatturapa_out_wt" + ) def test_e_invoice_wt_inps_1(self): - """ - Fill DatiCassaPrevidenziale with INPS data - """ - self.set_sequences(18, '2019-01-07') - self.inps.use_daticassaprev = True - self.inps.daticassprev_tax_id = self.tax_0 - invoice = self.invoice_model.create({ - 'date_invoice': '2019-01-07', - 'partner_id': self.res_partner_fatturapa_2.id, - 'journal_id': self.sales_journal.id, - 'account_id': self.a_recv.id, - 'payment_term_id': self.account_payment_term.id, - 'user_id': self.user_demo.id, - 'type': 'out_invoice', - 'currency_id': self.EUR.id, - 'invoice_line_ids': [ - (0, 0, { - 'account_id': self.a_sale.id, - 'name': 'Service', - 'quantity': 1, - 'uom_id': self.product_uom_unit.id, - 'price_unit': 10, - 'invoice_line_tax_ids': [(6, 0, [self.tax_22.id])], - 'invoice_line_tax_wt_ids': [(6, 0, [ - self.wt1040.id, - self.inps.id, - ])] - }), + """ + Fill DatiCassaPrevidenziale with INPS data + """ + self.set_sequences(18, "2019-01-07") + self.inps.use_daticassaprev = True + self.inps.daticassprev_tax_id = self.tax_0 + invoice = self.invoice_model.create( + { + "date_invoice": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "account_id": self.a_recv.id, + "payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "uom_id": self.product_uom_unit.id, + "price_unit": 10, + "invoice_line_tax_ids": [(6, 0, [self.tax_22.id])], + "invoice_line_tax_wt_ids": [ + ( + 6, + 0, + [ + self.wt1040.id, + self.inps.id, + ], + ) + ], + }, + ), ], - }) - invoice._onchange_invoice_line_wt_ids() - invoice.action_invoice_open() - res = self.run_wizard(invoice.id) + } + ) + invoice._onchange_invoice_line_wt_ids() + invoice.action_invoice_open() + res = self.run_wizard(invoice.id) - attachment = self.attach_model.browse(res['res_id']) - self.set_e_invoice_file_id(attachment, 'IT06363391001_00018.xml') + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00018.xml") - # XML doc to be validated - xml_content = base64.decodebytes(attachment.datas) - self.check_content( - xml_content, 'IT06363391001_00018.xml', - module_name='l10n_it_fatturapa_out_wt') + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, "IT06363391001_00018.xml", module_name="l10n_it_fatturapa_out_wt" + ) def test_e_invoice_wt_inps_2(self): - """ - Fill DatiCassaPrevidenziale with INPS data, - when DatiRiepilogo already has 0 VAT - """ - self.set_sequences(19, '2019-01-07') - self.inps.use_daticassaprev = True - self.inps.daticassprev_tax_id = self.tax_0 - invoice = self.invoice_model.create({ - 'date_invoice': '2019-01-07', - 'partner_id': self.res_partner_fatturapa_2.id, - 'journal_id': self.sales_journal.id, - 'account_id': self.a_recv.id, - 'payment_term_id': self.account_payment_term.id, - 'user_id': self.user_demo.id, - 'type': 'out_invoice', - 'currency_id': self.EUR.id, - 'invoice_line_ids': [ - (0, 0, { - 'account_id': self.a_sale.id, - 'name': 'Service', - 'quantity': 1, - 'uom_id': self.product_uom_unit.id, - 'price_unit': 10, - 'invoice_line_tax_ids': [(6, 0, [self.tax_0.id])], - 'invoice_line_tax_wt_ids': [(6, 0, [ - self.wt1040.id, - self.inps.id, - ])] - }), + """ + Fill DatiCassaPrevidenziale with INPS data, + when DatiRiepilogo already has 0 VAT + """ + self.set_sequences(19, "2019-01-07") + self.inps.use_daticassaprev = True + self.inps.daticassprev_tax_id = self.tax_0 + invoice = self.invoice_model.create( + { + "date_invoice": "2019-01-07", + "partner_id": self.res_partner_fatturapa_2.id, + "journal_id": self.sales_journal.id, + "account_id": self.a_recv.id, + "payment_term_id": self.account_payment_term.id, + "user_id": self.user_demo.id, + "type": "out_invoice", + "currency_id": self.EUR.id, + "invoice_line_ids": [ + ( + 0, + 0, + { + "account_id": self.a_sale.id, + "name": "Service", + "quantity": 1, + "uom_id": self.product_uom_unit.id, + "price_unit": 10, + "invoice_line_tax_ids": [(6, 0, [self.tax_0.id])], + "invoice_line_tax_wt_ids": [ + ( + 6, + 0, + [ + self.wt1040.id, + self.inps.id, + ], + ) + ], + }, + ), ], - }) - invoice._onchange_invoice_line_wt_ids() - invoice.action_invoice_open() - res = self.run_wizard(invoice.id) + } + ) + invoice._onchange_invoice_line_wt_ids() + invoice.action_invoice_open() + res = self.run_wizard(invoice.id) - attachment = self.attach_model.browse(res['res_id']) - self.set_e_invoice_file_id(attachment, 'IT06363391001_00019.xml') + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00019.xml") - # XML doc to be validated - xml_content = base64.decodebytes(attachment.datas) - self.check_content( - xml_content, 'IT06363391001_00019.xml', - module_name='l10n_it_fatturapa_out_wt') + # XML doc to be validated + xml_content = base64.decodebytes(attachment.datas) + self.check_content( + xml_content, "IT06363391001_00019.xml", module_name="l10n_it_fatturapa_out_wt" + ) diff --git a/l10n_it_fatturapa_out_wt/wizard/__init__.py b/l10n_it_fatturapa_out_wt/wizard/__init__.py index a5be93d64228..5196bb6ea240 100644 --- a/l10n_it_fatturapa_out_wt/wizard/__init__.py +++ b/l10n_it_fatturapa_out_wt/wizard/__init__.py @@ -1,2 +1 @@ - from . import wizard_export_fatturapa diff --git a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py index 3fed0f0cd457..6208ebfbea8f 100644 --- a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py +++ b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py @@ -1,25 +1,20 @@ - from odoo import models -from odoo.tools.translate import _ from odoo.exceptions import Warning as UserError from odoo.tools.float_utils import float_round +from odoo.tools.translate import _ + from odoo.addons.l10n_it_fatturapa.bindings.fatturapa import ( - DatiRitenutaType, DatiCassaPrevidenzialeType, - DatiRiepilogoType + DatiRiepilogoType, + DatiRitenutaType, ) -WT_TAX_CODE = { - 'inps': 'RT03', - 'enasarco': 'RT04', - 'enpam': 'RT05', - 'other': 'RT06' -} +WT_TAX_CODE = {"inps": "RT03", "enasarco": "RT04", "enpam": "RT05", "other": "RT06"} TC_CODE = { - 'inps': 'TC22', - 'enasarco': 'TC07', - 'enpam': 'TC09', + "inps": "TC22", + "enasarco": "TC07", + "enpam": "TC09", } @@ -27,67 +22,65 @@ class WizardExportFatturapa(models.TransientModel): _inherit = "wizard.export.fatturapa" def getTipoRitenuta(self, wt_types, partner): - if wt_types == 'ritenuta': + if wt_types == "ritenuta": if partner.is_company: - tipoRitenuta = 'RT02' + tipoRitenuta = "RT02" else: - tipoRitenuta = 'RT01' + tipoRitenuta = "RT01" else: tipoRitenuta = WT_TAX_CODE[wt_types] return tipoRitenuta def setDatiGeneraliDocumento(self, invoice, body): - res = super(WizardExportFatturapa, self).setDatiGeneraliDocumento( - invoice, body) + res = super(WizardExportFatturapa, self).setDatiGeneraliDocumento(invoice, body) # Get consistent ordering for file generation for compare with test XML ritenuta_lines = invoice.withholding_tax_line_ids.sorted( - key=lambda l: l.withholding_tax_id.code) + key=lambda l: l.withholding_tax_id.code + ) for wt_line in ritenuta_lines: if not wt_line.withholding_tax_id.causale_pagamento_id.code: - raise UserError(_('Missing payment reason for ' - 'withholding tax %s!') - % wt_line.withholding_tax_id.name) - tipoRitenuta = self.getTipoRitenuta( - wt_line.withholding_tax_id.wt_types, - invoice.partner_id + raise UserError( + _("Missing payment reason for " "withholding tax %s!") + % wt_line.withholding_tax_id.name ) + tipoRitenuta = self.getTipoRitenuta( + wt_line.withholding_tax_id.wt_types, invoice.partner_id + ) body.DatiGenerali.DatiGeneraliDocumento.DatiRitenuta.append( DatiRitenutaType( TipoRitenuta=tipoRitenuta, - ImportoRitenuta='%.2f' % float_round(wt_line.tax, 2), - AliquotaRitenuta='%.2f' % float_round( - wt_line.withholding_tax_id.tax, 2), - CausalePagamento=wt_line.withholding_tax_id. - causale_pagamento_id.code - )) + ImportoRitenuta="%.2f" % float_round(wt_line.tax, 2), + AliquotaRitenuta="%.2f" + % float_round(wt_line.withholding_tax_id.tax, 2), + CausalePagamento=wt_line.withholding_tax_id.causale_pagamento_id.code, + ) + ) if wt_line.withholding_tax_id.use_daticassaprev: tax_id = wt_line.withholding_tax_id.daticassprev_tax_id tax_kind = tax_id.kind_id.code - body.DatiGenerali.DatiGeneraliDocumento.\ - DatiCassaPrevidenziale.append( - DatiCassaPrevidenzialeType( - TipoCassa=TC_CODE[wt_line.withholding_tax_id.wt_types], - AlCassa='%.2f' % float_round( - wt_line.withholding_tax_id.tax, 2), - ImportoContributoCassa='%.2f' % float_round( - wt_line.tax, 2), - AliquotaIVA='0.00', - Natura=tax_kind, - ) - ) + body.DatiGenerali.DatiGeneraliDocumento.DatiCassaPrevidenziale.append( + DatiCassaPrevidenzialeType( + TipoCassa=TC_CODE[wt_line.withholding_tax_id.wt_types], + AlCassa="%.2f" % float_round(wt_line.withholding_tax_id.tax, 2), + ImportoContributoCassa="%.2f" % float_round(wt_line.tax, 2), + AliquotaIVA="0.00", + Natura=tax_kind, + ) + ) return res def get_tax_riepilogo(self, body, tax_id): for riepilogo in body.DatiBeniServizi.DatiRiepilogo: - if float(riepilogo.AliquotaIVA) == 0.0 \ - and riepilogo.Natura == tax_id.kind_id.code: + if ( + float(riepilogo.AliquotaIVA) == 0.0 + and riepilogo.Natura == tax_id.kind_id.code + ): return riepilogo def setDatiRiepilogo(self, invoice, body): - res = super(WizardExportFatturapa, self).setDatiRiepilogo( - invoice, body) + res = super(WizardExportFatturapa, self).setDatiRiepilogo(invoice, body) wt_lines_to_write = invoice.withholding_tax_line_ids.filtered( - lambda x: x.withholding_tax_id.wt_types not in ('ritenuta', 'other') + lambda x: x.withholding_tax_id.wt_types not in ("ritenuta", "other") and x.withholding_tax_id.use_daticassaprev ) for wt_line in wt_lines_to_write: @@ -96,41 +89,39 @@ def setDatiRiepilogo(self, invoice, body): if tax_riepilogo: base_amount = float(tax_riepilogo.ImponibileImporto) base_amount += wt_line.tax - tax_riepilogo.ImponibileImporto = '%.2f' % float_round( - base_amount, 2) + tax_riepilogo.ImponibileImporto = "%.2f" % float_round(base_amount, 2) else: riepilogo = DatiRiepilogoType( - AliquotaIVA='0.00', - ImponibileImporto='%.2f' % float_round(wt_line.tax, 2), - Imposta='0.00', + AliquotaIVA="0.00", + ImponibileImporto="%.2f" % float_round(wt_line.tax, 2), + Imposta="0.00", Natura=tax_id.kind_id.code, RiferimentoNormativo=tax_id.law_reference, ) body.DatiBeniServizi.DatiRiepilogo.append(riepilogo) return res - def setDettaglioLinea( - self, line_no, line, body, price_precision, uom_precision - ): + def setDettaglioLinea(self, line_no, line, body, price_precision, uom_precision): DettaglioLinea = super(WizardExportFatturapa, self).setDettaglioLinea( line_no, line, body, price_precision, uom_precision ) if any([wt for wt in line.invoice_line_tax_wt_ids]): - DettaglioLinea.Ritenuta = 'SI' + DettaglioLinea.Ritenuta = "SI" return DettaglioLinea def setDatiPagamento(self, invoice, body): - res = super(WizardExportFatturapa, self).setDatiPagamento( - invoice, body) + res = super(WizardExportFatturapa, self).setDatiPagamento(invoice, body) if invoice.withholding_tax_line_ids and invoice.payment_term_id: payment_line_ids = invoice.get_receivable_line_ids() index = 0 rate = invoice.amount_net_pay / invoice.amount_total - move_line_pool = self.env['account.move.line'] + move_line_pool = self.env["account.move.line"] for move_line_id in payment_line_ids: move_line = move_line_pool.browse(move_line_id) - body.DatiPagamento[0].DettaglioPagamento[index].\ - ImportoPagamento = '%.2f' % float_round( - (move_line.amount_currency or move_line.debit) * rate, 2) + body.DatiPagamento[0].DettaglioPagamento[ + index + ].ImportoPagamento = "%.2f" % float_round( + (move_line.amount_currency or move_line.debit) * rate, 2 + ) index += 1 return res diff --git a/setup/l10n_it_fatturapa_out_wt/odoo/addons/l10n_it_fatturapa_out_wt b/setup/l10n_it_fatturapa_out_wt/odoo/addons/l10n_it_fatturapa_out_wt new file mode 120000 index 000000000000..9a62739d02d7 --- /dev/null +++ b/setup/l10n_it_fatturapa_out_wt/odoo/addons/l10n_it_fatturapa_out_wt @@ -0,0 +1 @@ +../../../../l10n_it_fatturapa_out_wt \ No newline at end of file diff --git a/setup/l10n_it_fatturapa_out_wt/setup.py b/setup/l10n_it_fatturapa_out_wt/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/l10n_it_fatturapa_out_wt/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From 3807fe2feaf59eade9cc367a123660a4ee7ff180 Mon Sep 17 00:00:00 2001 From: Ciro Urselli Date: Fri, 6 Aug 2021 09:56:33 +0200 Subject: [PATCH 25/27] [MIG] l10n_it_fatturapa_ou_wt: Migration to 14.0 --- l10n_it_fatturapa_out_wt/README.rst | 1 + l10n_it_fatturapa_out_wt/__init__.py | 1 - l10n_it_fatturapa_out_wt/__manifest__.py | 5 +- l10n_it_fatturapa_out_wt/i18n/it.po | 28 ------- .../i18n/l10n_it_fatturapa_out_wt.pot | 26 ------- .../readme/CONTRIBUTORS.rst | 1 + .../tests/test_fatturapa_wt.py | 25 ++++-- .../account_invoice_it_dati_ritenuta.xml | 76 +++++++++++++++++++ l10n_it_fatturapa_out_wt/wizard/__init__.py | 2 +- l10n_it_fatturapa_out_wt/wizard/efattura.py | 22 ++++++ 10 files changed, 121 insertions(+), 66 deletions(-) delete mode 100644 l10n_it_fatturapa_out_wt/i18n/it.po delete mode 100644 l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot create mode 100644 l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml create mode 100644 l10n_it_fatturapa_out_wt/wizard/efattura.py diff --git a/l10n_it_fatturapa_out_wt/README.rst b/l10n_it_fatturapa_out_wt/README.rst index cb8a5dac843d..750edcc13b79 100644 --- a/l10n_it_fatturapa_out_wt/README.rst +++ b/l10n_it_fatturapa_out_wt/README.rst @@ -64,6 +64,7 @@ Contributors ~~~~~~~~~~~~ * Sergio Corato +* Ciro Urselli Maintainers ~~~~~~~~~~~ diff --git a/l10n_it_fatturapa_out_wt/__init__.py b/l10n_it_fatturapa_out_wt/__init__.py index 4b25b9723083..78369e77d948 100644 --- a/l10n_it_fatturapa_out_wt/__init__.py +++ b/l10n_it_fatturapa_out_wt/__init__.py @@ -1,3 +1,2 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - from . import wizard diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py index ceeb5720521e..2a295645e7eb 100644 --- a/l10n_it_fatturapa_out_wt/__manifest__.py +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -2,11 +2,12 @@ # Copyright 2018 Openforce Srls Unipersonale (www.openforce.it) # Copyright 2018 Sergio Corato (https://efatto.it) # Copyright 2018-2019 Lorenzo Battistini +# Copyright 2021 Ciro Urselli # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "ITA - Fattura elettronica - Integrazione " "ritenuta", "summary": "Modulo ponte tra emissione fatture elettroniche e ritenute.", - "version": "12.0.2.0.0", + "version": "14.0.1.0.0", "development_status": "Beta", "category": "Hidden", "website": "https://github.com/OCA/l10n-italy", @@ -16,7 +17,7 @@ "l10n_it_fatturapa", "l10n_it_fatturapa_out", "l10n_it_withholding_tax", - "l10n_it_withholding_tax_causali", + "l10n_it_withholding_tax_reason", ], "data": [], "installable": True, diff --git a/l10n_it_fatturapa_out_wt/i18n/it.po b/l10n_it_fatturapa_out_wt/i18n/it.po deleted file mode 100644 index ff89d7dc2134..000000000000 --- a/l10n_it_fatturapa_out_wt/i18n/it.po +++ /dev/null @@ -1,28 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * l10n_it_fatturapa_out_wt -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2021-05-31 19:48+0000\n" -"Last-Translator: Sergio Corato \n" -"Language-Team: none\n" -"Language: it\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.3.2\n" - -#. module: l10n_it_fatturapa_out_wt -#: model:ir.model,name:l10n_it_fatturapa_out_wt.model_wizard_export_fatturapa -msgid "Export E-invoice" -msgstr "Esporta E-fattura" - -#. module: l10n_it_fatturapa_out_wt -#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:47 -#, python-format -msgid "Missing payment reason for withholding tax %s!" -msgstr "Causale di pagamento mancante per la ritenuta d'acconto %s!" diff --git a/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot b/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot deleted file mode 100644 index 92b3c46337c4..000000000000 --- a/l10n_it_fatturapa_out_wt/i18n/l10n_it_fatturapa_out_wt.pot +++ /dev/null @@ -1,26 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * l10n_it_fatturapa_out_wt -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: l10n_it_fatturapa_out_wt -#: model:ir.model,name:l10n_it_fatturapa_out_wt.model_wizard_export_fatturapa -msgid "Export E-invoice" -msgstr "" - -#. module: l10n_it_fatturapa_out_wt -#: code:addons/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py:47 -#, python-format -msgid "Missing payment reason for withholding tax %s!" -msgstr "" - diff --git a/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst b/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst index feb5b093f570..45de63c47513 100644 --- a/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst +++ b/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Sergio Corato +* Ciro Urselli \ No newline at end of file diff --git a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py index fb473b7ecf65..b6a557a7f4ad 100644 --- a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py +++ b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py @@ -32,7 +32,8 @@ def setUp(self): "name": "", "line_ids": [(0, 0, {"value": "balance", "days": 15})], } - self.payment_term_15 = self.env["account.payment.term"].create(vals_payment) + self.payment_term_15 = self.env["account.payment.term"].create( + vals_payment) wt_vals = { "name": "Code 1040", "code": "1040", @@ -41,7 +42,8 @@ def setUp(self): "account_payable_id": self.wt_account_payable.id, "journal_id": self.journal_misc.id, "payment_term": self.payment_term_15.id, - "causale_pagamento_id": self.env.ref("l10n_it_causali_pagamento.a").id, + "causale_pagamento_id": self.env.ref( + "l10n_it_causali_pagamento.a").id, "rate_ids": [ ( 0, @@ -62,7 +64,8 @@ def setUp(self): "journal_id": self.journal_misc.id, "wt_types": "enasarco", "payment_term": self.payment_term_15.id, - "causale_pagamento_id": self.env.ref("l10n_it_causali_pagamento.a").id, + "causale_pagamento_id": self.env.ref( + "l10n_it_causali_pagamento.a").id, "rate_ids": [ ( 0, @@ -83,7 +86,8 @@ def setUp(self): "journal_id": self.journal_misc.id, "wt_types": "enasarco", "payment_term": self.payment_term_15.id, - "causale_pagamento_id": self.env.ref("l10n_it_causali_pagamento.a").id, + "causale_pagamento_id": self.env.ref( + "l10n_it_causali_pagamento.a").id, "rate_ids": [ ( 0, @@ -120,7 +124,9 @@ def test_e_invoice_wt(self): "uom_id": self.product_uom_unit.id, "price_unit": 10, "invoice_line_tax_ids": [(6, 0, [self.tax_22.id])], - "invoice_line_tax_wt_ids": [(6, 0, [self.wt1040.id])], + "invoice_line_tax_wt_ids": [ + (6, 0, [self.wt1040.id]) + ], }, ), ], @@ -360,7 +366,8 @@ def test_e_invoice_wt_inps_0(self): # XML doc to be validated xml_content = base64.decodebytes(attachment.datas) self.check_content( - xml_content, "IT06363391001_00017.xml", module_name="l10n_it_fatturapa_out_wt" + xml_content, "IT06363391001_00017.xml", + module_name="l10n_it_fatturapa_out_wt" ) @@ -417,7 +424,8 @@ def test_e_invoice_wt_inps_1(self): # XML doc to be validated xml_content = base64.decodebytes(attachment.datas) self.check_content( - xml_content, "IT06363391001_00018.xml", module_name="l10n_it_fatturapa_out_wt" + xml_content, "IT06363391001_00018.xml", + module_name="l10n_it_fatturapa_out_wt" ) @@ -475,5 +483,6 @@ def test_e_invoice_wt_inps_2(self): # XML doc to be validated xml_content = base64.decodebytes(attachment.datas) self.check_content( - xml_content, "IT06363391001_00019.xml", module_name="l10n_it_fatturapa_out_wt" + xml_content, "IT06363391001_00019.xml", + module_name="l10n_it_fatturapa_out_wt" ) diff --git a/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml b/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml new file mode 100644 index 000000000000..1ee69280e7eb --- /dev/null +++ b/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/l10n_it_fatturapa_out_wt/wizard/__init__.py b/l10n_it_fatturapa_out_wt/wizard/__init__.py index 5196bb6ea240..aa1627f0e386 100644 --- a/l10n_it_fatturapa_out_wt/wizard/__init__.py +++ b/l10n_it_fatturapa_out_wt/wizard/__init__.py @@ -1 +1 @@ -from . import wizard_export_fatturapa +from . import efattura diff --git a/l10n_it_fatturapa_out_wt/wizard/efattura.py b/l10n_it_fatturapa_out_wt/wizard/efattura.py new file mode 100644 index 000000000000..60f5cd0ca479 --- /dev/null +++ b/l10n_it_fatturapa_out_wt/wizard/efattura.py @@ -0,0 +1,22 @@ +# Copyright 2020 Giuseppe Borruso +# Copyright 2020 Marco Colombo +# Copyright 2021 Ciro Urselli +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.addons.l10n_it_fatturapa_out.wizard.efattura import EFatturaOut + + +WT_TAX_CODE = {"inps": "RT03", "enasarco": "RT04", "enpam": "RT05", "other": "RT06"} + + +class EFatturaOut(EFatturaOut): + + def getTipoRitenuta(wt_types, partner): + if wt_types == "ritenuta": + if partner.is_company: + tipoRitenuta = "RT02" + else: + tipoRitenuta = "RT01" + else: + tipoRitenuta = WT_TAX_CODE[wt_types] + return tipoRitenuta From b8b2d5419eab10b0e7236ae1c0fd859f60f5343d Mon Sep 17 00:00:00 2001 From: Ciro Urselli Date: Fri, 6 Aug 2021 12:31:25 +0200 Subject: [PATCH 26/27] [MIG] l10n_it_fatturapa_ou_wt: fix view xml --- l10n_it_fatturapa_out_wt/__manifest__.py | 4 +- .../account_invoice_it_dati_ritenuta.xml | 14 +- l10n_it_fatturapa_out_wt/wizard/efattura.py | 6 +- .../wizard/wizard_export_fatturapa.py | 127 ------------------ 4 files changed, 14 insertions(+), 137 deletions(-) delete mode 100644 l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py index 2a295645e7eb..4f757ef6d0d7 100644 --- a/l10n_it_fatturapa_out_wt/__manifest__.py +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -19,7 +19,9 @@ "l10n_it_withholding_tax", "l10n_it_withholding_tax_reason", ], - "data": [], + "data": [ + 'views/account_invoice_it_dati_ritenuta.xml' + ], "installable": True, "auto_install": True, } diff --git a/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml b/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml index 1ee69280e7eb..22613bfa9335 100644 --- a/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml +++ b/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml @@ -7,12 +7,12 @@ - - + @@ -26,8 +26,8 @@ - + + @@ -55,7 +55,7 @@ - - - + --> \ No newline at end of file diff --git a/l10n_it_fatturapa_out_wt/wizard/efattura.py b/l10n_it_fatturapa_out_wt/wizard/efattura.py index 60f5cd0ca479..45e89619036b 100644 --- a/l10n_it_fatturapa_out_wt/wizard/efattura.py +++ b/l10n_it_fatturapa_out_wt/wizard/efattura.py @@ -6,7 +6,11 @@ from odoo.addons.l10n_it_fatturapa_out.wizard.efattura import EFatturaOut -WT_TAX_CODE = {"inps": "RT03", "enasarco": "RT04", "enpam": "RT05", "other": "RT06"} +WT_TAX_CODE = { + "inps": "RT03", + "enasarco": "RT04", + "enpam": "RT05", + "other": "RT06"} class EFatturaOut(EFatturaOut): diff --git a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py deleted file mode 100644 index 6208ebfbea8f..000000000000 --- a/l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py +++ /dev/null @@ -1,127 +0,0 @@ -from odoo import models -from odoo.exceptions import Warning as UserError -from odoo.tools.float_utils import float_round -from odoo.tools.translate import _ - -from odoo.addons.l10n_it_fatturapa.bindings.fatturapa import ( - DatiCassaPrevidenzialeType, - DatiRiepilogoType, - DatiRitenutaType, -) - -WT_TAX_CODE = {"inps": "RT03", "enasarco": "RT04", "enpam": "RT05", "other": "RT06"} - -TC_CODE = { - "inps": "TC22", - "enasarco": "TC07", - "enpam": "TC09", -} - - -class WizardExportFatturapa(models.TransientModel): - _inherit = "wizard.export.fatturapa" - - def getTipoRitenuta(self, wt_types, partner): - if wt_types == "ritenuta": - if partner.is_company: - tipoRitenuta = "RT02" - else: - tipoRitenuta = "RT01" - else: - tipoRitenuta = WT_TAX_CODE[wt_types] - return tipoRitenuta - - def setDatiGeneraliDocumento(self, invoice, body): - res = super(WizardExportFatturapa, self).setDatiGeneraliDocumento(invoice, body) - # Get consistent ordering for file generation for compare with test XML - ritenuta_lines = invoice.withholding_tax_line_ids.sorted( - key=lambda l: l.withholding_tax_id.code - ) - for wt_line in ritenuta_lines: - if not wt_line.withholding_tax_id.causale_pagamento_id.code: - raise UserError( - _("Missing payment reason for " "withholding tax %s!") - % wt_line.withholding_tax_id.name - ) - tipoRitenuta = self.getTipoRitenuta( - wt_line.withholding_tax_id.wt_types, invoice.partner_id - ) - body.DatiGenerali.DatiGeneraliDocumento.DatiRitenuta.append( - DatiRitenutaType( - TipoRitenuta=tipoRitenuta, - ImportoRitenuta="%.2f" % float_round(wt_line.tax, 2), - AliquotaRitenuta="%.2f" - % float_round(wt_line.withholding_tax_id.tax, 2), - CausalePagamento=wt_line.withholding_tax_id.causale_pagamento_id.code, - ) - ) - if wt_line.withholding_tax_id.use_daticassaprev: - tax_id = wt_line.withholding_tax_id.daticassprev_tax_id - tax_kind = tax_id.kind_id.code - body.DatiGenerali.DatiGeneraliDocumento.DatiCassaPrevidenziale.append( - DatiCassaPrevidenzialeType( - TipoCassa=TC_CODE[wt_line.withholding_tax_id.wt_types], - AlCassa="%.2f" % float_round(wt_line.withholding_tax_id.tax, 2), - ImportoContributoCassa="%.2f" % float_round(wt_line.tax, 2), - AliquotaIVA="0.00", - Natura=tax_kind, - ) - ) - return res - - def get_tax_riepilogo(self, body, tax_id): - for riepilogo in body.DatiBeniServizi.DatiRiepilogo: - if ( - float(riepilogo.AliquotaIVA) == 0.0 - and riepilogo.Natura == tax_id.kind_id.code - ): - return riepilogo - - def setDatiRiepilogo(self, invoice, body): - res = super(WizardExportFatturapa, self).setDatiRiepilogo(invoice, body) - wt_lines_to_write = invoice.withholding_tax_line_ids.filtered( - lambda x: x.withholding_tax_id.wt_types not in ("ritenuta", "other") - and x.withholding_tax_id.use_daticassaprev - ) - for wt_line in wt_lines_to_write: - tax_id = wt_line.withholding_tax_id.daticassprev_tax_id - tax_riepilogo = self.get_tax_riepilogo(body, tax_id) - if tax_riepilogo: - base_amount = float(tax_riepilogo.ImponibileImporto) - base_amount += wt_line.tax - tax_riepilogo.ImponibileImporto = "%.2f" % float_round(base_amount, 2) - else: - riepilogo = DatiRiepilogoType( - AliquotaIVA="0.00", - ImponibileImporto="%.2f" % float_round(wt_line.tax, 2), - Imposta="0.00", - Natura=tax_id.kind_id.code, - RiferimentoNormativo=tax_id.law_reference, - ) - body.DatiBeniServizi.DatiRiepilogo.append(riepilogo) - return res - - def setDettaglioLinea(self, line_no, line, body, price_precision, uom_precision): - DettaglioLinea = super(WizardExportFatturapa, self).setDettaglioLinea( - line_no, line, body, price_precision, uom_precision - ) - if any([wt for wt in line.invoice_line_tax_wt_ids]): - DettaglioLinea.Ritenuta = "SI" - return DettaglioLinea - - def setDatiPagamento(self, invoice, body): - res = super(WizardExportFatturapa, self).setDatiPagamento(invoice, body) - if invoice.withholding_tax_line_ids and invoice.payment_term_id: - payment_line_ids = invoice.get_receivable_line_ids() - index = 0 - rate = invoice.amount_net_pay / invoice.amount_total - move_line_pool = self.env["account.move.line"] - for move_line_id in payment_line_ids: - move_line = move_line_pool.browse(move_line_id) - body.DatiPagamento[0].DettaglioPagamento[ - index - ].ImportoPagamento = "%.2f" % float_round( - (move_line.amount_currency or move_line.debit) * rate, 2 - ) - index += 1 - return res From 484073b10ab5bf30d171c5fef5f72844a57b9b0b Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 6 Aug 2021 16:44:02 +0200 Subject: [PATCH 27/27] fixup! [MIG] l10n_it_fatturapa_ou_wt: Migration to 14.0 --- l10n_it_fatturapa_out_wt/__manifest__.py | 2 +- .../readme/CONTRIBUTORS.rst | 2 +- .../tests/test_fatturapa_wt.py | 158 ++++++++++-------- .../account_invoice_it_dati_ritenuta.xml | 109 +++++++----- l10n_it_fatturapa_out_wt/wizard/__init__.py | 1 + l10n_it_fatturapa_out_wt/wizard/efattura.py | 79 +++++++-- .../wizard/wizard_export_fatturapa.py | 10 ++ 7 files changed, 236 insertions(+), 125 deletions(-) create mode 100644 l10n_it_fatturapa_out_wt/wizard/wizard_export_fatturapa.py diff --git a/l10n_it_fatturapa_out_wt/__manifest__.py b/l10n_it_fatturapa_out_wt/__manifest__.py index 4f757ef6d0d7..998b39cecb91 100644 --- a/l10n_it_fatturapa_out_wt/__manifest__.py +++ b/l10n_it_fatturapa_out_wt/__manifest__.py @@ -20,7 +20,7 @@ "l10n_it_withholding_tax_reason", ], "data": [ - 'views/account_invoice_it_dati_ritenuta.xml' + "views/account_invoice_it_dati_ritenuta.xml", ], "installable": True, "auto_install": True, diff --git a/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst b/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst index 45de63c47513..1783ba4797f0 100644 --- a/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst +++ b/l10n_it_fatturapa_out_wt/readme/CONTRIBUTORS.rst @@ -1,2 +1,2 @@ * Sergio Corato -* Ciro Urselli \ No newline at end of file +* Ciro Urselli diff --git a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py index b6a557a7f4ad..b9d140d2fcde 100644 --- a/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py +++ b/l10n_it_fatturapa_out_wt/tests/test_fatturapa_wt.py @@ -5,10 +5,43 @@ class TestInvoiceWT(FatturaPACommon): def setUp(self): - super(TestInvoiceWT, self).setUp() + super().setUp() + + ### + # XXX this should really be in FatturaPACommon + # tested 2021/08/06 @TheMule71 + + # XXX - a company named "YourCompany" alread exists + # we move it out of the way but we should do better here + self.env.company.sudo().search([("name", "=", "YourCompany")]).write( + {"name": "YourCompany_"} + ) + self.env.company.name = "YourCompany" + self.env.company.vat = "IT06363391001" + self.env.company.fatturapa_art73 = True + self.env.company.partner_id.street = "Via Milano, 1" + self.env.company.partner_id.city = "Roma" + self.env.company.partner_id.state_id = self.env.ref("base.state_us_2").id + self.env.company.partner_id.country_id = self.env.ref("base.it").id + self.env.company.partner_id.zip = "00100" + self.env.company.partner_id.phone = "06543534343" + self.env.company.email = "info@yourcompany.example.com" + self.env.company.fatturapa_fiscal_position_id = self.env.ref( + "l10n_it_fatturapa.fatturapa_RF01" + ).id + self.env["decimal.precision"].search( + [("name", "=", "Product Unit of Measure")] + ).digits = 3 + self.env["uom.uom"].search([("name", "=", "Units")]).name = "Unit(s)" + ### + type_payable = self.env.ref("account.data_account_type_payable") type_receivable = self.env.ref("account.data_account_type_receivable") - self.tax_0 = self.env.ref("l10n_it_fatturapa.tax_00_enas") + self.tax_0 = ( + self.env.ref("l10n_it_fatturapa.tax_00_enas") + .sudo() + .copy({"company_id": self.env.company.id}) + ) self.wt_account_payable = self.env["account.account"].create( { "name": "Debiti per ritenute da versare", @@ -32,8 +65,7 @@ def setUp(self): "name": "", "line_ids": [(0, 0, {"value": "balance", "days": 15})], } - self.payment_term_15 = self.env["account.payment.term"].create( - vals_payment) + self.payment_term_15 = self.env["account.payment.term"].create(vals_payment) wt_vals = { "name": "Code 1040", "code": "1040", @@ -42,8 +74,7 @@ def setUp(self): "account_payable_id": self.wt_account_payable.id, "journal_id": self.journal_misc.id, "payment_term": self.payment_term_15.id, - "causale_pagamento_id": self.env.ref( - "l10n_it_causali_pagamento.a").id, + "payment_reason_id": self.env.ref("l10n_it_payment_reason.a").id, "rate_ids": [ ( 0, @@ -64,8 +95,7 @@ def setUp(self): "journal_id": self.journal_misc.id, "wt_types": "enasarco", "payment_term": self.payment_term_15.id, - "causale_pagamento_id": self.env.ref( - "l10n_it_causali_pagamento.a").id, + "payment_reason_id": self.env.ref("l10n_it_payment_reason.a").id, "rate_ids": [ ( 0, @@ -86,8 +116,7 @@ def setUp(self): "journal_id": self.journal_misc.id, "wt_types": "enasarco", "payment_term": self.payment_term_15.id, - "causale_pagamento_id": self.env.ref( - "l10n_it_causali_pagamento.a").id, + "payment_reason_id": self.env.ref("l10n_it_payment_reason.a").id, "rate_ids": [ ( 0, @@ -103,15 +132,16 @@ def setUp(self): def test_e_invoice_wt(self): self.set_sequences(13, "2019-01-07") + invoice = self.invoice_model.create( { - "date_invoice": "2019-01-07", + "name": "INV/2019/0013", + "invoice_date": "2019-01-07", "partner_id": self.res_partner_fatturapa_2.id, "journal_id": self.sales_journal.id, - "account_id": self.a_recv.id, - "payment_term_id": self.account_payment_term.id, + "invoice_payment_term_id": self.account_payment_term.id, "user_id": self.user_demo.id, - "type": "out_invoice", + "move_type": "out_invoice", "currency_id": self.EUR.id, "invoice_line_ids": [ ( @@ -121,19 +151,17 @@ def test_e_invoice_wt(self): "account_id": self.a_sale.id, "name": "Service", "quantity": 1, - "uom_id": self.product_uom_unit.id, + "product_uom_id": self.product_uom_unit.id, "price_unit": 10, - "invoice_line_tax_ids": [(6, 0, [self.tax_22.id])], - "invoice_line_tax_wt_ids": [ - (6, 0, [self.wt1040.id]) - ], + "tax_ids": [(6, 0, [self.tax_22.id])], + "invoice_line_tax_wt_ids": [(6, 0, [self.wt1040.id])], }, ), ], } ) invoice._onchange_invoice_line_wt_ids() - invoice.action_invoice_open() + invoice.action_post() res = self.run_wizard(invoice.id) attachment = self.attach_model.browse(res["res_id"]) @@ -151,13 +179,13 @@ def test_e_invoice_wt_enas_0(self): self.set_sequences(14, "2019-01-07") invoice = self.invoice_model.create( { - "date_invoice": "2019-01-07", + "name": "INV/2019/0014", + "invoice_date": "2019-01-07", "partner_id": self.res_partner_fatturapa_2.id, "journal_id": self.sales_journal.id, - "account_id": self.a_recv.id, - "payment_term_id": self.account_payment_term.id, + "invoice_payment_term_id": self.account_payment_term.id, "user_id": self.user_demo.id, - "type": "out_invoice", + "move_type": "out_invoice", "currency_id": self.EUR.id, "invoice_line_ids": [ ( @@ -167,9 +195,9 @@ def test_e_invoice_wt_enas_0(self): "account_id": self.a_sale.id, "name": "Service", "quantity": 1, - "uom_id": self.product_uom_unit.id, + "product_uom_id": self.product_uom_unit.id, "price_unit": 10, - "invoice_line_tax_ids": [(6, 0, [self.tax_22.id])], + "tax_ids": [(6, 0, [self.tax_22.id])], "invoice_line_tax_wt_ids": [ ( 6, @@ -186,7 +214,7 @@ def test_e_invoice_wt_enas_0(self): } ) invoice._onchange_invoice_line_wt_ids() - invoice.action_invoice_open() + invoice.action_post() res = self.run_wizard(invoice.id) attachment = self.attach_model.browse(res["res_id"]) @@ -209,13 +237,13 @@ def test_e_invoice_wt_enas_1(self): self.enasarco.daticassprev_tax_id = self.tax_0 invoice = self.invoice_model.create( { - "date_invoice": "2019-01-07", + "name": "INV/2019/0015", + "invoice_date": "2019-01-07", "partner_id": self.res_partner_fatturapa_2.id, "journal_id": self.sales_journal.id, - "account_id": self.a_recv.id, - "payment_term_id": self.account_payment_term.id, + "invoice_payment_term_id": self.account_payment_term.id, "user_id": self.user_demo.id, - "type": "out_invoice", + "move_type": "out_invoice", "currency_id": self.EUR.id, "invoice_line_ids": [ ( @@ -225,9 +253,9 @@ def test_e_invoice_wt_enas_1(self): "account_id": self.a_sale.id, "name": "Service", "quantity": 1, - "uom_id": self.product_uom_unit.id, + "product_uom_id": self.product_uom_unit.id, "price_unit": 10, - "invoice_line_tax_ids": [(6, 0, [self.tax_22.id])], + "tax_ids": [(6, 0, [self.tax_22.id])], "invoice_line_tax_wt_ids": [ ( 6, @@ -244,7 +272,7 @@ def test_e_invoice_wt_enas_1(self): } ) invoice._onchange_invoice_line_wt_ids() - invoice.action_invoice_open() + invoice.action_post() res = self.run_wizard(invoice.id) attachment = self.attach_model.browse(res["res_id"]) @@ -268,13 +296,13 @@ def test_e_invoice_wt_enas_2(self): self.enasarco.daticassprev_tax_id = self.tax_0 invoice = self.invoice_model.create( { - "date_invoice": "2019-01-07", + "name": "INV/2019/0016", + "invoice_date": "2019-01-07", "partner_id": self.res_partner_fatturapa_2.id, "journal_id": self.sales_journal.id, - "account_id": self.a_recv.id, - "payment_term_id": self.account_payment_term.id, + "invoice_payment_term_id": self.account_payment_term.id, "user_id": self.user_demo.id, - "type": "out_invoice", + "move_type": "out_invoice", "currency_id": self.EUR.id, "invoice_line_ids": [ ( @@ -284,9 +312,9 @@ def test_e_invoice_wt_enas_2(self): "account_id": self.a_sale.id, "name": "Service", "quantity": 1, - "uom_id": self.product_uom_unit.id, + "product_uom_id": self.product_uom_unit.id, "price_unit": 10, - "invoice_line_tax_ids": [(6, 0, [self.tax_0.id])], + "tax_ids": [(6, 0, [self.tax_0.id])], "invoice_line_tax_wt_ids": [ ( 6, @@ -303,7 +331,7 @@ def test_e_invoice_wt_enas_2(self): } ) invoice._onchange_invoice_line_wt_ids() - invoice.action_invoice_open() + invoice.action_post() res = self.run_wizard(invoice.id) attachment = self.attach_model.browse(res["res_id"]) @@ -322,13 +350,12 @@ def test_e_invoice_wt_inps_0(self): self.set_sequences(17, "2019-01-07") invoice = self.invoice_model.create( { - "date_invoice": "2019-01-07", + "invoice_date": "2019-01-07", "partner_id": self.res_partner_fatturapa_2.id, "journal_id": self.sales_journal.id, - "account_id": self.a_recv.id, - "payment_term_id": self.account_payment_term.id, + "invoice_payment_term_id": self.account_payment_term.id, "user_id": self.user_demo.id, - "type": "out_invoice", + "move_type": "out_invoice", "currency_id": self.EUR.id, "invoice_line_ids": [ ( @@ -338,9 +365,9 @@ def test_e_invoice_wt_inps_0(self): "account_id": self.a_sale.id, "name": "Service", "quantity": 1, - "uom_id": self.product_uom_unit.id, + "product_uom_id": self.product_uom_unit.id, "price_unit": 10, - "invoice_line_tax_ids": [(6, 0, [self.tax_22.id])], + "tax_ids": [(6, 0, [self.tax_22.id])], "invoice_line_tax_wt_ids": [ ( 6, @@ -357,7 +384,7 @@ def test_e_invoice_wt_inps_0(self): } ) invoice._onchange_invoice_line_wt_ids() - invoice.action_invoice_open() + invoice.action_post() res = self.run_wizard(invoice.id) attachment = self.attach_model.browse(res["res_id"]) @@ -366,8 +393,7 @@ def test_e_invoice_wt_inps_0(self): # XML doc to be validated xml_content = base64.decodebytes(attachment.datas) self.check_content( - xml_content, "IT06363391001_00017.xml", - module_name="l10n_it_fatturapa_out_wt" + xml_content, "IT06363391001_00017.xml", module_name="l10n_it_fatturapa_out_wt" ) @@ -380,13 +406,12 @@ def test_e_invoice_wt_inps_1(self): self.inps.daticassprev_tax_id = self.tax_0 invoice = self.invoice_model.create( { - "date_invoice": "2019-01-07", + "invoice_date": "2019-01-07", "partner_id": self.res_partner_fatturapa_2.id, "journal_id": self.sales_journal.id, - "account_id": self.a_recv.id, - "payment_term_id": self.account_payment_term.id, + "invoice_payment_term_id": self.account_payment_term.id, "user_id": self.user_demo.id, - "type": "out_invoice", + "move_type": "out_invoice", "currency_id": self.EUR.id, "invoice_line_ids": [ ( @@ -396,9 +421,9 @@ def test_e_invoice_wt_inps_1(self): "account_id": self.a_sale.id, "name": "Service", "quantity": 1, - "uom_id": self.product_uom_unit.id, + "product_uom_id": self.product_uom_unit.id, "price_unit": 10, - "invoice_line_tax_ids": [(6, 0, [self.tax_22.id])], + "tax_ids": [(6, 0, [self.tax_22.id])], "invoice_line_tax_wt_ids": [ ( 6, @@ -415,7 +440,7 @@ def test_e_invoice_wt_inps_1(self): } ) invoice._onchange_invoice_line_wt_ids() - invoice.action_invoice_open() + invoice.action_post() res = self.run_wizard(invoice.id) attachment = self.attach_model.browse(res["res_id"]) @@ -424,8 +449,7 @@ def test_e_invoice_wt_inps_1(self): # XML doc to be validated xml_content = base64.decodebytes(attachment.datas) self.check_content( - xml_content, "IT06363391001_00018.xml", - module_name="l10n_it_fatturapa_out_wt" + xml_content, "IT06363391001_00018.xml", module_name="l10n_it_fatturapa_out_wt" ) @@ -439,13 +463,12 @@ def test_e_invoice_wt_inps_2(self): self.inps.daticassprev_tax_id = self.tax_0 invoice = self.invoice_model.create( { - "date_invoice": "2019-01-07", + "invoice_date": "2019-01-07", "partner_id": self.res_partner_fatturapa_2.id, "journal_id": self.sales_journal.id, - "account_id": self.a_recv.id, - "payment_term_id": self.account_payment_term.id, + "invoice_payment_term_id": self.account_payment_term.id, "user_id": self.user_demo.id, - "type": "out_invoice", + "move_type": "out_invoice", "currency_id": self.EUR.id, "invoice_line_ids": [ ( @@ -455,9 +478,9 @@ def test_e_invoice_wt_inps_2(self): "account_id": self.a_sale.id, "name": "Service", "quantity": 1, - "uom_id": self.product_uom_unit.id, + "product_uom_id": self.product_uom_unit.id, "price_unit": 10, - "invoice_line_tax_ids": [(6, 0, [self.tax_0.id])], + "tax_ids": [(6, 0, [self.tax_0.id])], "invoice_line_tax_wt_ids": [ ( 6, @@ -474,7 +497,7 @@ def test_e_invoice_wt_inps_2(self): } ) invoice._onchange_invoice_line_wt_ids() - invoice.action_invoice_open() + invoice.action_post() res = self.run_wizard(invoice.id) attachment = self.attach_model.browse(res["res_id"]) @@ -483,6 +506,5 @@ def test_e_invoice_wt_inps_2(self): # XML doc to be validated xml_content = base64.decodebytes(attachment.datas) self.check_content( - xml_content, "IT06363391001_00019.xml", - module_name="l10n_it_fatturapa_out_wt" + xml_content, "IT06363391001_00019.xml", module_name="l10n_it_fatturapa_out_wt" ) diff --git a/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml b/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml index 22613bfa9335..d4310470ec74 100644 --- a/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml +++ b/l10n_it_fatturapa_out_wt/views/account_invoice_it_dati_ritenuta.xml @@ -1,74 +1,107 @@ -