Commit 9b825396 authored by Jorge Sanabria's avatar Jorge Sanabria
Browse files

Update 2021-01-08 20:24

parent 1b168619
l10n_co_edi_jorels
------------------
Copyright (2019-2020) - Jorels SAS
Copyright (2019-2021) - Jorels SAS
[info@jorels.com](mailto:info@jorels.com)
......@@ -12,6 +12,6 @@ Under LGPL (Lesser General Public License)
Contributing
============
Jorge Sanabria - [js@jorels.com](mailto:js@jorels.com)
Jorge Sanabria (2021) - [js@jorels.com](mailto:js@jorels.com)
Leonardo Martinez - [lotharius96@protonmail.ch](mailto:lotharius96@protonmail.ch)
Leonardo Martinez (2020) - [lotharius96@protonmail.ch](mailto:lotharius96@protonmail.ch)
l10n_co_edi_jorels
------------------
Copyright (2019-2020) - Jorels SAS
Copyright (2019-2021) - Jorels SAS
[info@jorels.com](mailto:info@jorels.com)
......
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......@@ -49,17 +49,27 @@
'views/config/res_config_settings_views.xml',
'views/config/resolution_views.xml',
'views/config/ir_sequence.xml',
'views/config/account_product_view.xml',
'views/config/uom_uom_views.xml',
'views/config/account_taxes_view.xml',
'views/account_invoice_view.xml',
'views/res_partner_view.xml',
'report/report_invoice.xml',
'data/mail_template_data.xml',
],
# 'external_dependencies': {
# 'python': [
# ]
# },
'external_dependencies': {
'python': [
'num2words',
'json',
'base64',
'math',
'tempfile',
'zipfile',
'pathlib',
'qrcode',
'requests',
'io'
]
},
'installable': True,
'application': False,
}
from . import main
\ No newline at end of file
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
# l10n_co_edi_jorels is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# l10n_co_edi_jorels is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with l10n_co_edi_jorels. If not, see <https://www.gnu.org/licenses/>.
#
# email: info@jorels.com
#
from . import main
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
# l10n_co_edi_jorels is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# l10n_co_edi_jorels is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with l10n_co_edi_jorels. If not, see <https://www.gnu.org/licenses/>.
#
# email: info@jorels.com
#
import json
import logging
......
<?xml version="1.0" encoding="utf-8"?>
<!--Jorels S.A.S. - Copyright (2019-2020)-->
<!--Jorels S.A.S. - Copyright (2019-2021)-->
<!--This file is part of l10n_co_edi_jorels.-->
......
<?xml version="1.0" ?>
<?xml version="1.0" encoding="utf-8"?>
<!--Jorels S.A.S. - Copyright (2019-2021)-->
<!--This file is part of l10n_co_edi_jorels.-->
<!--l10n_co_edi_jorels is free software: you can redistribute it and/or modify-->
<!--it under the terms of the GNU Lesser General Public License as published by-->
<!--the Free Software Foundation, either version 3 of the License, or-->
<!--(at your option) any later version.-->
<!--l10n_co_edi_jorels is distributed in the hope that it will be useful,-->
<!--but WITHOUT ANY WARRANTY; without even the implied warranty of-->
<!--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-->
<!--GNU Lesser General Public License for more details.-->
<!--You should have received a copy of the GNU Lesser General Public License-->
<!--along with l10n_co_edi_jorels. If not, see <https://www.gnu.org/licenses/>.-->
<!--email: info@jorels.com-->
<odoo>
<data noupdate="1">
<record id="account.email_template_edi_invoice" model="mail.template">
<field name="name">Invoice: Send by email</field>
<field name="model_id" ref="account.model_account_invoice"/>
<!-- <field name="email_from">${object.user_id.email_formatted |safe}</field>-->
<field name="email_from">${object.company_id.email_edi}</field>
<field name="email_to">${object.partner_id.email_edi}</field>
<field name="partner_to">${object.partner_id.id}</field>
......
This diff is collapsed.
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......@@ -20,25 +20,27 @@
# email: info@jorels.com
#
import base64
from odoo import api, fields, models, tools
import logging
from odoo import api, fields, models
from odoo.exceptions import Warning
import json
import requests
import qrcode
from io import BytesIO
import zipfile, tempfile
from pathlib import Path
import logging
_logger = logging.getLogger(__name__)
try:
import base64
import json
import math
import tempfile
import zipfile
import qrcode
import requests
from io import BytesIO
from pathlib import Path
from num2words import num2words
except Exception as err:
_logger.debug(err)
class AccountInvoice(models.Model):
_inherit = "account.invoice"
......@@ -91,6 +93,8 @@ class AccountInvoice(models.Model):
# Total base excluida de impuestos
ei_amount_excluded = fields.Monetary("Excluido", compute="_compute_amount", store=True)
value_letters = fields.Char("Valor en letras", compute="_compute_amount", store=True)
def action_invoice_sent(self):
self.ensure_one()
action = super().action_invoice_sent()
......@@ -306,8 +310,12 @@ class AccountInvoice(models.Model):
products.update({'description': invoice_line_id.name})
if invoice_line_id.product_id.edi_unit_measure_id.id:
products.update({'unit_measure_id': invoice_line_id.product_id.edi_unit_measure_id.id}),
if invoice_line_id.product_id.uom_id.edi_unit_measure_id.id:
products.update({'unit_measure_id': invoice_line_id.product_id.uom_id.edi_unit_measure_id.id})
elif invoice_line_id.product_id.edi_unit_measure_id.id:
# Si se usa la configuracion en la unidad de medida de Odoo, entonces este campo no es necesario
# Sin embargo se deja por compatibilidad con campos ya existentes
products.update({'unit_measure_id': invoice_line_id.product_id.edi_unit_measure_id.id})
else:
raise Warning("Todos los productos deben tener asignada una 'Unidad de medida (DIAN)'.\n"
"Revise, por favor.")
......@@ -439,6 +447,19 @@ class AccountInvoice(models.Model):
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
# Valor en letras
decimal_part, integer_part = math.modf(self.amount_total)
if decimal_part:
decimal_part = round(decimal_part * math.pow(10, self.currency_id.decimal_places))
if integer_part:
self.value_letters = num2words(integer_part, lang=self.partner_id.lang).upper() + ' ' + \
self.currency_id.currency_unit_label.upper()
if decimal_part:
self.value_letters = self.value_letters + ', ' + \
num2words(decimal_part, lang=self.partner_id.lang).upper() + ' ' + \
self.currency_id.currency_subunit_label.upper() + '.'
return res
@api.multi
......@@ -791,6 +812,18 @@ class AccountInvoice(models.Model):
def skip_validate_dian_production(self):
self.skip_validate_dian()
@api.multi
def is_journal_pos(self):
self.ensure_one()
try:
journal_pos_rec = self.env['pos.config'].search([('invoice_journal_id.id', '=', self.journal_id.id)])
if journal_pos_rec:
return True
else:
return False
except KeyError:
return False
@api.multi
def action_invoice_open(self):
previous_invoice_state_is_draft = False
......@@ -801,7 +834,10 @@ class AccountInvoice(models.Model):
if previous_invoice_state_is_draft:
to_open_invoices = self.filtered(lambda inv: inv.state == 'open')
if to_open_invoices.filtered(lambda inv: inv.type in ('out_invoice', 'out_refund')):
if to_open_invoices.filtered(
lambda inv: inv.type in (
'out_invoice', 'out_refund') and not inv.ei_is_valid and not inv.is_journal_pos()):
# Entorno
to_open_invoices.filtered(
lambda inv: inv.write({'ei_is_not_test': inv.env.user.company_id.is_not_test}))
......@@ -813,6 +849,8 @@ class AccountInvoice(models.Model):
if to_open_invoices.filtered(lambda inv: inv.ei_is_not_test):
to_open_invoices.validate_dian_generic(False)
if to_open_invoices.filtered(lambda inv: inv.env.user.company_id.enable_mass_send_print):
to_open_invoices.mass_send_print()
if to_open_invoices.filtered(lambda inv: not inv.ei_is_not_test):
to_open_invoices.validate_dian_generic(True)
......
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......@@ -20,9 +20,10 @@
# email: info@jorels.com
#
from . import account_product
from . import account_taxes
from . import ir_sequence
from . import uom_uom
from . import res_company
from . import res_config_settings
from . import resolution
from . import account_taxes
from . import account_product
from . import ir_sequence
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......@@ -20,14 +20,12 @@
# email: info@jorels.com
#
import json
import logging
from odoo import api, fields, models, tools
from odoo.exceptions import Warning
from pathlib import Path
import json
import requests
from pathlib import Path
from odoo import api, fields, models
_logger = logging.getLogger(__name__)
......@@ -75,6 +73,8 @@ class ResCompany(models.Model):
test_set_id = fields.Char(string="TestSetId")
enable_validate_state = fields.Boolean(string="Habilitar estado intermedio de Validación DIAN en la facturación",
default=True)
enable_mass_send_print = fields.Boolean(string="Email automatico de la factura al validar(En producción)",
default=False)
# Report
report_custom_text = fields.Html(string="Custom text")
......
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......@@ -20,14 +20,13 @@
# email: info@jorels.com
#
from odoo import api, fields, models, _
from odoo.exceptions import Warning
import json
import requests
import logging
from pathlib import Path
import logging
import requests
from odoo import api, fields, models
from odoo.exceptions import Warning
_logger = logging.getLogger(__name__)
......@@ -59,6 +58,9 @@ class ResConfigSettings(models.TransientModel):
enable_validate_state = fields.Boolean(related="company_id.enable_validate_state",
string="Estado internedio Validación DIAN",
default=True, readonly=False)
enable_mass_send_print = fields.Boolean(related="company_id.enable_mass_send_print",
string="Email automatico de la factura al validar(En producción)",
default=False, readonly=False)
# Report
report_custom_text = fields.Html(related="company_id.report_custom_text", string="Custom text", readonly=False)
......@@ -170,19 +172,21 @@ class ResConfigSettings(models.TransientModel):
_logger.debug('API Response: %s', response)
# No es posible comprobar la firma digital, ni el password
if 'id' in response:
if 'name' in response:
rec.certificate_message = "El nombre del certificado actualmente almacenado en la API es: " + \
response['name']
else:
rec.certificate_message = "No se ha encontrado un certificado. " \
"¡Suba uno o Intente nuevamente!"
elif 'message' in response:
if 'message' in response:
if response['message'] == 'Unauthenticated.' or response['message'] == '':
rec.certificate_message = 'No es posible la autenticación con la API. ' \
'Revise su Api key e intente nuevamente.'
else:
rec.certificate_message = response['message']
elif 'is_valid' in response:
if response['is_valid']:
if 'organization' in response:
rec.certificate_message = "Certificado valido para la empresa: " + response['organization']
else:
rec.certificate_message = "Certificado valido en servidor"
else:
rec.certificate_message = "No se ha encontrado un certificado. " \
"¡Suba uno o Intente nuevamente!"
else:
rec.certificate_message = 'Algo sucede. No es posible comunicarse con la API'
......
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......@@ -20,18 +20,20 @@
# email: info@jorels.com
#
from odoo import api, fields, models, _
from odoo.exceptions import Warning
import json
import requests
from pathlib import Path
import logging
from odoo import api, fields, models
from odoo.exceptions import Warning
_logger = logging.getLogger(__name__)
try:
import json
import requests
from pathlib import Path
except Exception as err:
_logger.debug(err)
class Resolution(models.Model):
_name = 'l10n_co_edi_jorels.resolution'
......@@ -62,7 +64,7 @@ class Resolution(models.Model):
def _compute_name(self):
for rec in self:
rec.name = str(rec.resolution_id) + ' - ' + \
rec.resolution_type_document_id.name + ' [' + rec.resolution_type_document_id.code + ']'
rec.resolution_type_document_id.name + ' [' + rec.resolution_type_document_id.code + ']'
@api.model
def create(self, vals):
......
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
# l10n_co_edi_jorels is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# l10n_co_edi_jorels is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with l10n_co_edi_jorels. If not, see <https://www.gnu.org/licenses/>.
#
# email: info@jorels.com
#
from odoo import api, fields, models, tools
class ProductUom(models.Model):
_inherit = "uom.uom"
edi_unit_measure_id = fields.Many2one(comodel_name='l10n_co_edi_jorels.unit_measures',
string="Unidad de medida (DIAN)")
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......
# -*- coding: utf-8 -*-
#
# Jorels S.A.S. - Copyright (2019-2020)
# Jorels S.A.S. - Copyright (2019-2021)
#
# This file is part of l10n_co_edi_jorels.
#
......