Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
l10n_mx
l10n_mx_facturae
Commits
e9379153
Commit
e9379153
authored
1 year ago
by
marisol.hernandez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat_tax_regime: se agregan cambios para el regimen fiscal 4.0
parent
803d769b
Pipeline
#20431
passed with stage
in 34 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
39 deletions
+38
-39
l10n_mx_facturae/models/account_invoice.py
l10n_mx_facturae/models/account_invoice.py
+28
-34
l10n_mx_facturae/models/account_voucher.py
l10n_mx_facturae/models/account_voucher.py
+1
-1
l10n_mx_facturae/report/account_invoice.odt
l10n_mx_facturae/report/account_invoice.odt
+0
-0
l10n_mx_facturae/report/account_voucher.odt
l10n_mx_facturae/report/account_voucher.odt
+0
-0
l10n_mx_facturae/templates/account_invoice.txt
l10n_mx_facturae/templates/account_invoice.txt
+2
-2
l10n_mx_facturae/templates/account_voucher.txt
l10n_mx_facturae/templates/account_voucher.txt
+2
-2
l10n_mx_facturae/views/account_invoice.xml
l10n_mx_facturae/views/account_invoice.xml
+5
-0
No files found.
l10n_mx_facturae/models/account_invoice.py
View file @
e9379153
...
...
@@ -17,6 +17,11 @@ class AccountInvoice(models.Model):
_name
=
"account.invoice"
_inherit
=
[
"account.invoice"
,
"base.cfdi"
]
cfdi_fiscal_regime_id
=
fields
.
Many2one
(
"cfdi.fiscal.regime"
,
states
=
{
"draft"
:
[(
"readonly"
,
False
)]},
)
@
property
def
formapago
(
self
):
"""Return payment type for display on CFDI"""
...
...
@@ -89,7 +94,7 @@ class AccountInvoice(models.Model):
# Classify taxes for CFDI
for
dummy
,
tax
in
tax_grouped
.
items
():
if
tax
.
group
in
[
"IVA"
,
"IEPS"
,
"ISR"
]:
if
tax
.
group
in
[
"IVA"
,
"IEPS"
]:
if
tax
.
amount
>=
0
:
taxes
[
"traslados"
].
append
(
tax
)
taxes
[
"total_traslados"
]
+=
tax
.
amount
...
...
@@ -274,6 +279,8 @@ class AccountInvoice(models.Model):
for
invoice
in
self
.
filtered
(
lambda
i
:
i
.
type
in
(
"out_invoice"
,
"out_refund"
)):
partner
=
invoice
.
partner_id
if
partner
:
if
partner
.
cfdi_fiscal_regime_id
.
id
:
invoice
.
cfdi_fiscal_regime_id
=
partner
.
cfdi_fiscal_regime_id
.
id
if
partner
.
cfdi_use
.
id
:
invoice
.
cfdi_use
=
partner
.
cfdi_use
.
id
invoice
.
payment_method_id
=
partner
.
payment_method_id
.
id
...
...
@@ -322,7 +329,7 @@ class AccountInvoice(models.Model):
lambda
i
:
i
.
journal_id
.
sign_sat
and
i
.
cfdi_id
and
i
.
cfdi_id
.
state
not
in
[
"draft"
,
"cancel"
]
and
i
.
cfdi_id
.
state
!=
"cancel"
)
for
invoice
in
cfdis
:
# Ensure we can cancel this invoice
...
...
@@ -334,15 +341,14 @@ class AccountInvoice(models.Model):
)
cancelacion
=
invoice
.
cancel_cfdi
()[
0
]
if
cancelacion
:
# CFDI cancelled (cancelacion == True) must cancel invoice too
super
(
AccountInvoice
,
invoice
).
action_cancel
()
elif
cancelacion
is
None
:
# CFDI set to approval (cancelacion == None) must set invoice
# to waiting too
invoice
.
write
({
"state"
:
"waiting"
})
if
invoice
.
cfdi_id
.
state
==
"waiting"
:
invoice
.
write
({
"state"
:
"waiting"
})
else
:
super
(
AccountInvoice
,
invoice
).
action_cancel
()
invoice
.
write
({
"state"
:
"cancel"
})
elif
cancelacion
is
False
:
# CFDI cancel denied (cancelacion == False) must get back invoice
# to open state
self
.
undo_waiting_state
()
# Call super only with invoices without CFDI
...
...
@@ -360,30 +366,18 @@ class AccountInvoice(models.Model):
def
action_consult_cancellation_status
(
self
):
"""Verify cancellation status"""
# TODO: Is this really needed? Maybe we can reuse the action_cancel
for
invoice
in
self
:
try
:
with
self
.
env
.
cr
.
savepoint
():
status_cancelacion
=
invoice
.
consult_cfdi_cancellation_status
()
if
status_cancelacion
is
None
:
invoice
.
message_post
(
body
=
_
(
"No status update found on SAT"
)
)
elif
status_cancelacion
is
False
:
self
.
undo_waiting_state
()
else
:
try
:
invoice
.
action_cancel
()
except
Exception
as
e
:
invoice
.
message_post
(
body
=
_
(
"The invoice could not be canceled"
)
)
except
Exception
as
e
:
invoice
.
message_post
(
body
=
_
(
"Could not check SAT invoice status "
"due to the following error: %s."
)
%
(
e
)
)
for
account_invoice
in
self
:
status_cancelacion
=
account_invoice
.
consult_cfdi_cancellation_status
()
if
status_cancelacion
is
None
:
continue
elif
status_cancelacion
is
False
:
self
.
undo_waiting_state
()
else
:
try
:
account_invoice
.
action_cancel
()
except
Exception
as
e
:
_logger
.
info
(
e
)
continue
@
api
.
multi
def
_validate_cfdi_data
(
self
):
...
...
@@ -400,7 +394,7 @@ class AccountInvoice(models.Model):
[
"cfdi_use"
,
"partner_id"
,
"fiscal_
position
"
,
"
cfdi_
fiscal_
regime_id
"
,
"payment_type_ids"
,
"address_issued_id"
,
"journal_id"
,
...
...
@@ -536,7 +530,7 @@ class AccountInvoiceLine(models.Model):
self
.
ensure_one
()
taxes
=
{
"traslados"
:
[],
"retenciones"
:
[],
"locales"
:
[]}
for
tax
in
self
.
export_invoice_line_for_xml
().
taxes
:
if
tax
.
group
in
[
"IVA"
,
"IEPS"
,
"ISR"
]:
if
tax
.
group
in
[
"IVA"
,
"IEPS"
]:
if
tax
.
amount
>=
0
:
taxes
[
"traslados"
].
append
(
tax
)
else
:
...
...
This diff is collapsed.
Click to expand it.
l10n_mx_facturae/models/account_voucher.py
View file @
e9379153
...
...
@@ -375,7 +375,7 @@ class AccountVoucher(models.Model):
required
=
[
"vat"
,
"name"
,
"
property_account_position
"
"
cfdi_fiscal_regime_id
"
]
for
record
in
self
:
...
...
This diff is collapsed.
Click to expand it.
l10n_mx_facturae/report/account_invoice.odt
View file @
e9379153
No preview for this file type
This diff is collapsed.
Click to expand it.
l10n_mx_facturae/report/account_voucher.odt
View file @
e9379153
No preview for this file type
This diff is collapsed.
Click to expand it.
l10n_mx_facturae/templates/account_invoice.txt
View file @
e9379153
...
...
@@ -69,7 +69,7 @@
<cfdi:Emisor
Rfc="${ html_escape(o.company_id.partner_id.vat_split) }"
Nombre="${ html_escape(o.company_id.partner_id.name.upper()) }"
RegimenFiscal="${ o.company_id.partner_id.
property_account_position
.code }"/>
RegimenFiscal="${ o.company_id.partner_id.
cfdi_fiscal_regime_id
.code }"/>
<cfdi:Receptor
Nombre="${ html_escape(o.commercial_partner_id.name.upper()) }"
{% choose o.commercial_partner_id.country_id and o.commercial_partner_id.country_id.code_alpha3 %}
...
...
@@ -85,7 +85,7 @@
DomicilioFiscalReceptor="${ o.commercial_partner_id.zip }"
{% end %}
{% end %}
RegimenFiscalReceptor="${ o.commercial_partner_id.
property_account_position
.code }"
RegimenFiscalReceptor="${ o.commercial_partner_id.
cfdi_fiscal_regime_id
.code }"
{% end %}
{% otherwise %}
Rfc="XEXX010101000"
...
...
This diff is collapsed.
Click to expand it.
l10n_mx_facturae/templates/account_voucher.txt
View file @
e9379153
...
...
@@ -34,7 +34,7 @@
{% end %}
<cfdi:Emisor
Nombre="${ html_escape(o.company_id.name.upper()) }"
RegimenFiscal="$o.company_id.partner_id.
property_account_position
.code"
RegimenFiscal="$o.company_id.partner_id.
cfdi_fiscal_regime_id
.code"
Rfc="${ html_escape(o.company_id.partner_id.vat_split) }" />
<cfdi:Receptor
Nombre="${ html_escape(o.partner_id.name.upper()) }"
...
...
@@ -54,7 +54,7 @@
DomicilioFiscalReceptor="${ o.partner_id.zip }"
{% end %}
{% end %}
RegimenFiscalReceptor="${ o.partner_id.
property_account_position
.code }"
RegimenFiscalReceptor="${ o.partner_id.
cfdi_fiscal_regime_id
.code }"
{% end %}
{% otherwise %}
Rfc="XEXX010101000"
...
...
This diff is collapsed.
Click to expand it.
l10n_mx_facturae/views/account_invoice.xml
View file @
e9379153
...
...
@@ -120,6 +120,11 @@
</div>
</xpath>
<field
name=
"fiscal_position"
position=
"after"
>
<field
name=
"cfdi_fiscal_regime_id"
attrs=
"{
'readonly': [('cfdi_state','in', ['signed', 'cancel', 'done'])],
'invisible': [('is_cfdi_candidate', '=', False)]
}"
/>
<field
name=
"cfdi_use"
attrs=
"{
'readonly': [('cfdi_state','in', ['signed', 'cancel', 'done'])],
...
...
This diff is collapsed.
Click to expand it.
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