diff --git a/l10n_mx_facturae_pac_facturalo/models/__init__.py b/l10n_mx_facturae_pac_facturalo/models/__init__.py index e37375dc994d6b54ba87ad50399790d590edb566..8cca2628e29ddd264927be4a10e382cb57ca6b9e 100644 --- a/l10n_mx_facturae_pac_facturalo/models/__init__.py +++ b/l10n_mx_facturae_pac_facturalo/models/__init__.py @@ -3,4 +3,4 @@ from . import invoice from . import ir_attachment_facturae from . import account_journal - +from . import params_pac diff --git a/l10n_mx_facturae_pac_facturalo/models/params_pac.py b/l10n_mx_facturae_pac_facturalo/models/params_pac.py index 07afcce262fd4b67c827bf4095726feaa6cbc62a..7f3da61ff06078a682c206bb3a618d1ed2223cad 100644 --- a/l10n_mx_facturae_pac_facturalo/models/params_pac.py +++ b/l10n_mx_facturae_pac_facturalo/models/params_pac.py @@ -22,11 +22,11 @@ # ############################################################################## -from openerp.osv import fields, osv +from openerp.osv import fields, orm from openerp.tools.translate import _ -class params_pac(osv.osv): +class params_pac(orm.Model): _inherit = 'params.pac' def _get_method_type_selection(self, cr, uid, context=None): @@ -39,7 +39,8 @@ class params_pac(osv.osv): return types _columns = { - 'method_type': fields.selection(_get_method_type_selection, + 'method_type': fields.selection( + _get_method_type_selection, "Process to perform", type='char', size=64, required=True, help='Type of process to configure in this pac'), } diff --git a/l10n_mx_facturae_validate_cfdi/__init__.py b/l10n_mx_facturae_validate_cfdi/__init__.py index 31729920d78091d3c1b7dfd4e56e8ff74e6faac4..391d1aa4d8cb7beca1ee5a2e668055c02d895e61 100644 --- a/l10n_mx_facturae_validate_cfdi/__init__.py +++ b/l10n_mx_facturae_validate_cfdi/__init__.py @@ -22,5 +22,5 @@ # ############################################################################## -import invoice +from . import models import wizard diff --git a/l10n_mx_facturae_validate_cfdi/models/__init__.py b/l10n_mx_facturae_validate_cfdi/models/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..c641769626faab84196f646ae30a93011fab5efc --- /dev/null +++ b/l10n_mx_facturae_validate_cfdi/models/__init__.py @@ -0,0 +1,7 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from . import account_invoice +from . import account_journal diff --git a/l10n_mx_facturae_validate_cfdi/invoice.py b/l10n_mx_facturae_validate_cfdi/models/account_invoice.py similarity index 99% rename from l10n_mx_facturae_validate_cfdi/invoice.py rename to l10n_mx_facturae_validate_cfdi/models/account_invoice.py index 80cfa0cdaae13e5d3876d892d61315b1c011983e..aeb1d11fdbe5a0763bc63c84a4d51a3444598d7f 100644 --- a/l10n_mx_facturae_validate_cfdi/invoice.py +++ b/l10n_mx_facturae_validate_cfdi/models/account_invoice.py @@ -43,7 +43,7 @@ from openerp.tools.translate import _ try: from openerp.addons.account import signals except ImportError: - from . import signals + from .. import signals _logger = logging.getLogger(__name__) diff --git a/l10n_mx_facturae_validate_cfdi/models/account_journal.py b/l10n_mx_facturae_validate_cfdi/models/account_journal.py new file mode 100644 index 0000000000000000000000000000000000000000..1b3e4a3bdf6ab1869bf7d5f0c2204ae6802a822f --- /dev/null +++ b/l10n_mx_facturae_validate_cfdi/models/account_journal.py @@ -0,0 +1,47 @@ +# -*- encoding: utf-8 -*- +# ########################################################################## +# Module Writen to OpenERP, Open Source Management Solution +# +# Authors: Openpyme (<http://openpyme.mx>) +# +# Coded by: Miguel Angel Villafuerte Ojeda (mikeshot@gmail.com) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from openerp.osv import fields, orm + + +class account_journal(orm.Model): + _inherit = 'account.journal' + + _columns = { + 'validate_sat': fields.boolean( + 'Validate SAT', + help="If this field is enabled, then validates through the" + " webservice of the Mexican SAT that the info of " + " CFDI is valid (attached or provided in the form)" + ), + 'validate_xml': fields.boolean( + 'Validate XML', + help="If this field is enabled, then validates that" + " the supplier invoices has a valid XML file attached" + ), + 'max_diff': fields.float( + 'Max difference', + help="Max difference between total calculated on invoice form" + " and total indicated on XML file" + ) + } diff --git a/l10n_mx_facturae_validate_cfdi/view/account_journal_view.xml b/l10n_mx_facturae_validate_cfdi/view/account_journal_view.xml index 59ad90dd10e8da1dfe6732a40fbfa747d9823fde..e9cd8458e40114abc567c333f8a965cd479c286d 100644 --- a/l10n_mx_facturae_validate_cfdi/view/account_journal_view.xml +++ b/l10n_mx_facturae_validate_cfdi/view/account_journal_view.xml @@ -16,10 +16,6 @@ <field name="validate_xml"/> <field name="max_diff" attrs="{'invisible':[('validate_xml', '=', False)]}" /> </group> - <group> - <field name="sign_sat"/> - <field name="type_cfdi"/> - </group> </group> </page> </xpath> diff --git a/l10n_mx_invoice_datetime/__openerp__.py b/l10n_mx_invoice_datetime/__openerp__.py index 2bd25c9b1a4ef7ee457df4f1e35592d4b042a2d4..1f3abd192aea64d1a8e56a3e2ced242d2830fb8a 100644 --- a/l10n_mx_invoice_datetime/__openerp__.py +++ b/l10n_mx_invoice_datetime/__openerp__.py @@ -33,6 +33,8 @@ "l10n_mx_facturae_groups", ], "demo": [], - "data": [], + "data": [ + "views/account_invoice_view.xml" + ], "installable": True, } diff --git a/l10n_mx_invoice_datetime/invoice.py b/l10n_mx_invoice_datetime/invoice.py deleted file mode 100644 index 06f00c33627f82fa4f8bec91d979904656177f15..0000000000000000000000000000000000000000 --- a/l10n_mx_invoice_datetime/invoice.py +++ /dev/null @@ -1,159 +0,0 @@ -# -*- encoding: utf-8 -*- -########################################################################### -# Module Writen to OpenERP, Open Source Management Solution -# -# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/ -# All Rights Reserved. -# info Vauxoo (info@vauxoo.com) -############################################################################ -# Coded by: moylop260 (moylop260@vauxoo.com) -# Launchpad Project Manager for Publication: Nhomar Hernandez - nhomar@vauxoo.com -############################################################################ -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -############################################################################## - -from openerp.osv import fields, osv -from openerp import tools -from openerp import release -from openerp.tools.translate import _ -import datetime - -import time - - -class account_payment_term(osv.Model): - _inherit = "account.payment.term" - - def compute(self, cr, uid, id, value, date_ref=False, context=None): - if context is None: - context = {} - if date_ref: - try: - date_ref = time.strftime('%Y-%m-%d', time.strptime( - date_ref, '%Y-%m-%d %H:%M:%S')) - except: - pass - return super(account_payment_term, self).compute(cr, uid, id, value, - date_ref, context=context) - - -class account_invoice(osv.Model): - _inherit = 'account.invoice' - # _order = 'invoice_datetime asc' - - def _get_date_invoice_tz(self, cr, uid, ids, field_names=None, arg=False, context=None): - if context is None: - context = {} - res = {} - if release.version >= '6': - dt_format = tools.DEFAULT_SERVER_DATETIME_FORMAT - tz = context.get('tz_invoice_mx', 'America/Mexico_City') - for invoice in self.browse(cr, uid, ids, context=context): - res[invoice.id] = invoice.invoice_datetime and tools.\ - server_to_local_timestamp(invoice.invoice_datetime, - tools.DEFAULT_SERVER_DATETIME_FORMAT, - tools.DEFAULT_SERVER_DATETIME_FORMAT, context.get( - 'tz_invoice_mx', 'America/Mexico_City')) or False - elif release.version < '6': - # TODO: tz change for openerp5 - for invoice in self.browse(cr, uid, ids, context=context): - res[invoice.id] = invoice.date_invoice - return res - - _columns = { - # Extract date_invoice from original, but add datetime - 'invoice_datetime': fields.datetime( - 'Date Electronic Invoiced ', copy=False, - states={'open': [('readonly', True)], 'close': [('readonly', True)]}, - help="Keep empty to use the current date" - ), - 'date_invoice_tz': fields.function( - _get_date_invoice_tz, method=True, - type='datetime', string='Date Invoiced with TZ', store=True, - help='Date of Invoice with Time Zone'), - } - - def create(self, cr, uid, vals, context=None): - if context is None: - context = {} - res = self.assigned_datetime(cr, uid, vals, context=context) - if res: - vals.update(res) - return super(account_invoice, self).create(cr, uid, vals, context) - - def write(self, cr, uid, ids, vals, context=None): - if context is None: - context = {} - res = {} - if vals.get('date_invoice', False): - vals.update({'invoice_datetime': False}) - res = self.assigned_datetime(cr, uid, vals, context=context) - if vals.get('invoice_datetime', False): - vals.update({'date_invoice' : False}) - res = self.assigned_datetime(cr, uid, vals, context=context) - if res: - vals.update(res) - return super(account_invoice, self).write(cr, uid, ids, vals, - context=context) - - def assigned_datetime(self, cr, uid, values, context=None): - if context is None: - context = {} - res = {} - if values.get('date_invoice', False) and\ - not values.get('invoice_datetime', False): - - user_hour = self._get_time_zone(cr, uid, [], context=context) - time_invoice = datetime.time(abs(user_hour), 0, 0) - - date_invoice = datetime.datetime.strptime( - values['date_invoice'], '%Y-%m-%d').date() - - dt_invoice = datetime.datetime.combine( - date_invoice, time_invoice).strftime('%Y-%m-%d %H:%M:%S') - - res['invoice_datetime'] = dt_invoice - res['date_invoice'] = values['date_invoice'] - return res - - if values.get('invoice_datetime', False) and not\ - values.get('date_invoice', False): - date_invoice = fields.datetime.context_timestamp(cr, uid, - datetime.datetime.strptime(values['invoice_datetime'], - tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context) - res['date_invoice'] = date_invoice - res['invoice_datetime'] = values['invoice_datetime'] - return res - - if 'invoice_datetime' in values and 'date_invoice' in values: - if values['invoice_datetime'] and values['date_invoice']: - date_invoice = datetime.datetime.strptime( - values['invoice_datetime'], - '%Y-%m-%d %H:%M:%S').date().strftime('%Y-%m-%d') - if date_invoice != values['date_invoice']: - raise osv.except_osv(_('Warning!'), - _('Invoice dates should be equal')) - - if not values.get('invoice_datetime', False) and\ - not values.get('date_invoice', False): - - date_ts = fields.datetime.context_timestamp(cr, uid, - datetime.datetime.strptime(fields.datetime.now(), - tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context) - res['date_invoice'] = date_ts - res['invoice_datetime'] = fields.datetime.now() - return res - return res diff --git a/l10n_mx_invoice_datetime/account_invoice_view.xml b/l10n_mx_invoice_datetime/views/account_invoice_view.xml similarity index 74% rename from l10n_mx_invoice_datetime/account_invoice_view.xml rename to l10n_mx_invoice_datetime/views/account_invoice_view.xml index 01e96362582d2c84b6efee37b33dbd7b49838c69..6638aeb58f3ff515139680818f6cf9bfb779446a 100644 --- a/l10n_mx_invoice_datetime/account_invoice_view.xml +++ b/l10n_mx_invoice_datetime/views/account_invoice_view.xml @@ -6,9 +6,6 @@ <field name="model">account.invoice</field> <field name="inherit_id" ref="account.invoice_form"/> <field name="arch" type="xml"> - <xpath expr="//field[@name='date_invoice']" position="after"> - <field name="invoice_datetime" groups="l10n_mx_facturae_groups.group_l10n_mx_facturae_manager"/> - </xpath> <xpath expr="//field[@name='date_invoice']" position="replace"> <field name="date_invoice" groups="l10n_mx_facturae_groups.group_l10n_mx_facturae_user"/> </xpath> diff --git a/l10n_mx_ir_attachment_facturae/migrations/1.3.0/post-migration.py b/l10n_mx_ir_attachment_facturae/migrations/1.3.0/post-migration.py new file mode 100644 index 0000000000000000000000000000000000000000..58b12b3bed05cf8e48d6111d5b453671692e65a8 --- /dev/null +++ b/l10n_mx_ir_attachment_facturae/migrations/1.3.0/post-migration.py @@ -0,0 +1,53 @@ +""" + +Revision ID: l10n_mx_ir_attachment_facture_1.3.0 +Revises: +Create Date: 2016-05-05 + +""" +from openupgradelib import openupgrade as tools + +revision = '1.3.0' +down_revision = '1.2.0' +branch_labels = None +depends_on = None + +@tools.migrate() +def migrate(cr, installed_version): + # ir_sequence_approval is deprecated but + # we need to save its values and match them with + # the new code + cr.execute( + """ + select ir_sequence_approval.type as type_cfdi, + account_journal.id + from ir_sequence_approval + inner join ir_sequence on + ir_sequence.id = ir_sequence_approval.sequence_id + inner join account_journal on + account_journal.sequence_id = ir_sequence.id + """ + ) + # Fetch result into a dictionary + results = cr.dictfetchall() + # Write in account_journal table type_cdfi + for result in results: + if 'cfdi32' in result['type_cfdi']: + query = ( + """ + update account_journal + set sign_sat = True, + type_cfdi = '{type_cfdi}' + where id = {journal_id} + """.format( + type_cfdi=result['type_cfdi'], + journal_id=result['id'] + ) + ) + cr.execute(query) + # Delete ir_sequence_approval table + cr.execute( + """ + drop table if exists ir_sequence_approval + """ + ) diff --git a/l10n_mx_ir_attachment_facturae/migrations/1.3.0/pre-migration.py b/l10n_mx_ir_attachment_facturae/migrations/1.3.0/pre-migration.py index aa6c45a8b7cc562129e9e3de5f51ad8c16f0ca8a..0b95a447bcc22ca000f0668a91c0817cf82d52e9 100644 --- a/l10n_mx_ir_attachment_facturae/migrations/1.3.0/pre-migration.py +++ b/l10n_mx_ir_attachment_facturae/migrations/1.3.0/pre-migration.py @@ -1,6 +1,6 @@ """ -Revision ID: l10n_mx_ir_attachment_facture_2.0.0 +Revision ID: l10n_mx_ir_attachment_facture_1.3.0 Revises: Create Date: 2016-05-05 @@ -24,34 +24,3 @@ def migrate(cr, installed_version): # Rename column from invoice_id to res_id if not tools.column_exists(cr, 'ir_attachment_facturae_mx', 'res_id'): tools.rename_columns(cr, column_renames) - - # Second update - # Select journals in which there is a ir_sequence_approval set up - cr.execute( - """ - select ir_sequence_approval.type as type_cfdi, - account_journal.id - from ir_sequence_approval - inner join ir_sequence on - ir_sequence.id = ir_sequence_approval.sequence_id - inner join account_journal on - account_journal.sequence_id = ir_sequence.id - """ - ) - # Fetch result into a dictionary - results = cr.dictfetchall() - # Write in account_journal table type_cdfi - for result in results: - if 'cfdi32' in result['type_cfdi']: - query = ( - """ - update account_journal - set sign_sat = True, - type_cfdi = '{type_cfdi}' - where id = {journal_id} - """.format( - type_cfdi=result['type_cfdi'], - journal_id=result['id'] - ) - ) - cr.execute(query) diff --git a/l10n_mx_ir_attachment_facturae/models/ir_attachment_facturae.py b/l10n_mx_ir_attachment_facturae/models/ir_attachment_facturae.py index f02fa37a63a16159627c718c197428e0e7faf293..17eaa3c9ad59ddb3641cf7196d8bff84ea8fbaf5 100644 --- a/l10n_mx_ir_attachment_facturae/models/ir_attachment_facturae.py +++ b/l10n_mx_ir_attachment_facturae/models/ir_attachment_facturae.py @@ -135,47 +135,6 @@ class ir_attachment_facturae_mx(orm.Model): 'last_date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), } - def action_confirm(self, cr, uid, ids, context=None): - if context is None: - context = {} - invoice_obj = self.pool.get('account.invoice') - msj = '' - index_xml = '' - attach = self.browse(cr, uid, ids[0]) - invoice = attach.invoice_id - type = attach.type - save_attach = None - if 'cfdi' in type: - fname_invoice = invoice.fname_invoice and invoice.fname_invoice + \ - '_V3_2.xml' or '' - fname, xml_data = invoice_obj._get_facturae_invoice_xml_data( - cr, uid, [invoice.id], context=context) - attach = self.pool.get('ir.attachment').create(cr, uid, { - 'name': fname_invoice, - 'datas': base64.encodestring(xml_data), - 'datas_fname': fname_invoice, - 'res_model': 'account.invoice', - 'res_id': invoice.id, - }, context=None) - msj = _("Attached Successfully XML CFDI 3.2\n") - save_attach = True - else: - raise orm.except_orm( - _("Type Electronic Invoice Unknow!"), - _("The Type Electronic Invoice:" + (type or '')) - ) - if save_attach: - self.write( - cr, uid, ids, - {'file_input': attach or False, - 'state': 'confirmed', - 'last_date': time.strftime('%Y-%m-%d %H:%M:%S'), - 'msj': msj, - 'file_xml_sign_index': index_xml}, - context=context - ) - return True - def action_sign(self, cr, uid, ids, context=None): context = dict(context or {}) attach = ''