Skip to content

Commit 725eeeb

Browse files
[ADD] atm_averba: new module
1 parent 452fcf8 commit 725eeeb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3320
-0
lines changed

atm_averba_base/README.rst

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
================
2+
AT&M Averba Base
3+
================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:9a4224c2d4df2b32a46347629979517299f7700e10d26077b24cb238f0ab8ab7
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Alpha
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-Escodoo%2Fclog--addons-lightgray.png?logo=github
20+
:target: https://github.com/Escodoo/clog-addons/tree/14.0/atm_averba_base
21+
:alt: Escodoo/clog-addons
22+
23+
|badge1| |badge2| |badge3|
24+
25+
AT&M Averba Base
26+
27+
.. IMPORTANT::
28+
This is an alpha version, the data model and design can change at any time without warning.
29+
Only for development or testing purpose, do not use in production.
30+
`More details on development status <https://odoo-community.org/page/development-status>`_
31+
32+
**Table of contents**
33+
34+
.. contents::
35+
:local:
36+
37+
Configuration
38+
=============
39+
40+
#. Go to Settings > Users & Companies > Companies and open or create a new company:
41+
42+
- Access the Document Registration notebook.
43+
- Select the environment and fill out the user and password and codigoatm for authentication.
44+
45+
Bug Tracker
46+
===========
47+
48+
Bugs are tracked on `GitHub Issues <https://github.com/Escodoo/clog-addons/issues>`_.
49+
In case of trouble, please check there if your issue has already been reported.
50+
If you spotted it first, help us to smash it by providing a detailed and welcomed
51+
`feedback <https://github.com/Escodoo/clog-addons/issues/new?body=module:%20atm_averba_base%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
52+
53+
Do not contact contributors directly about support or help with technical issues.
54+
55+
Credits
56+
=======
57+
58+
Authors
59+
~~~~~~~
60+
61+
* Escodoo
62+
63+
Contributors
64+
~~~~~~~~~~~~
65+
66+
* `Escodoo <https://escodoo.com.br>`_:
67+
68+
* Cristiano Mafra Junior <cristiano.mafra@escodoo.com.br>
69+
70+
Maintainers
71+
~~~~~~~~~~~
72+
73+
This module is part of the `Escodoo/clog-addons <https://github.com/Escodoo/clog-addons/tree/14.0/atm_averba_base>`_ project on GitHub.
74+
75+
You are welcome to contribute.

atm_averba_base/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

atm_averba_base/__manifest__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2025 - TODAY, Escodoo
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "AT&M Averba Base",
6+
"summary": """
7+
AT&M Averba Base""",
8+
"version": "14.0.1.0.0",
9+
"license": "AGPL-3",
10+
"author": "Escodoo",
11+
"development_status": "Alpha",
12+
"website": "https://github.com/Escodoo/clog-addons",
13+
"depends": ["base"],
14+
"data": ["views/res_company.xml"],
15+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright 2025 - TODAY, Cristiano Mafra Junior <cristiano.mafra@escodoo.com.br>
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
ATM_AVERBA_URL = "https://webserver.averba.com.br/rest/CTe"

atm_averba_base/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import res_company
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Copyright 2025 - TODAY, Cristiano Mafra Junior <cristiano.mafra@escodoo.com.br>
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
5+
import requests
6+
7+
from odoo import _, fields, models
8+
from odoo.exceptions import UserError
9+
10+
from ..constants.atm_averba import ATM_AVERBA_URL
11+
12+
13+
class ResCompany(models.Model):
14+
15+
_inherit = "res.company"
16+
17+
atm_averba_environment = fields.Selection(
18+
selection=[("1", "Production"), ("2", "Homologation")],
19+
string="Environment",
20+
default="2",
21+
)
22+
atm_averba_user = fields.Char(string="User")
23+
atm_averba_user_password = fields.Char(string="User Password")
24+
atm_code = fields.Char()
25+
atm_token = fields.Char()
26+
27+
def get_atm_averba_environment(self):
28+
self.ensure_one()
29+
return {
30+
"url": ATM_AVERBA_URL
31+
if self.atm_averba_environment == "1"
32+
else ATM_AVERBA_URL,
33+
"usuario": self.atm_averba_user,
34+
"senha": self.atm_averba_user_password,
35+
"codigoatm": self.atm_code,
36+
}
37+
38+
def generate_atm_token(self):
39+
self.ensure_one()
40+
config = self.get_atm_averba_environment()
41+
42+
url = "https://webserver.averba.com.br/rest/Auth"
43+
headers = {
44+
"Accept": "application/json",
45+
"Content-Type": "application/json",
46+
}
47+
payload = {
48+
"usuario": config["usuario"],
49+
"senha": config["senha"],
50+
"codigoatm": config["codigoatm"],
51+
}
52+
53+
try:
54+
response = requests.post(url, json=payload, headers=headers, timeout=15)
55+
response.raise_for_status()
56+
result = response.json()
57+
except requests.RequestException as e:
58+
raise UserError(_("Erro na conexão com AT&M: %s") % str(e))
59+
except Exception as e:
60+
raise UserError(_("Erro inesperado: %s") % str(e))
61+
62+
token = result.get("Bearer")
63+
if not token:
64+
raise UserError(_("Token não retornado pela AT&M: %s") % result)
65+
66+
self.atm_token = token
67+
return token
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#. Go to Settings > Users & Companies > Companies and open or create a new company:
2+
3+
- Access the Document Registration notebook.
4+
- Select the environment and fill out the user and password and codigoatm for authentication.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* `Escodoo <https://escodoo.com.br>`_:
2+
3+
* Cristiano Mafra Junior <cristiano.mafra@escodoo.com.br>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AT&M Averba Base
2.81 KB
Loading

0 commit comments

Comments
 (0)