Skip to content

Commit

Permalink
[MIG] l10n_pt_account_invoicexpress: migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dreispt committed Dec 20, 2024
1 parent b363ead commit df28dca
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 64 deletions.
38 changes: 22 additions & 16 deletions l10n_pt_account_invoicexpress/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@ Portugal InvoiceXpress Integration
Generate Portuguese tax authority legal Invoices ("Faturas") using
InvoiceXpress.

**UPDATE November/2021:**

Invoices:

- Added support to the different documents types: Invoice, Invoice
Receipt, Simplified Invoice. The default document type is set on the
Journal, and can be changed on the Invoice form.
- Use the invoice commercial partner for the name and address, instead
of the invoice contact.
- Added support for the Terms and Conditions/Observations field
- Added to Credit Notes the link to the source Invoice

InvoiceXpress is a paid service. Visit https://invoicexpress.com for
more details.

Expand All @@ -58,8 +46,8 @@ generated document should be used. Having other print layouts for the
invoice is not allowed by the Portuguese Tax Authority.

Legal transport documents ("Guias de Transporte" e "Guias de Remessa)
are also supported through the extension module
"l10n_pt_stock_invoicexpress".
are also supported through an extension module. For this please ensure
that "l10n_pt_stock_invoicexpress" is installed.

**Table of contents**

Expand All @@ -72,13 +60,18 @@ Configuration
To configure:

- Navigate to Settings/General Settings.
- In the "General Settings" configuration section, locate the
"InvoiceXpress" subsection: There you can set:

- In the "Invoicing" configuration section, locate the "InvoiceXpress"
subsection: There you can set:

- InvoiceXpress Account Name
- InvoiceXpress API Key
- InvoiceXpress Invoice Email Template

- In "Invoicing/Accounting" configuration section, locate the Sales
Journals, and set the "InvoiceXpress Doc Type". This is required
before invoices before any invoice can be created.

The email template is used to prepare the details for the email the
InvoiceXpress service sends with the invoice:

Expand Down Expand Up @@ -117,6 +110,19 @@ send an email with a copy of the legal document.
The Invoice form shows an "InvoiceXpress" tab containing details for the
corresponding InvoiceXpress document.

Invoices:

- Added support to the different documents types: Invoice, Invoice
Receipt, Simplified Invoice. The default document type is set on the
Journal, and can be changed on the Invoice form.
- Use the invoice commercial partner for the name and address, instead
of the invoice contact.
- Added support for the Terms and Conditions/Observations field
- Added to Credit Notes the link to the source Invoice

The monthly SAF-T file should be downloaded from the InvoiceXpress
website.

Bug Tracker
===========

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,19 @@ def _check_http_status(self, response):
"""
# TODO: implement request rate limit
if response.status_code not in [200, 201]:
if response.json():
msg = "\n".join(
"- " + (x.get("error") or repr(x))
for x in response.json().get("errors", [])
)
else:
msg = repr(response.json())
raise exceptions.ValidationError(
_("Error running API request (%(status_code)s %(reason)s):\n%(json)s")
% {
"status_code": response.status_code,
"reason": response.reason,
"json": response.json(),
"json": msg,
}
)

Expand Down
18 changes: 10 additions & 8 deletions l10n_pt_account_invoicexpress/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import uuid

from markupsafe import Markup

from odoo import _, api, exceptions, fields, models


Expand Down Expand Up @@ -202,7 +204,7 @@ def _update_invoicexpress_status(self):
"<ul><li>InvoiceXpress Id: {inv_xpress_id}</li>"
"<li>{inv_xpress_link}</li></ul>"
).format(inv_xpress_id=self.invoicexpress_id, inv_xpress_link=inv_xpress_link)
self.message_post(body=msg)
self.message_post(body=Markup(msg))

def action_create_invoicexpress_invoice(self):
InvoiceXpress = self.env["account.invoicexpress"]
Expand Down Expand Up @@ -240,7 +242,7 @@ def action_create_invoicexpress_invoice(self):
)
)
prefix = self._get_invoicexpress_prefix(doctype)
invx_number = f"{prefix}, {seqnum}" if prefix else seqnum
invx_number = f"{prefix} {seqnum}" if prefix else seqnum
if invoice.payment_reference == invoice.name:
invoice.payment_reference = invx_number
invoice.name = invx_number
Expand All @@ -249,16 +251,16 @@ def action_create_invoicexpress_invoice(self):
def _prepare_invoicexpress_email_vals(self, ignore_no_config=False):
self.ensure_one()
template_id = self.company_id.invoicexpress_template_id
values = template_id.generate_email(
self.id, ["subject", "body_html", "email_to", "email_cc"]
)
if not template_id and not ignore_no_config:
raise exceptions.UserError(
_(
"Please configure the InvoiceXpress email template"
" at Settings > General Setting, InvoiceXpress section"
)
)
values = template_id._generate_template(
[self.id], ["subject", "body_html", "email_to", "email_cc"]
)[self.id]
if not values.get("email_to") and not ignore_no_config:
raise exceptions.UserError(_("No address to send invoice email to."))
email_data = None
Expand Down Expand Up @@ -288,12 +290,12 @@ def action_send_invoicexpress_email(self, ignore_no_config=False):
InvoiceXpress.call(invoice.company_id, endpoint, "PUT", payload=payload)
msg = _(
"Email sent by InvoiceXpress:<ul><li>To: "
"%(email)s</li><li>Cc: %(cc)s</li></ul>"
"{email}</li><li>Cc:{cc}</li></ul>"
).format(
email=payload["message"]["client"]["email"],
cc=payload["message"]["cc"] or _("None"),
)
invoice.message_post(body=msg)
invoice.message_post(body=Markup(msg))

def _post(self, soft=True):
res = super()._post(soft=soft)
Expand Down Expand Up @@ -337,7 +339,7 @@ def _mark_invoice_paid(self):
)
)
msg = _("InvoiceXpress record has been modified to Paid.")
self.message_post(body=msg)
self.message_post(body=Markup(msg))


class AccountMoveLine(models.Model):
Expand Down
6 changes: 5 additions & 1 deletion l10n_pt_account_invoicexpress/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
To configure:

- Navigate to Settings/General Settings.
- In the "General Settings" configuration section, locate the
- In the "Invoicing" configuration section, locate the
"InvoiceXpress" subsection: There you can set:
- InvoiceXpress Account Name
- InvoiceXpress API Key
- InvoiceXpress Invoice Email Template

- In "Invoicing/Accounting" configuration section, locate the
Sales Journals, and set the "InvoiceXpress Doc Type".
This is required before invoices before any invoice can be created.

The email template is used to prepare the details for the email the
InvoiceXpress service sends with the invoice:

Expand Down
15 changes: 2 additions & 13 deletions l10n_pt_account_invoicexpress/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
Generate Portuguese tax authority legal Invoices ("Faturas") using
InvoiceXpress.

**UPDATE November/2021:**

Invoices:

- Added support to the different documents types: Invoice, Invoice
Receipt, Simplified Invoice. The default document type is set on the
Journal, and can be changed on the Invoice form.
- Use the invoice commercial partner for the name and address, instead
of the invoice contact.
- Added support for the Terms and Conditions/Observations field
- Added to Credit Notes the link to the source Invoice

InvoiceXpress is a paid service. Visit <https://invoicexpress.com> for
more details.
Expand All @@ -28,5 +17,5 @@ generated document should be used. Having other print layouts for the
invoice is not allowed by the Portuguese Tax Authority.

Legal transport documents ("Guias de Transporte" e "Guias de Remessa)
are also supported through the extension module
"l10n_pt_stock_invoicexpress".
are also supported through an extension module. For this please ensure that
"l10n_pt_stock_invoicexpress" is installed.
13 changes: 13 additions & 0 deletions l10n_pt_account_invoicexpress/readme/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,16 @@ send an email with a copy of the legal document.

The Invoice form shows an "InvoiceXpress" tab containing details for the
corresponding InvoiceXpress document.

Invoices:

- Added support to the different documents types: Invoice, Invoice
Receipt, Simplified Invoice. The default document type is set on the
Journal, and can be changed on the Invoice form.
- Use the invoice commercial partner for the name and address, instead
of the invoice contact.
- Added support for the Terms and Conditions/Observations field
- Added to Credit Notes the link to the source Invoice


The monthly SAF-T file should be downloaded from the InvoiceXpress website.
34 changes: 19 additions & 15 deletions l10n_pt_account_invoicexpress/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,6 @@ <h1 class="title">Portugal InvoiceXpress Integration</h1>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-portugal/tree/17.0/l10n_pt_account_invoicexpress"><img alt="OCA/l10n-portugal" src="https://img.shields.io/badge/github-OCA%2Fl10n--portugal-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-portugal-17-0/l10n-portugal-17-0-l10n_pt_account_invoicexpress"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-portugal&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Generate Portuguese tax authority legal Invoices (“Faturas”) using
InvoiceXpress.</p>
<p><strong>UPDATE November/2021:</strong></p>
<p>Invoices:</p>
<ul class="simple">
<li>Added support to the different documents types: Invoice, Invoice
Receipt, Simplified Invoice. The default document type is set on the
Journal, and can be changed on the Invoice form.</li>
<li>Use the invoice commercial partner for the name and address, instead
of the invoice contact.</li>
<li>Added support for the Terms and Conditions/Observations field</li>
<li>Added to Credit Notes the link to the source Invoice</li>
</ul>
<p>InvoiceXpress is a paid service. Visit <a class="reference external" href="https://invoicexpress.com">https://invoicexpress.com</a> for
more details.</p>
<p>Once the InvoiceXpress connection is configured, the invoice CONFIRM
Expand All @@ -394,8 +383,8 @@ <h1 class="title">Portugal InvoiceXpress Integration</h1>
generated document should be used. Having other print layouts for the
invoice is not allowed by the Portuguese Tax Authority.</p>
<p>Legal transport documents (“Guias de Transporte” e “Guias de Remessa)
are also supported through the extension module
“l10n_pt_stock_invoicexpress”.</p>
are also supported through an extension module. For this please ensure
that “l10n_pt_stock_invoicexpress” is installed.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand All @@ -415,13 +404,16 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>To configure:</p>
<ul class="simple">
<li>Navigate to Settings/General Settings.</li>
<li>In the “General Settings” configuration section, locate the
“InvoiceXpress” subsection: There you can set:<ul>
<li>In the “Invoicing” configuration section, locate the “InvoiceXpress”
subsection: There you can set:<ul>
<li>InvoiceXpress Account Name</li>
<li>InvoiceXpress API Key</li>
<li>InvoiceXpress Invoice Email Template</li>
</ul>
</li>
<li>In “Invoicing/Accounting” configuration section, locate the Sales
Journals, and set the “InvoiceXpress Doc Type”. This is required
before invoices before any invoice can be created.</li>
</ul>
<p>The email template is used to prepare the details for the email the
InvoiceXpress service sends with the invoice:</p>
Expand Down Expand Up @@ -454,6 +446,18 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
send an email with a copy of the legal document.</p>
<p>The Invoice form shows an “InvoiceXpress” tab containing details for the
corresponding InvoiceXpress document.</p>
<p>Invoices:</p>
<ul class="simple">
<li>Added support to the different documents types: Invoice, Invoice
Receipt, Simplified Invoice. The default document type is set on the
Journal, and can be changed on the Invoice form.</li>
<li>Use the invoice commercial partner for the name and address, instead
of the invoice contact.</li>
<li>Added support for the Terms and Conditions/Observations field</li>
<li>Added to Credit Notes the link to the source Invoice</li>
</ul>
<p>The monthly SAF-T file should be downloaded from the InvoiceXpress
website.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
Expand Down
2 changes: 1 addition & 1 deletion l10n_pt_account_invoicexpress/tests/test_invoicexpress.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ def test_101_create_invoicexpress_invoice(self, mock_request):
invoice.action_post()
self.assertEqual(invoice.invoicexpress_doc_type, "invoice_receipt")
self.assertEqual(invoice.invoicexpress_id, "12345678")
self.assertEqual(invoice.name, "FR, MYSEQ/123")
self.assertEqual(invoice.name, "FR MYSEQ/123")
2 changes: 1 addition & 1 deletion l10n_pt_account_invoicexpress/views/res_company_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<page string="InvoiceXpress Configuration">
<group>
<field name="invoicexpress_account_name" />
<field name="invoicexpress_api_key" />
<field name="invoicexpress_api_key" password="True" />
<field name="has_invoicexpress" groups="base.group_no_one" />
<field name="invoicexpress_template_id" />
</group>
Expand Down
12 changes: 4 additions & 8 deletions l10n_pt_account_invoicexpress/views/res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
<field name="name">res.config.settings.view.form.invoicexpress</field>
<field name="priority" eval="200" />
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form" />
<field name="inherit_id" ref="account.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//block[@name='integration']" position="after">
<block
title="InvoiceXpress"
groups="base.group_no_one"
name="invoice_express"
>
<xpath expr="//app[@name='account']" position="inside">
<block title="InvoiceXpress" name="invoice_express">
<setting
string="InvoiceXpress"
help="Integration with InvoiceXpress for generating invoices and managing API settings"
Expand All @@ -34,7 +30,7 @@
for="invoicexpress_api_key"
string="InvoiceXpress API Key"
/>
<field name="invoicexpress_api_key" />
<field name="invoicexpress_api_key" password="True" />
</div>
<div class="mt16">
<label
Expand Down

0 comments on commit df28dca

Please sign in to comment.