Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Jorels Community
Edi
Commits
48ac1c99
Commit
48ac1c99
authored
Dec 08, 2020
by
Jorge Sanabria
Browse files
Update 2020-12-08-21:24
parent
ec59a601
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
13 deletions
+57
-13
l10n_co_edi_jorels/__init__.py
l10n_co_edi_jorels/__init__.py
+1
-0
l10n_co_edi_jorels/__manifest__.py
l10n_co_edi_jorels/__manifest__.py
+2
-2
l10n_co_edi_jorels/controllers/__init__.py
l10n_co_edi_jorels/controllers/__init__.py
+1
-0
l10n_co_edi_jorels/controllers/main.py
l10n_co_edi_jorels/controllers/main.py
+30
-0
l10n_co_edi_jorels/models/account_invoice.py
l10n_co_edi_jorels/models/account_invoice.py
+23
-11
No files found.
l10n_co_edi_jorels/__init__.py
View file @
48ac1c99
...
...
@@ -20,4 +20,5 @@
# email: info@jorels.com
#
from
.
import
controllers
from
.
import
models
l10n_co_edi_jorels/__manifest__.py
View file @
48ac1c99
...
...
@@ -37,9 +37,9 @@
'account'
,
# 'snailmail_account',
'l10n_co'
,
#
'web_notify',
'web_notify'
,
'update_from_csv'
,
#
'account_debitnote',
'account_debitnote'
,
],
'data'
:
[
'security/security.xml'
,
...
...
l10n_co_edi_jorels/controllers/__init__.py
0 → 100644
View file @
48ac1c99
from
.
import
main
\ No newline at end of file
l10n_co_edi_jorels/controllers/main.py
0 → 100644
View file @
48ac1c99
import
json
import
logging
from
odoo
import
http
from
odoo.http
import
request
_logger
=
logging
.
getLogger
(
__name__
)
class
Webhooks
(
http
.
Controller
):
@
http
.
route
(
'/l10n_co_edi_jorels/webhook/in_invoice/<company_id>'
,
type
=
'json'
,
auth
=
'public'
,
methods
=
[
'POST'
],
csrf
=
False
)
def
webhook_in_invoice
(
self
,
company_id
,
**
args
):
# journal_id = 2
# partner_id = 1
# json_example = {'a': 1, 'b': 2, 'c': '3', 'd': '4'}
# data = json.loads(request.httprequest.args)
data
=
json
.
loads
(
request
.
httprequest
.
data
)
# request.env['account.invoice'].sudo().create({
# 'partner_id': partner_id,
# 'journal_id': journal_id,
# 'type': 'in_invoice',
# 'comment': data
# })
_logger
.
debug
(
"webhook_in_invoice: company_id: %s, json: %s"
,
company_id
,
data
)
return
"Test Ok"
l10n_co_edi_jorels/models/account_invoice.py
View file @
48ac1c99
...
...
@@ -88,6 +88,9 @@ class AccountInvoice(models.Model):
ei_amount_tax_no_withholding
=
fields
.
Monetary
(
"Impuestos sin retenciones"
,
compute
=
"_compute_amount"
,
store
=
True
)
ei_amount_total_no_withholding
=
fields
.
Monetary
(
"Total sin retenciones"
,
compute
=
"_compute_amount"
,
store
=
True
)
# Total base excluida de impuestos
ei_amount_excluded
=
fields
.
Monetary
(
"Excluido"
,
compute
=
"_compute_amount"
,
store
=
True
)
def
action_invoice_sent
(
self
):
self
.
ensure_one
()
action
=
super
().
action_invoice_sent
()
...
...
@@ -263,11 +266,11 @@ class AccountInvoice(models.Model):
def
get_ei_legal_monetary_totals
(
self
):
for
rec
in
self
:
line_extension_amount
=
rec
.
amount_untaxed
tax_exclusive_amount
=
rec
.
amount_untaxed
tax_inclusive_amount
=
rec
.
ei_amount_total_no_withholding
tax_exclusive_amount
=
rec
.
amount_untaxed
-
rec
.
ei_amount_excluded
allowance_total_amount
=
0.0
charge_total_amount
=
0.0
payable_amount
=
tax_inclusive_amount
payable_amount
=
rec
.
ei_amount_total_no_withholding
tax_inclusive_amount
=
payable_amount
-
charge_total_amount
+
allowance_total_amount
return
{
"line_extension_amount"
:
line_extension_amount
,
...
...
@@ -369,6 +372,8 @@ class AccountInvoice(models.Model):
# los impuestos se adjuntan dentro de este json
if
tax_totals
[
'tax_totals'
]:
invoice_temps
.
update
({
'tax_totals'
:
tax_totals
[
'tax_totals'
]})
else
:
invoice_temps
.
pop
(
"reference_price_id"
)
lines
.
append
(
invoice_temps
)
...
...
@@ -403,30 +408,37 @@ class AccountInvoice(models.Model):
# }
# ]
# Calculo de las retenciones
# Calculo de las retenciones
, excluidos, etc
@
api
.
one
def
_compute_amount
(
self
):
res
=
super
(
AccountInvoice
,
self
).
_compute_amount
()
amount_tax_withholding
=
0
amount_tax_no_withholding
=
0
amount_excluded
=
0
for
tax_line_id
in
self
.
tax_line_ids
:
if
tax_line_id
.
tax_id
.
edi_tax_id
:
edi_tax_name
=
tax_line_id
.
tax_id
.
edi_tax_id
.
name
if
edi_tax_name
[:
4
]
!=
'Rete'
:
amount_tax_no_withholding
=
amount_tax_no_withholding
+
tax_line_id
.
amount_total
else
:
tax_name
=
tax_line_id
.
tax_id
.
name
if
tax_name
==
'IVA Excluido'
:
amount_excluded
=
amount_excluded
+
tax_line_id
.
base
elif
edi_tax_name
[:
4
]
==
'Rete'
:
amount_tax_withholding
=
amount_tax_withholding
+
tax_line_id
.
amount_total
else
:
amount_tax_no_withholding
=
amount_tax_no_withholding
+
tax_line_id
.
amount_total
else
:
tax_name
=
tax_line_id
.
tax_id
.
name
if
tax_name
[:
3
]
!=
'Rte
'
:
amount_
tax_no_withholding
=
amount_tax_no_withholding
+
tax_line_id
.
amount_total
el
se
:
if
tax_name
==
'IVA Excluido
'
:
amount_
excluded
=
amount_excluded
+
tax_line_id
.
base
el
if
tax_name
[:
3
]
==
'Rte'
:
amount_tax_withholding
=
amount_tax_withholding
+
tax_line_id
.
amount_total
else
:
amount_tax_no_withholding
=
amount_tax_no_withholding
+
tax_line_id
.
amount_total
self
.
ei_amount_tax_withholding
=
amount_tax_withholding
self
.
ei_amount_tax_no_withholding
=
amount_tax_no_withholding
self
.
ei_amount_total_no_withholding
=
self
.
amount_untaxed
+
amount_tax_no_withholding
self
.
ei_amount_excluded
=
amount_excluded
return
res
@
api
.
multi
...
...
@@ -690,7 +702,7 @@ class AccountInvoice(models.Model):
@
api
.
multi
def
validate_dian_generic
(
self
,
is_test
):
# raise Warning(json.dumps(self.get_json_request(), indent=2, sort_keys=False))
#
_logger.debug("Request Validación DIAN: %s", json.dumps(self.get_json_request(), indent=2, sort_keys=False))
_logger
.
debug
(
"Request Validación DIAN: %s"
,
json
.
dumps
(
self
.
get_json_request
(),
indent
=
2
,
sort_keys
=
False
))
for
rec
in
self
:
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment