diff --git a/addons/l10n_ar/__manifest__.py b/addons/l10n_ar/__manifest__.py index fdfe00a768b..1349883de6b 100644 --- a/addons/l10n_ar/__manifest__.py +++ b/addons/l10n_ar/__manifest__.py @@ -98,7 +98,6 @@ Master Data: 'views/uom_uom_view.xml', 'views/account_journal_view.xml', 'views/l10n_latam_document_type_view.xml', - 'views/ir_sequence_view.xml', 'views/report_invoice.xml', 'report/invoice_report_view.xml', ], diff --git a/addons/l10n_ar/demo/account_supplier_invoice_demo.xml b/addons/l10n_ar/demo/account_supplier_invoice_demo.xml index 938456a13ab..ffb8c931e3d 100644 --- a/addons/l10n_ar/demo/account_supplier_invoice_demo.xml +++ b/addons/l10n_ar/demo/account_supplier_invoice_demo.xml @@ -1,9 +1,10 @@ + + - FA-C 0001-00000008 @@ -22,7 +23,6 @@ - FA-A 0002-00000123 @@ -38,7 +38,6 @@ - FA-A 0003-00000312 @@ -53,7 +52,6 @@ - FA-A 0001-00000200 @@ -68,7 +66,6 @@ - FA-A 0001-00000222 @@ -87,7 +84,6 @@ - FA-I 0001-00000333 @@ -101,7 +97,6 @@ - FA-I 0001-00000334 @@ -116,7 +111,6 @@ - GA-I 0001-00000605 @@ -222,6 +216,31 @@ + + 0001-00000008 + + + 0002-00000123 + + + 0003-00000312 + + + 0001-00000200 + + + 0001-00000222 + + + 0001-00000333 + + + 0001-00000334 + + + 16052IC04000605L + + diff --git a/addons/l10n_ar/demo/account_supplier_refund_demo.xml b/addons/l10n_ar/demo/account_supplier_refund_demo.xml index 3866523a65c..631e30bad35 100644 --- a/addons/l10n_ar/demo/account_supplier_refund_demo.xml +++ b/addons/l10n_ar/demo/account_supplier_refund_demo.xml @@ -5,6 +5,7 @@ Mercadería defectuosa refund + 0001-01234567 @@ -14,6 +15,7 @@ Venta cancelada cancel + 0001-01234566 diff --git a/addons/l10n_ar/i18n/es.po b/addons/l10n_ar/i18n/es.po index ceb06420e72..a749028b79e 100644 --- a/addons/l10n_ar/i18n/es.po +++ b/addons/l10n_ar/i18n/es.po @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 13.0+e\n" +"Project-Id-Version: Odoo Server 13.3alpha1+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-15 13:31+0000\n" -"PO-Revision-Date: 2020-01-15 13:31+0000\n" +"POT-Creation-Date: 2020-03-30 18:37+0000\n" +"PO-Revision-Date: 2020-03-30 18:37+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -365,6 +365,16 @@ msgstr "" msgid "CUIT" msgstr "" +#. module: l10n_ar +#: code:addons/l10n_ar/models/account_move.py:0 +#, python-format +msgid "" +"Can not change the POS number, you can only change the first number for " +"document type that you are creating in odoo" +msgstr "" +"No puede cambiar el número de POS, solo puede cambiar el el primer número para" +"el tipo de document que esta creando en odoo" + #. module: l10n_ar #: code:addons/l10n_ar/models/account_journal.py:0 #, python-format @@ -440,11 +450,6 @@ msgstr "" msgid "Country" msgstr "País" -#. module: l10n_ar -#: model:ir.model.fields,field_description:l10n_ar.field_res_company__l10n_ar_country_code -msgid "Country Code" -msgstr "Código País" - #. module: l10n_ar #: model:ir.model.fields,field_description:l10n_ar.field_l10n_ar_afip_responsibility_type__create_uid msgid "Created by" @@ -613,7 +618,7 @@ msgstr "Servicio de Guarda" #. module: l10n_ar #: model:ir.model.fields,field_description:l10n_ar.field_l10n_ar_afip_responsibility_type__id msgid "ID" -msgstr "" +msgstr "ID (identificación)" #. module: l10n_ar #: model:ir.actions.act_window,name:l10n_ar.action_iibb_purchases_by_state_and_account_pivot @@ -714,11 +719,6 @@ msgstr "Tipo de Documento Latam" msgid "Legal Entity VAT" msgstr "CUIT Persona Jurídica" -#. module: l10n_ar -#: model:ir.model.fields,field_description:l10n_ar.field_ir_sequence__l10n_ar_letter -msgid "Letter" -msgstr "Letra" - #. module: l10n_ar #: model:ir.model.fields,field_description:l10n_ar.field_l10n_latam_document_type__l10n_ar_letter msgid "Letters" @@ -780,11 +780,6 @@ msgstr "El nombre debe ser único!" msgid "Natural Person VAT" msgstr "IVA Persona Física" -#. module: l10n_ar -#: model_terms:ir.ui.view,arch_db:l10n_ar.view_account_journal_form -msgid "Next Number" -msgstr "Próximo número" - #. module: l10n_ar #: code:addons/l10n_ar/models/res_partner.py:0 #, python-format @@ -857,6 +852,11 @@ msgstr "Otros Documentos de Compra" msgid "Other VAT" msgstr "CUIT Otros" +#. module: l10n_ar +#: model:ir.model.fields,field_description:l10n_ar.field_account_journal__company_partner +msgid "Partner" +msgstr "Empresa" + #. module: l10n_ar #: code:addons/l10n_ar/models/account_move.py:0 #, python-format @@ -867,8 +867,14 @@ msgstr "" #. module: l10n_ar #: code:addons/l10n_ar/models/account_journal.py:0 #, python-format -msgid "Please define a valid AFIP POS number" -msgstr "Por favor defina un número de PdV AFIP válido" +msgid "Please define a valid AFIP POS number (5 digits max)" +msgstr "Por favor defina un número de PdV AFIP válido (5 números máximo)" + +#. module: l10n_ar +#: code:addons/l10n_ar/models/account_journal.py:0 +#, python-format +msgid "Please define an AFIP POS number" +msgstr "Por favor defina un número de PdV AFIP" #. module: l10n_ar #: code:addons/l10n_ar/models/account_journal.py:0 @@ -915,17 +921,10 @@ msgid "Responsibility Types" msgstr "Tipos de Responsabilidad" #. module: l10n_ar -#: model:ir.model,name:l10n_ar.model_ir_sequence #: model:ir.model.fields,field_description:l10n_ar.field_l10n_ar_afip_responsibility_type__sequence -#: model_terms:ir.ui.view,arch_db:l10n_ar.view_account_journal_form msgid "Sequence" msgstr "Secuencia" -#. module: l10n_ar -#: model:ir.model.fields,field_description:l10n_ar.field_account_journal__l10n_ar_sequence_ids -msgid "Sequences" -msgstr "Secuencias" - #. module: l10n_ar #: model_terms:ir.ui.view,arch_db:l10n_ar.view_move_form msgid "Service Date" @@ -980,15 +979,6 @@ msgstr "Servicio Telefónico (IVA 27)" msgid "Template for Fiscal Position" msgstr "Plantilla de posición fiscal" -#. module: l10n_ar -#: model:ir.model.fields,help:l10n_ar.field_res_company__l10n_ar_country_code -msgid "" -"The ISO country code in two chars. \n" -"You can use this field for quick search." -msgstr "" -"EL código ISO del país en dos caracteres.\n" -"Puede utilizar este campo para la búsqueda rápida." - #. module: l10n_ar #: code:addons/l10n_ar/models/l10n_latam_document_type.py:0 #, python-format @@ -1020,7 +1010,7 @@ msgstr "El dígito de validación no es válido para \"%s\"" #, python-format msgid "There must be one and only one VAT tax per line. Check line \"%s\"" msgstr "" -"Debe haver un único y solo un impuestp de IVA por línea. Revise la línea " +"Debe haber un único y solo un impuestp de IVA por línea. Revise la línea " "\"%s\"" #. module: l10n_ar diff --git a/addons/l10n_ar/i18n/l10n_ar.pot b/addons/l10n_ar/i18n/l10n_ar.pot index ecfdf56395e..b6a9c8d507f 100644 --- a/addons/l10n_ar/i18n/l10n_ar.pot +++ b/addons/l10n_ar/i18n/l10n_ar.pot @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 13.0+e\n" +"Project-Id-Version: Odoo Server 13.3alpha1+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-15 13:31+0000\n" -"PO-Revision-Date: 2020-01-15 13:31+0000\n" +"POT-Creation-Date: 2020-03-30 18:36+0000\n" +"PO-Revision-Date: 2020-03-30 18:36+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -363,6 +363,14 @@ msgstr "" msgid "CUIT" msgstr "" +#. module: l10n_ar +#: code:addons/l10n_ar/models/account_move.py:0 +#, python-format +msgid "" +"Can not change the POS number, you can only change the first number for " +"document type that you are creating in odoo" +msgstr "" + #. module: l10n_ar #: code:addons/l10n_ar/models/account_journal.py:0 #, python-format @@ -430,11 +438,6 @@ msgstr "" msgid "Country" msgstr "" -#. module: l10n_ar -#: model:ir.model.fields,field_description:l10n_ar.field_res_company__l10n_ar_country_code -msgid "Country Code" -msgstr "" - #. module: l10n_ar #: model:ir.model.fields,field_description:l10n_ar.field_l10n_ar_afip_responsibility_type__create_uid msgid "Created by" @@ -693,11 +696,6 @@ msgstr "" msgid "Legal Entity VAT" msgstr "" -#. module: l10n_ar -#: model:ir.model.fields,field_description:l10n_ar.field_ir_sequence__l10n_ar_letter -msgid "Letter" -msgstr "" - #. module: l10n_ar #: model:ir.model.fields,field_description:l10n_ar.field_l10n_latam_document_type__l10n_ar_letter msgid "Letters" @@ -754,11 +752,6 @@ msgstr "" msgid "Natural Person VAT" msgstr "" -#. module: l10n_ar -#: model_terms:ir.ui.view,arch_db:l10n_ar.view_account_journal_form -msgid "Next Number" -msgstr "" - #. module: l10n_ar #: code:addons/l10n_ar/models/res_partner.py:0 #, python-format @@ -829,6 +822,11 @@ msgstr "" msgid "Other VAT" msgstr "" +#. module: l10n_ar +#: model:ir.model.fields,field_description:l10n_ar.field_account_journal__company_partner +msgid "Partner" +msgstr "" + #. module: l10n_ar #: code:addons/l10n_ar/models/account_move.py:0 #, python-format @@ -838,7 +836,13 @@ msgstr "" #. module: l10n_ar #: code:addons/l10n_ar/models/account_journal.py:0 #, python-format -msgid "Please define a valid AFIP POS number" +msgid "Please define a valid AFIP POS number (5 digits max)" +msgstr "" + +#. module: l10n_ar +#: code:addons/l10n_ar/models/account_journal.py:0 +#, python-format +msgid "Please define an AFIP POS number" msgstr "" #. module: l10n_ar @@ -882,17 +886,10 @@ msgid "Responsibility Types" msgstr "" #. module: l10n_ar -#: model:ir.model,name:l10n_ar.model_ir_sequence #: model:ir.model.fields,field_description:l10n_ar.field_l10n_ar_afip_responsibility_type__sequence -#: model_terms:ir.ui.view,arch_db:l10n_ar.view_account_journal_form msgid "Sequence" msgstr "" -#. module: l10n_ar -#: model:ir.model.fields,field_description:l10n_ar.field_account_journal__l10n_ar_sequence_ids -msgid "Sequences" -msgstr "" - #. module: l10n_ar #: model_terms:ir.ui.view,arch_db:l10n_ar.view_move_form msgid "Service Date" @@ -945,13 +942,6 @@ msgstr "" msgid "Template for Fiscal Position" msgstr "" -#. module: l10n_ar -#: model:ir.model.fields,help:l10n_ar.field_res_company__l10n_ar_country_code -msgid "" -"The ISO country code in two chars. \n" -"You can use this field for quick search." -msgstr "" - #. module: l10n_ar #: code:addons/l10n_ar/models/l10n_latam_document_type.py:0 #, python-format diff --git a/addons/l10n_ar/models/__init__.py b/addons/l10n_ar/models/__init__.py index 63afb0d60ea..4f7205335f3 100644 --- a/addons/l10n_ar/models/__init__.py +++ b/addons/l10n_ar/models/__init__.py @@ -15,4 +15,3 @@ from . import res_partner_bank from . import uom_uom from . import account_chart_template from . import account_move -from . import ir_sequence diff --git a/addons/l10n_ar/models/account_journal.py b/addons/l10n_ar/models/account_journal.py index 25ffcae5c45..ba901e591fc 100644 --- a/addons/l10n_ar/models/account_journal.py +++ b/addons/l10n_ar/models/account_journal.py @@ -17,7 +17,6 @@ class AccountJournal(models.Model): 'res.partner', 'AFIP POS Address', help='This is the address used for invoice reports of this POS', domain="['|', ('id', '=', company_partner), '&', ('id', 'child_of', company_partner), ('type', '!=', 'contact')]" ) - l10n_ar_sequence_ids = fields.One2many('ir.sequence', 'l10n_latam_journal_id', string="Sequences") l10n_ar_share_sequences = fields.Boolean( 'Unified Book', help='Use same sequence for documents with the same letter') @@ -104,23 +103,6 @@ class AccountJournal(models.Model): elif self.l10n_ar_afip_pos_system in ['FEERCEL', 'FEEWS', 'FEERCELP']: return expo_codes - @api.model - def create(self, values): - """ Create Document sequences after create the journal """ - res = super().create(values) - res._l10n_ar_create_document_sequences() - return res - - def write(self, values): - """ Update Document sequences after update journal """ - to_check = set(['type', 'l10n_ar_afip_pos_system', 'l10n_ar_afip_pos_number', 'l10n_ar_share_sequences', - 'l10n_latam_use_documents']) - res = super().write(values) - if to_check.intersection(set(values.keys())): - for rec in self: - rec._l10n_ar_create_document_sequences() - return res - @api.constrains('type', 'l10n_ar_afip_pos_system', 'l10n_ar_afip_pos_number', 'l10n_ar_share_sequences', 'l10n_latam_use_documents') def _check_afip_configurations(self): @@ -136,35 +118,6 @@ class AccountJournal(models.Model): 'You can not change the journal configuration for a journal that already have validate invoices') + ':

- %s' % ('
- '.join(invoices.mapped('display_name')))) - def _l10n_ar_create_document_sequences(self): - """ IF AFIP Configuration change try to review if this can be done and then create / update the document - sequences """ - self.ensure_one() - if self.company_id.country_id != self.env.ref('base.ar'): - return True - if not self.type == 'sale' or not self.l10n_latam_use_documents: - return False - - sequences = self.l10n_ar_sequence_ids - sequences.unlink() - - # Create Sequences - letters = self._get_journal_letter() - internal_types = ['invoice', 'debit_note', 'credit_note'] - domain = [('country_id.code', '=', 'AR'), ('internal_type', 'in', internal_types), - '|', ('l10n_ar_letter', '=', False), ('l10n_ar_letter', 'in', letters)] - codes = self._get_journal_codes() - if codes: - domain.append(('code', 'in', codes)) - documents = self.env['l10n_latam.document.type'].search(domain) - for document in documents: - if self.l10n_ar_share_sequences and self.l10n_ar_sequence_ids.filtered( - lambda x: x.l10n_ar_letter == document.l10n_ar_letter): - continue - - sequences |= self.env['ir.sequence'].create(document._get_document_sequence_vals(self)) - return sequences - @api.constrains('l10n_ar_afip_pos_number') def _check_afip_pos_number(self): to_review = self.filtered( diff --git a/addons/l10n_ar/models/account_move.py b/addons/l10n_ar/models/account_move.py index 286805a5bed..97bf2a45520 100644 --- a/addons/l10n_ar/models/account_move.py +++ b/addons/l10n_ar/models/account_move.py @@ -167,3 +167,43 @@ class AccountMove(models.Model): 'l10n_ar_afip_service_end': move.l10n_ar_afip_service_end, }) return super()._reverse_moves(default_values_list=default_values_list, cancel=cancel) + + @api.onchange('l10n_latam_document_type_id', 'l10n_latam_document_number') + def _inverse_l10n_latam_document_number(self): + super()._inverse_l10n_latam_document_number() + + # Avoid that user change the POS number (x.l10n_latam_document_number), Rhe POS number configure in journal it + # will always be used + to_review = self.filtered( + lambda x: x.journal_id.type == 'sale' and x.l10n_latam_document_type_id and x.l10n_latam_document_number and + (x.l10n_latam_manual_document_number or not x.highest_name)) + for rec in to_review: + number = rec.l10n_latam_document_type_id._format_document_number(rec.l10n_latam_document_number) + current_pos = int(number.split("-")[0]) + if current_pos != rec.journal_id.l10n_ar_afip_pos_number: + raise UserError(_('Can not change the POS number, you can only change the first number for document' + ' type that you are creating in odoo')) + + def _get_formatted_sequence(self, number=0): + return "%s %05d-%08d" % (self.l10n_latam_document_type_id.doc_code_prefix, + self.journal_id.l10n_ar_afip_pos_number, number) + + def _get_starting_sequence(self): + """ If use documents then will create a new starting sequence using the document type code prefix and the + journal document number with a 8 padding number """ + if self.journal_id.l10n_latam_use_documents and self.env.company.country_id == self.env.ref('base.ar'): + if self.l10n_latam_document_type_id: + return self._get_formatted_sequence() + return super()._get_starting_sequence() + + def _get_last_sequence_domain(self, relaxed=False): + where_string, param = super(AccountMove, self)._get_last_sequence_domain(relaxed) + if self.company_id.country_id == self.env.ref('base.ar') and self.l10n_latam_use_documents: + if not self.journal_id.l10n_ar_share_sequences: + where_string += " AND l10n_latam_document_type_id = %(l10n_latam_document_type_id)s" + param['l10n_latam_document_type_id'] = self.l10n_latam_document_type_id.id or 0 + elif self.journal_id.l10n_ar_share_sequences: + where_string += " AND l10n_latam_document_type_id in %(l10n_latam_document_type_ids)s" + param['l10n_latam_document_type_ids'] = tuple(self.l10n_latam_document_type_id.search( + [('l10n_ar_letter', '=', self.l10n_latam_document_type_id.l10n_ar_letter)]).ids) + return where_string, param diff --git a/addons/l10n_ar/models/ir_sequence.py b/addons/l10n_ar/models/ir_sequence.py deleted file mode 100644 index af0d34c4809..00000000000 --- a/addons/l10n_ar/models/ir_sequence.py +++ /dev/null @@ -1,13 +0,0 @@ -# Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models - - -class IrSequence(models.Model): - - _inherit = 'ir.sequence' - - l10n_ar_letter = fields.Selection(selection='_get_l10n_ar_letters', string='Letter') - - def _get_l10n_ar_letters(self): - """ Return the list of values of the selection field. """ - return self.env['l10n_latam.document.type']._get_l10n_ar_letters() diff --git a/addons/l10n_ar/models/l10n_latam_document_type.py b/addons/l10n_ar/models/l10n_latam_document_type.py index 37f695f3de8..581f56d15d5 100644 --- a/addons/l10n_ar/models/l10n_latam_document_type.py +++ b/addons/l10n_ar/models/l10n_latam_document_type.py @@ -31,22 +31,6 @@ class L10nLatamDocumentType(models.Model): ('X', 'X'), ('I', 'I'), # used for mapping of imports ] - - def _get_document_sequence_vals(self, journal): - """ Values to create the sequences """ - values = super()._get_document_sequence_vals(journal) - if self.country_id != self.env.ref('base.ar'): - return values - - values.update({'padding': 8, 'implementation': 'no_gap', 'prefix': "%05i-" % (journal.l10n_ar_afip_pos_number), - 'l10n_latam_journal_id': journal.id}) - if journal.l10n_ar_share_sequences: - values.update({'name': '%s - Letter %s Documents' % (journal.name, self.l10n_ar_letter), - 'l10n_ar_letter': self.l10n_ar_letter}) - else: - values.update({'name': '%s - %s' % (journal.name, self.name), 'l10n_latam_document_type_id': self.id}) - return values - def _filter_taxes_included(self, taxes): """ In argentina we include taxes depending on document letter """ self.ensure_one() diff --git a/addons/l10n_ar/views/account_journal_view.xml b/addons/l10n_ar/views/account_journal_view.xml index d40b674bd0f..af6a4fdfbba 100644 --- a/addons/l10n_ar/views/account_journal_view.xml +++ b/addons/l10n_ar/views/account_journal_view.xml @@ -6,18 +6,6 @@ account.journal.form - - - - - - - - - - - {'invisible': ['|', ('type', 'not in', ['sale', 'purchase']), ('l10n_latam_use_documents', '=', True), ('l10n_latam_country_code', '=', 'AR')]} - diff --git a/addons/l10n_ar/views/ir_sequence_view.xml b/addons/l10n_ar/views/ir_sequence_view.xml deleted file mode 100644 index ad2e080bb11..00000000000 --- a/addons/l10n_ar/views/ir_sequence_view.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - ir.sequence.form - ir.sequence - - - - - - - - - - ir.sequence.tree - ir.sequence - - - - - - - - - - ir.sequence.search - ir.sequence - - - - - - - - -