diff --git a/l10n_it_fatturapa_in/README.rst b/l10n_it_fatturapa_in/README.rst index ae20a2f5df03..6ef0b35fb13f 100644 --- a/l10n_it_fatturapa_in/README.rst +++ b/l10n_it_fatturapa_in/README.rst @@ -14,13 +14,13 @@ ITA - Fattura elettronica - Ricezione :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_in + :target: https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_fatturapa_in :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-12-0/l10n-italy-12-0-l10n_it_fatturapa_in + :target: https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-0-l10n_it_fatturapa_in :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/12.0 + :target: https://runbot.odoo-community.org/runbot/122/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -91,7 +91,7 @@ See also the README file of l10n_it_fatturapa module. For every supplier, it is possible to set the 'E-bills Detail Level': - - Minimum level: Bill is created with no lines; User will have to create them, according to what specified in the electronic bill + - Minimum level: Bill is created with no lines; User will have to create them, according to what specified in the electronic bill - Maximum level: Every line contained in electronic bill will create a line in bill Moreover, in supplier form you can set the 'E-bill Default Product': this product will be used, during generation of bills, when no other possible product is found. Tax and account of bill line will be set according to what configured in the product. @@ -152,7 +152,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. @@ -174,6 +174,7 @@ Contributors * Sergio Zanchetta * Giovanni Serra * Gianmarco Conte +* Marco Colombo Maintainers ~~~~~~~~~~~ @@ -188,6 +189,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_in/__manifest__.py b/l10n_it_fatturapa_in/__manifest__.py index 6f8b249018bd..91094d0a36eb 100644 --- a/l10n_it_fatturapa_in/__manifest__.py +++ b/l10n_it_fatturapa_in/__manifest__.py @@ -6,7 +6,7 @@ { "name": "ITA - Fattura elettronica - Ricezione", - "version": "12.0.2.1.3", + "version": "14.0.2.1.3", "development_status": "Beta", "category": "Localization/Italy", "summary": "Ricezione fatture elettroniche", diff --git a/l10n_it_fatturapa_in/i18n/l10n_it_fatturapa_in.pot b/l10n_it_fatturapa_in/i18n/l10n_it_fatturapa_in.pot index 8457069a682d..ed161b23a446 100644 --- a/l10n_it_fatturapa_in/i18n/l10n_it_fatturapa_in.pot +++ b/l10n_it_fatturapa_in/i18n/l10n_it_fatturapa_in.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: <>\n" "Language-Team: \n" diff --git a/l10n_it_fatturapa_in/models/account.py b/l10n_it_fatturapa_in/models/account.py index e5a97431f61f..1a41776f7a99 100644 --- a/l10n_it_fatturapa_in/models/account.py +++ b/l10n_it_fatturapa_in/models/account.py @@ -1,12 +1,10 @@ from odoo import _, api, fields, models -from odoo.exceptions import UserError, ValidationError +from odoo.exceptions import ValidationError from odoo.tools import float_compare -import odoo.addons.decimal_precision as dp - class AccountInvoice(models.Model): - _inherit = "account.invoice" + _inherit = "account.move" fatturapa_attachment_in_id = fields.Many2one( "fatturapa.attachment.in", "E-bill Import File", ondelete="restrict", copy=False @@ -42,78 +40,28 @@ class AccountInvoice(models.Model): e_invoice_received_date = fields.Date(string="E-Bill Received Date") - @api.multi @api.depends( - "invoice_line_ids.price_subtotal", - "tax_line_ids.amount", - "tax_line_ids.amount_rounding", - "currency_id", - "company_id", - "date_invoice", - "type", - "efatt_rounding", + "line_ids.matched_debit_ids.debit_move_id.move_id.line_ids.amount_residual", + "line_ids.matched_debit_ids.debit_move_id.move_id.line_ids.amount_residual_currency", # noqa: B950 + "line_ids.matched_credit_ids.credit_move_id.move_id.line_ids.amount_residual", + "line_ids.matched_credit_ids.credit_move_id.move_id.line_ids.amount_residual_currency", # noqa: B950 + "line_ids.debit", + "line_ids.credit", + "line_ids.currency_id", + "line_ids.amount_currency", + "line_ids.amount_residual", + "line_ids.amount_residual_currency", + "line_ids.payment_id.state", + "line_ids.full_reconcile_id", ) def _compute_amount(self): super(AccountInvoice, self)._compute_amount() for inv in self: if inv.efatt_rounding != 0: inv.amount_total += inv.efatt_rounding - amount_total_company_signed = inv.amount_total - if ( - inv.currency_id - and inv.company_id - and inv.currency_id != inv.company_id.currency_id - ): - currency_id = inv.currency_id - amount_total_company_signed = currency_id._convert( - inv.amount_total, - inv.company_id.currency_id, - inv.company_id, - inv.date_invoice or fields.Date.today(), - ) - sign = inv.type in ["in_refund", "out_refund"] and -1 or 1 - inv.amount_total_company_signed = amount_total_company_signed * sign + sign = inv.move_type in ["in_refund", "out_refund"] and -1 or 1 inv.amount_total_signed = inv.amount_total * sign - @api.model - def invoice_line_move_line_get(self): - """Append global rounding move lines""" - res = super().invoice_line_move_line_get() - - if self.efatt_rounding != 0: - if self.efatt_rounding > 0: - arrotondamenti_account_id = ( - self.env.user.company_id.arrotondamenti_passivi_account_id - ) - if not arrotondamenti_account_id: - raise UserError( - _("Round down account is not set " "in Accounting Settings") - ) - name = _("Rounding down") - else: - arrotondamenti_account_id = ( - self.env.user.company_id.arrotondamenti_attivi_account_id - ) - if not arrotondamenti_account_id: - raise UserError( - _("Round up account is not set " "in Accounting Settings") - ) - name = _("Rounding up") - - res.append( - { - "type": "global_rounding", - "name": name, - "price_unit": self.efatt_rounding, - "quantity": 1, - "price": self.efatt_rounding, - "account_id": arrotondamenti_account_id.id, - "invoice_id": self.id, - } - ) - return res - - @api.multi def invoice_validate(self): for invoice in self: if ( @@ -216,18 +164,22 @@ def e_inv_dati_ritenuta(self): return error_message @api.depends( - "type", + "move_type", "state", "fatturapa_attachment_in_id", "amount_untaxed", "amount_tax", "amount_total", - "reference", - "date_invoice", + "ref", + "invoice_date", ) def _compute_e_invoice_validation_error(self): + self.ensure_one() + self.e_invoice_validation_error = False + self.e_invoice_validation_message = False + bills_to_check = self.filtered( - lambda inv: inv.type in ["in_invoice", "in_refund"] + lambda inv: inv.move_type in ["in_invoice", "in_refund"] and inv.state in ["draft", "open", "paid"] and inv.fatturapa_attachment_in_id ) @@ -250,21 +202,24 @@ def _compute_e_invoice_validation_error(self): if error_message: error_messages.append(error_message) - if bill.e_invoice_reference and bill.reference != bill.e_invoice_reference: + if ( + bill.e_invoice_reference + and bill.payment_reference != bill.e_invoice_reference + ): error_messages.append( _( "Vendor reference ({bill_vendor_ref}) " "does not match with " "e-bill vendor reference ({e_bill_vendor_ref})" ).format( - bill_vendor_ref=bill.reference or "", + bill_vendor_ref=bill.payment_reference or "", e_bill_vendor_ref=bill.e_invoice_reference, ) ) if ( bill.e_invoice_date_invoice - and bill.e_invoice_date_invoice != bill.date_invoice + and bill.e_invoice_date_invoice != bill.invoice_date ): error_messages.append( _( @@ -272,7 +227,7 @@ def _compute_e_invoice_validation_error(self): "does not match with " "e-bill invoice date ({e_bill_date_invoice})" ).format( - bill_date_invoice=bill.date_invoice or "", + bill_date_invoice=bill.invoice_date or "", e_bill_date_invoice=bill.e_invoice_date_invoice, ) ) @@ -282,27 +237,25 @@ def _compute_e_invoice_validation_error(self): bill.e_invoice_validation_error = True bill.e_invoice_validation_message = ",\n".join(error_messages) + "." - @api.multi def name_get(self): result = super(AccountInvoice, self).name_get() res = [] for tup in result: invoice = self.browse(tup[0]) - if invoice.type in ("in_invoice", "in_refund"): + if invoice.move_type in ("in_invoice", "in_refund"): name = "{}, {}".format(tup[1], invoice.partner_id.name) if invoice.amount_total_signed: name += ", {} {}".format( invoice.amount_total_signed, invoice.currency_id.symbol, ) - if invoice.origin: - name += ", %s" % invoice.origin + if invoice.invoice_origin: + name += ", %s" % invoice.invoice_origin res.append((invoice.id, name)) else: res.append(tup) return res - @api.multi def remove_attachment_link(self): self.ensure_one() self.fatturapa_attachment_in_id = False @@ -359,7 +312,7 @@ def process_negative_lines(self): # if every line is negative, change them all for line in self.invoice_line_ids: line.price_unit = -line.price_unit - self.compute_taxes() + self._recompute_dynamic_lines(recompute_all_taxes=True) class FatturapaArticleCode(models.Model): @@ -379,13 +332,13 @@ class AccountInvoiceLine(models.Model): # '2.2.1.3', '2.2.1.6', '2.2.1.7', # '2.2.1.8', '2.1.1.10' # ] - _inherit = "account.invoice.line" + _inherit = "account.move.line" fatturapa_attachment_in_id = fields.Many2one( "fatturapa.attachment.in", "E-bill Import File", readonly=True, - related="invoice_id.fatturapa_attachment_in_id", + related="move_id.fatturapa_attachment_in_id", ) @@ -400,7 +353,7 @@ class EInvoiceLine(models.Model): _name = "einvoice.line" _description = "E-invoice line" invoice_id = fields.Many2one( - "account.invoice", "Bill", readonly=True, ondelete="cascade" + "account.move", "Bill", readonly=True, ondelete="cascade" ) line_number = fields.Integer("Line Number", readonly=True) service_type = fields.Char("Sale Provision Type", readonly=True) @@ -408,15 +361,11 @@ class EInvoiceLine(models.Model): "fatturapa.article.code", "e_invoice_line_id", "Articles Code", readonly=True ) name = fields.Char("Description", readonly=True) - qty = fields.Float( - "Quantity", readonly=True, digits=dp.get_precision("Product Unit of Measure") - ) + qty = fields.Float("Quantity", readonly=True, digits="Product Unit of Measure") uom = fields.Char("Unit of measure", readonly=True) period_start_date = fields.Date("Period Start Date", readonly=True) period_end_date = fields.Date("Period End Date", readonly=True) - unit_price = fields.Float( - "Unit Price", readonly=True, digits=dp.get_precision("Product Price") - ) + unit_price = fields.Float("Unit Price", readonly=True, digits="Product Price") discount_rise_price_ids = fields.One2many( "discount.rise.price", "e_invoice_line_id", diff --git a/l10n_it_fatturapa_in/models/attachment.py b/l10n_it_fatturapa_in/models/attachment.py index 0125d3bf6f18..6f8dcf6e1cc5 100644 --- a/l10n_it_fatturapa_in/models/attachment.py +++ b/l10n_it_fatturapa_in/models/attachment.py @@ -18,7 +18,7 @@ class FatturaPAAttachmentIn(models.Model): string="E-bill file name", related="ir_attachment_id.name", store=True ) in_invoice_ids = fields.One2many( - "account.invoice", + "account.move", "fatturapa_attachment_in_id", string="In Bills", readonly=True, @@ -62,6 +62,8 @@ class FatturaPAAttachmentIn(models.Model): @api.depends("in_invoice_ids.e_invoice_validation_error") def _compute_e_invoice_validation_error(self): for att in self: + att.e_invoice_validation_error = False + att.e_invoice_validation_message = False bills_with_error = att.in_invoice_ids.filtered( lambda b: b.e_invoice_validation_error ) @@ -78,41 +80,38 @@ def _compute_e_invoice_validation_error(self): ) att.e_invoice_validation_message = "\n\n".join(error_messages) - @api.onchange("datas_fname") - def onchagne_datas_fname(self): - self.name = self.datas_fname - def get_xml_string(self): return self.ir_attachment_id.get_xml_string() - @api.multi @api.depends("ir_attachment_id.datas") def _compute_xml_data(self): for att in self: + att.xml_supplier_id = False + att.invoices_number = False + att.invoices_total = False + att.invoices_date = False wiz_obj = self.env["wizard.import.fatturapa"].with_context( from_attachment=att ) - fatt = wiz_obj.get_invoice_obj(att) - cedentePrestatore = fatt.FatturaElettronicaHeader.CedentePrestatore - partner_id = wiz_obj.getCedPrest(cedentePrestatore) - att.xml_supplier_id = partner_id - att.invoices_number = len(fatt.FatturaElettronicaBody) - att.invoices_total = 0 - invoices_date = [] - for invoice_body in fatt.FatturaElettronicaBody: - dgd = invoice_body.DatiGenerali.DatiGeneraliDocumento - att.invoices_total += float(dgd.ImportoTotaleDocumento or 0) - invoice_date = format_date( - att.with_context(lang=att.env.user.lang).env, - fields.Date.from_string( - dgd.DatiGenerali.DatiGeneraliDocumento.Data - ), - ) - if invoice_date not in invoices_date: - invoices_date.append(invoice_date) - att.invoices_date = " ".join(invoices_date) + if wiz_obj: + fatt = wiz_obj.get_invoice_obj(att) + cedentePrestatore = fatt.FatturaElettronicaHeader.CedentePrestatore + partner_id = wiz_obj.getCedPrest(cedentePrestatore) + att.xml_supplier_id = partner_id + att.invoices_number = len(fatt.FatturaElettronicaBody) + att.invoices_total = 0 + invoices_date = [] + for invoice_body in fatt.FatturaElettronicaBody: + dgd = invoice_body.DatiGenerali.DatiGeneraliDocumento + att.invoices_total += float(dgd.ImportoTotaleDocumento or 0) + invoice_date = format_date( + att.with_context(lang=att.env.user.lang).env, + fields.Date.from_string(dgd.Data), + ) + if invoice_date not in invoices_date: + invoices_date.append(invoice_date) + att.invoices_date = " ".join(invoices_date) - @api.multi @api.depends("in_invoice_ids") def _compute_registered(self): for att in self: @@ -132,7 +131,6 @@ def extract_attachments(self, AttachmentsData, invoice_id): _attach_dict = { "name": name, "datas": base64.b64encode(content), - "datas_fname": name, "description": attach.DescrizioneAttachment or "", "compression": attach.AlgoritmoCompressione or "", "format": attach.FormatoAttachment or "", diff --git a/l10n_it_fatturapa_in/readme/CONTRIBUTORS.rst b/l10n_it_fatturapa_in/readme/CONTRIBUTORS.rst index 1a84bfecc996..d592bfd1ebf4 100644 --- a/l10n_it_fatturapa_in/readme/CONTRIBUTORS.rst +++ b/l10n_it_fatturapa_in/readme/CONTRIBUTORS.rst @@ -4,3 +4,4 @@ * Sergio Zanchetta * Giovanni Serra * Gianmarco Conte +* Marco Colombo diff --git a/l10n_it_fatturapa_in/security/ir.model.access.csv b/l10n_it_fatturapa_in/security/ir.model.access.csv index 056d7bcb6181..6ce8e04fa203 100644 --- a/l10n_it_fatturapa_in/security/ir.model.access.csv +++ b/l10n_it_fatturapa_in/security/ir.model.access.csv @@ -3,3 +3,6 @@ access_fatturapa_attachment_in,access_fatturapa_attachment_in,model_fatturapa_at access_fatturapa_article_code,access_fatturapa_article_code,model_fatturapa_article_code,account.group_account_invoice,1,1,1,1 access_einvoice_line,access_einvoice_line,model_einvoice_line,account.group_account_invoice,1,1,1,1 access_einvoice_line_other_data,access_einvoice_line_other_data,model_einvoice_line_other_data,account.group_account_invoice,1,1,1,1 +access_wizard_import_fatturapa,access_wizard_import_fatturapa,model_wizard_import_fatturapa,account.group_account_invoice,1,1,1,1 +access_wizard_link_to_invoice,access_wizard_link_to_invoice,model_wizard_link_to_invoice,account.group_account_invoice,1,1,1,1 +access_wizard_link_to_invoice_line,access_wizard_link_to_invoice_line,model_wizard_link_to_invoice_line,account.group_account_invoice,1,1,1,1 diff --git a/l10n_it_fatturapa_in/security/rules.xml b/l10n_it_fatturapa_in/security/rules.xml index 6d4bc882d501..0fd6a0e2cde6 100644 --- a/l10n_it_fatturapa_in/security/rules.xml +++ b/l10n_it_fatturapa_in/security/rules.xml @@ -9,7 +9,7 @@ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + >['|',('company_id','=',False),('company_id','in',company_ids)] diff --git a/l10n_it_fatturapa_in/static/description/index.html b/l10n_it_fatturapa_in/static/description/index.html index 2b75910494fd..44ea8f854030 100644 --- a/l10n_it_fatturapa_in/static/description/index.html +++ b/l10n_it_fatturapa_in/static/description/index.html @@ -3,7 +3,7 @@ - + ITA - Fattura elettronica - Ricezione