Skip to content

Commit

Permalink
[MIG] l10n_pt_stock_invoicexpress: migrate to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dreispt committed Dec 20, 2024
1 parent 0592a36 commit 26fdf8e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions l10n_pt_stock_invoicexpress/data/mail_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
Olá,
<br />
Enviamos em anexo a Guia de Trasporte <t t-out="object.name" />
<t t-if="object.ref">
relativa à sua encomenda <t t-out="object.ref" />
<t t-if="object.origin">
relativa à sua encomenda <t t-out="object.origin" />
</t>
.
<br /><br />
Expand Down
23 changes: 14 additions & 9 deletions l10n_pt_stock_invoicexpress/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import logging

from markupsafe import Markup

from odoo import _, api, exceptions, fields, models
from odoo.tools import format_datetime

Expand Down Expand Up @@ -178,16 +180,16 @@ def _prepare_invoicexpress_vals(self):
def _update_invoicexpress_status(self):
inv_xpress_link_name = _("View Document")
inv_xpress_link = _(
"<a class='btn btn-info mr-2' target='new' href=%(link)s>%(name)s</a>"
"<a class='btn btn-info mr-2' target='new' href={link}>{name}</a>"
).format(link=self.invoicexpress_permalink, name=inv_xpress_link_name)
msg = _(
"InvoiceXpress record has been created for this delivery order:<ul>"
"<li>Number: %(inv_xpress_num)s</li>"
"<li>%(inv_xpress_link)s</li></ul>"
"<li>Number: {inv_xpress_num}</li>"
"<li>{inv_xpress_link}</li></ul>"
).format(
inv_xpress_num=self.invoicexpress_number, inv_xpress_link=inv_xpress_link
)
self.message_post(body=msg)
self.message_post(body=Markup(msg))

def action_create_invoicexpress_delivery(self):
"""
Expand Down Expand Up @@ -225,9 +227,9 @@ def action_create_invoicexpress_delivery(self):
def _prepare_invoicexpress_email_vals(self, ignore_no_config=False):
self.ensure_one()
template_id = self.company_id.invoicexpress_delivery_template_id
values = template_id.generate_email(
self.id, ["subject", "body_html", "email_to", "email_cc"]
)
values = template_id._generate_template(

Check warning on line 230 in l10n_pt_stock_invoicexpress/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

l10n_pt_stock_invoicexpress/models/stock_picking.py#L228-L230

Added lines #L228 - L230 were not covered by tests
[self.id], ["subject", "body_html", "email_to", "email_cc"]
)[self.id]
if not template_id and not ignore_no_config:
raise exceptions.UserError(

Check warning on line 234 in l10n_pt_stock_invoicexpress/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

l10n_pt_stock_invoicexpress/models/stock_picking.py#L234

Added line #L234 was not covered by tests
_(
Expand Down Expand Up @@ -268,19 +270,22 @@ def action_send_invoicexpress_delivery(self, ignore_no_config=False):
)
msg = _(

Check warning on line 271 in l10n_pt_stock_invoicexpress/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

l10n_pt_stock_invoicexpress/models/stock_picking.py#L271

Added line #L271 was not covered by tests
"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"),
)
delivery.message_post(body=msg)
delivery.message_post(Markup(body=msg))

Check warning on line 278 in l10n_pt_stock_invoicexpress/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

l10n_pt_stock_invoicexpress/models/stock_picking.py#L278

Added line #L278 was not covered by tests

def button_validate(self):
"""
Automatically generate legal transport docs for PT customers
"""
res = super().button_validate()
if res is True: # do not enter if the result is a dict, only if it is True
missing_country = self.filtered(lambda x: not x.partner_id.country_id)
if missing_country:
raise exceptions.UserError(_("Please set the country of the partner."))

Check warning on line 288 in l10n_pt_stock_invoicexpress/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

l10n_pt_stock_invoicexpress/models/stock_picking.py#L288

Added line #L288 was not covered by tests
to_invoicexpress = self.filtered(
lambda x: x.partner_id.country_id.code == "PT"
)
Expand Down
5 changes: 4 additions & 1 deletion l10n_pt_stock_invoicexpress/views/res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +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="l10n_pt_account_invoicexpress.res_config_settings_view_form"
/>
<field name="arch" type="xml">
<div name="invoicexpress_options" position="after">
<div class="mt16">
Expand Down

0 comments on commit 26fdf8e

Please sign in to comment.