Skip to content

Commit

Permalink
[MIG] l10n_pt_account_invoicexpress: Migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aktiv-heli-kantawala committed Jul 25, 2022
1 parent 06a95b7 commit 768c081
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 68 deletions.
2 changes: 1 addition & 1 deletion l10n_pt_account_invoicexpress/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Portugal InvoiceXpress Integration",
"summary": "Portuguese certified invoices using InvoiceXpress",
"version": "14.0.4.1.3",
"version": "15.0.1.0.0",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/l10n-portugal",
Expand Down
57 changes: 30 additions & 27 deletions l10n_pt_account_invoicexpress/data/mail_template.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
<odoo noupdate="1">
<record id="email_template_invoice" model="mail.template">
<field name="name">InvoiceXpress: Send Invoice by Email</field>
<field name="model_id" ref="account.model_account_move" />
<field name="subject">Sua Fatura ${object.name | safe}</field>
<field name="email_to">${object.partner_id.email | safe}</field>
<field name="email_cc">${object.env.user.email | safe}</field>
<field name="body_html" type="html">
<p>
Olá,
<br />
Enviamos em anexo a fatura ${object.name | safe}
% if object.ref:
relativa à sua encomenda ${object.ref | safe}
% endif
.
<br /><br />
Obrigado
% if user.signature:
<br />
${user.signature | safe}
% endif
</p>
</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="auto_delete" eval="True" />
</record>
<odoo>
<data noupdate="1">
<record id="email_template_invoice" model="mail.template">
<field name="name">InvoiceXpress: Send Invoice by Email</field>
<field name="model_id" ref="account.model_account_move"/>
<field name="subject">Sua Fatura ${object.name | safe}</field>
<field name="email_to">${object.partner_id.email | safe}</field>
<field name="email_cc">${object.env.user.email | safe}</field>
<field name="body_html" type="html">
<p>
Olá,
<br/>
Enviamos em anexo a fatura ${object.name | safe}
% if object.ref:
relativa à sua encomenda ${object.ref | safe}
% endif
.
<br/>
<br/>
Obrigado
% if user.signature:
<br/>
${user.signature | safe}
% endif
</p>
</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="auto_delete" eval="True"/>
</record>
</data>
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down
2 changes: 1 addition & 1 deletion l10n_pt_account_invoicexpress/i18n/pt.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-11-18 20:36+0000\n"
"Last-Translator: Daniel Reis <[email protected]>\n"
Expand Down
11 changes: 3 additions & 8 deletions l10n_pt_account_invoicexpress/models/account_invoicexpress.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
import pprint

import requests
from werkzeug.urls import url_join

from odoo import _, exceptions, models
from werkzeug.urls import url_join

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -57,12 +56,8 @@ def _check_http_status(self, response):
# TODO: implement request rate limit
if response.status_code not in [200, 201]:
raise exceptions.ValidationError(
_(
"Error running API request ({} {}):\n{}".format(
response.status_code, response.reason, response.json()
)
)
)
_('Error running API request ({} {}):\n{}').format(response.status_code, response.reason,
response.json()))

def call(
self,
Expand Down
11 changes: 6 additions & 5 deletions l10n_pt_account_invoicexpress/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ class AccountMove(models.Model):

@api.depends("restrict_mode_hash_table", "state")
def _compute_show_reset_to_draft_button(self):
super()._compute_show_reset_to_draft_button()
res = super()._compute_show_reset_to_draft_button()
# InvoiceXpress generated invoices can't be set to Draft
self.filtered("invoicexpress_id").write({"show_reset_to_draft_button": False})
return res

@api.depends("move_type", "journal_id.use_invoicexpress")
def _compute_can_invoicexpress(self):
Expand Down Expand Up @@ -75,8 +76,8 @@ def _compute_invoicexpress_doc_type(self):
readonly=False,
copy=False,
help="Select the type of legal invoice document"
" to be created by InvoiceXpress."
" If unset, InvoiceXpress will not be used.",
" to be created by InvoiceXpress."
" If unset, InvoiceXpress will not be used.",
)

@api.constrains("journal_id", "company_id")
Expand Down Expand Up @@ -124,7 +125,7 @@ def _prepare_invoicexpress_lines(self):
items.append(
{
"name": line.product_id.default_code
or line.product_id.display_name,
or line.product_id.display_name,
"description": line._get_invoicexpress_descr(),
"unit_price": line.price_unit,
"quantity": line.quantity,
Expand Down Expand Up @@ -305,5 +306,5 @@ def _get_invoicexpress_descr(self):
ref = self.product_id.default_code
prefix = "[%s] " % ref
if ref and self.name.startswith(prefix):
res = self.name[len(prefix) :]
res = self.name[len(prefix):]
return res
1 change: 0 additions & 1 deletion l10n_pt_account_invoicexpress/tests/test_invoicexpress.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from unittest.mock import Mock, patch

import requests

from odoo import fields
from odoo.tests import Form, common

Expand Down
7 changes: 3 additions & 4 deletions l10n_pt_account_invoicexpress/views/account_journal_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
<record model="ir.ui.view" id="view_account_journal_form">
<field name="name">Journal Form: add Invoicexpress</field>
<field name="model">account.journal</field>
<field name="inherit_id" ref="account.view_account_journal_form" />
<field name="inherit_id" ref="account.view_account_journal_form"/>
<field name="arch" type="xml">

<page name="advanced_settings" position="inside">
<group
string="Invoicexpress"
attrs="{'invisible': [('type', '!=', 'sale')]}"
>
<field name="invoicexpress_doc_type" />
<field name="use_invoicexpress" groupe="base.group_no_one" />
<field name="invoicexpress_doc_type"/>
<field name="use_invoicexpress" groupe="base.group_no_one"/>
</group>
</page>

Expand Down
10 changes: 5 additions & 5 deletions l10n_pt_account_invoicexpress/views/account_move_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<record model="ir.ui.view" id="view_account_move_form">
<field name="name">account.move.form</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">

<div name="journal_div" position="after">
<field name="can_invoicexpress" invisible="1" />
<field name="can_invoicexpress_email" invisible="1" />
<field name="can_invoicexpress" invisible="1"/>
<field name="can_invoicexpress_email" invisible="1"/>
<field
name="invoicexpress_doc_type"
attrs="{'readonly': [('posted_before', '=', True)],
Expand All @@ -23,8 +23,8 @@
attrs="{'invisible': [('invoicexpress_id', '=', False)]}"
>
<group>
<field name="invoicexpress_id" />
<field name="invoicexpress_permalink" widget="url" />
<field name="invoicexpress_id"/>
<field name="invoicexpress_permalink" widget="url"/>
</group>
</page>
</xpath>
Expand Down
12 changes: 5 additions & 7 deletions l10n_pt_account_invoicexpress/views/res_company_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
<field name="name">InvoiceXpress Company Configuration</field>
<field name="model">res.company</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.view_company_form" />
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">

<notebook position="inside">
<page string="InvoiceXpress Configuration">
<group>
<field name="invoicexpress_account_name" />
<field name="invoicexpress_api_key" />
<field name="has_invoicexpress" groups="base.group_no_one" />
<field name="invoicexpress_template_id" />
<field name="invoicexpress_account_name"/>
<field name="invoicexpress_api_key"/>
<field name="has_invoicexpress" groups="base.group_no_one"/>
<field name="invoicexpress_template_id"/>
</group>
</page>
</notebook>

</field>
</record>
</odoo>
19 changes: 11 additions & 8 deletions l10n_pt_account_invoicexpress/views/res_config_settings.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<odoo>
<data>
<data noupdate="1">
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.invoicexpress</field>
<field name="priority" eval="200" />
<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="base_setup.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='integration']" position="after">
<div name="l10n_pt_account_invoicexpress">
Expand All @@ -15,9 +15,12 @@
<a
href="https://www.app.invoicexpress.com/users/api"
target="_blank"
><i
>
<i
class="fa fa-arrow-right"
/> Generate an API key</a>
/>
Generate an API key
</a>
<div
class="content-group"
name="invoicexpress_options"
Expand All @@ -27,21 +30,21 @@
for="invoicexpress_account_name"
string="InvoiceXpress Account Name"
/>
<field name="invoicexpress_account_name" />
<field name="invoicexpress_account_name"/>
</div>
<div class="mt16">
<label
for="invoicexpress_api_key"
string="InvoiceXpress API Key"
/>
<field name="invoicexpress_api_key" />
<field name="invoicexpress_api_key"/>
</div>
<div class="mt16">
<label
for="invoicexpress_template_id"
string="InvoiceXpress Invoice Email Template"
/>
<field name="invoicexpress_template_id" />
<field name="invoicexpress_template_id"/>
</div>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions setup/l10n_pt_account_invoicexpress/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 768c081

Please sign in to comment.