Skip to content

Commit

Permalink
[18.0][MIG] companyweb_base: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BertVGroenendael committed Nov 20, 2024
1 parent be1d6ae commit a448fab
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions companyweb_base/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Contributors

- Xavier Bouquiaux <[email protected]>
- Stéphane Bidoul <[email protected]>
- Bert Van Groenendael <[email protected]>

Other credits
-------------
Expand Down
8 changes: 4 additions & 4 deletions companyweb_base/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import zeep

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

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -492,7 +492,7 @@ def cweb_button_enhance(self):
based on status make decision
When status is ok -> populate fields"""
if not self.env.user.has_group("companyweb_base.cweb_download"):
raise UserError(_("Companyweb : You don't have access"))
raise UserError(self.env._("Companyweb : You don't have access"))
user_login = self.env.user.cweb_login
user_password = self.env.user.cweb_password
user_lang = self.env.context.get("lang")[:2].upper()
Expand Down Expand Up @@ -520,7 +520,7 @@ def cweb_button_enhance(self):
return self._cweb_call_wizard_credentials("Enter Companyweb credentials")
elif r["StatusCode"] != 0:
raise UserError(
_("Companyweb status : {status} : {message} ").format(
self.env._("Companyweb status : {status} : {message} ").format(
status=r["StatusCode"], message=r["StatusMessage"]
)
)
Expand All @@ -536,7 +536,7 @@ def cweb_button_enhance(self):

def cweb_button_copy_address(self):
if not self.env.user.has_group("companyweb_base.cweb_view"):
raise UserError(_("Companyweb : You don't have access"))
raise UserError(self.env._("Companyweb : You don't have access"))
self.street = self.cweb_street
self.city = self.cweb_city
self.zip = self.cweb_zip
Expand Down
1 change: 1 addition & 0 deletions companyweb_base/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Xavier Bouquiaux \<<[email protected]>\>
- Stéphane Bidoul \<<[email protected]>\>
- Bert Van Groenendael \<<[email protected]>\>
1 change: 1 addition & 0 deletions companyweb_base/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
<ul class="simple">
<li>Xavier Bouquiaux &lt;<a class="reference external" href="mailto:xavier.bouquiaux&#64;acsone.eu">xavier.bouquiaux&#64;acsone.eu</a>&gt;</li>
<li>Stéphane Bidoul &lt;<a class="reference external" href="mailto:stephane.bidoul&#64;acsone.eu">stephane.bidoul&#64;acsone.eu</a>&gt;</li>
<li>Bert Van Groenendael &lt;<a class="reference external" href="mailto:bert.vangroenendael&#64;dynapps.eu">bert.vangroenendael&#64;dynapps.eu</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
Expand Down
20 changes: 20 additions & 0 deletions companyweb_base/tests/test_api_cweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def _request_handler(cls, s: Session, r: PreparedRequest, /, **kw):

def setUp(self, *args, **kwargs):
super().setUp(*args, **kwargs)

self._install_language("fr")

demo_user = self.env.ref("base.user_demo")
demo_user.cweb_login = os.environ.get("COMPANYWEB_TEST_LOGIN", "cwebtestlogin")
demo_user.cweb_password = os.environ.get(
Expand All @@ -57,6 +60,23 @@ def _get_vcr_kwargs(self, **kwargs):
"decode_compressed_response": True,
}

def _install_language(self, lang_code="en_US"):
"""Install the language if not already installed."""
# Check if the language already exists
lang = self.env["res.lang"].search([("code", "=", lang_code)], limit=1)
if not lang:
# If the language doesn't exist, create and load it
lang_id = self.env.ref(f"base.lang_{lang_code}").id
lang_wizard = self.env["base.language.install"].create(
{
"lang_ids": [Command.link(lang_id)],
}
)
lang_wizard.lang_install()

# Set the language as active
self.env["res.lang"].search([("code", "=", lang_code)]).write({"active": True})

@freeze_time("2021-03-23") # because the login hash includes the date
def test_cweb_button(self):
# companyweb response depends on request language
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vcr_unittest

0 comments on commit a448fab

Please sign in to comment.