Skip to content

Commit

Permalink
[MIG] l10n_pt_account_invoicexpress: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
aktiv-heli-kantawala committed Jul 25, 2022
1 parent 768c081 commit d14b0eb
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 106 deletions.
58 changes: 28 additions & 30 deletions l10n_pt_account_invoicexpress/data/mail_template.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
<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 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>
9 changes: 6 additions & 3 deletions l10n_pt_account_invoicexpress/models/account_invoicexpress.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import pprint

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

from odoo import _, exceptions, models

_logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -56,8 +57,10 @@ 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
8 changes: 4 additions & 4 deletions l10n_pt_account_invoicexpress/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,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 @@ -125,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 @@ -306,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: 1 addition & 0 deletions l10n_pt_account_invoicexpress/tests/test_invoicexpress.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest.mock import Mock, patch

import requests

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

Expand Down
9 changes: 3 additions & 6 deletions l10n_pt_account_invoicexpress/views/account_journal_view.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<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>

</field>
</record>

</odoo>
12 changes: 5 additions & 7 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,11 @@
<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 +22,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 All @@ -48,7 +47,6 @@
attrs="{'invisible': ['|', ('can_invoicexpress_email', '=', False), ('invoicexpress_id', '=', False)]}"
/>
</button>

</field>
</record>
</odoo>
10 changes: 5 additions & 5 deletions l10n_pt_account_invoicexpress/views/res_company_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<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>
Expand Down
95 changes: 44 additions & 51 deletions l10n_pt_account_invoicexpress/views/res_config_settings.xml
Original file line number Diff line number Diff line change
@@ -1,58 +1,51 @@
<odoo>
<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="model">res.config.settings</field>
<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">
<h2>InvoiceXpress</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_right_pane">
<a
href="https://www.app.invoicexpress.com/users/api"
target="_blank"
>
<i
class="fa fa-arrow-right"
<odoo 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="model">res.config.settings</field>
<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">
<h2>InvoiceXpress</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_right_pane">
<a
href="https://www.app.invoicexpress.com/users/api"
target="_blank"
>
<i class="fa fa-arrow-right" />
Generate an API key
</a>
<div class="content-group" name="invoicexpress_options">
<div class="mt16">
<label
for="invoicexpress_account_name"
string="InvoiceXpress Account Name"
/>
Generate an API key
</a>
<div
class="content-group"
name="invoicexpress_options"
>
<div class="mt16">
<label
for="invoicexpress_account_name"
string="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"/>
</div>
<div class="mt16">
<label
for="invoicexpress_template_id"
string="InvoiceXpress Invoice Email Template"
/>
<field name="invoicexpress_template_id"/>
</div>
<field name="invoicexpress_account_name" />
</div>
<div class="mt16">
<label
for="invoicexpress_api_key"
string="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" />
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</data>
</div>
</xpath>
</field>
</record>
</odoo>

0 comments on commit d14b0eb

Please sign in to comment.