[IMP] l10n_ar: adapt code to remove sequences
* remove logic of sequences in invoices and use new logic to make it work * add logic do to not let the user to change the pos number in the document number * update translations
This commit is contained in:
@@ -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',
|
||||
],
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="True">
|
||||
|
||||
<!-- we add l10n_latam_document_number on on a separete line because we need l10n_latam_document_type_id to be auto assigned so that account.move.name can be computed with the _inverse_l10n_latam_document_number -->
|
||||
|
||||
<!-- Invoice from gritti support service, auto fiscal position set VAT Not Applicable -->
|
||||
<record id="demo_sup_invoice_1" model="account.move">
|
||||
<field name="name">FA-C 0001-00000008</field>
|
||||
<field name="partner_id" ref="res_partner_gritti_agrimensura"/>
|
||||
<field name="invoice_user_id" ref="base.user_demo"/>
|
||||
<field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/>
|
||||
@@ -22,7 +23,6 @@
|
||||
|
||||
<!-- Invoice from Foreign with vat 21, 27 and 10,5 -->
|
||||
<record id="demo_sup_invoice_2" model="account.move">
|
||||
<field name="name">FA-A 0002-00000123</field>
|
||||
<field name="partner_id" ref="res_partner_foreign"/>
|
||||
<field name="invoice_user_id" ref="base.user_demo"/>
|
||||
<field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/>
|
||||
@@ -38,7 +38,6 @@
|
||||
|
||||
<!-- Invoice from Foreign with vat zero and 21 -->
|
||||
<record id="demo_sup_invoice_3" model="account.move">
|
||||
<field name="name">FA-A 0003-00000312</field>
|
||||
<field name="partner_id" ref="res_partner_foreign"/>
|
||||
<field name="invoice_user_id" ref="base.user_demo"/>
|
||||
<field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/>
|
||||
@@ -53,7 +52,6 @@
|
||||
|
||||
<!-- Invoice to Foreign with vat exempt and 21 -->
|
||||
<record id="demo_sup_invoice_4" model="account.move">
|
||||
<field name="name">FA-A 0001-00000200</field>
|
||||
<field name="partner_id" ref="res_partner_foreign"/>
|
||||
<field name="invoice_user_id" ref="base.user_demo"/>
|
||||
<field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/>
|
||||
@@ -68,7 +66,6 @@
|
||||
|
||||
<!-- Invoice to Foreign with all type of taxes -->
|
||||
<record id="demo_sup_invoice_5" model="account.move">
|
||||
<field name="name">FA-A 0001-00000222</field>
|
||||
<field name="partner_id" ref="res_partner_foreign"/>
|
||||
<field name="invoice_user_id" ref="base.user_demo"/>
|
||||
<field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/>
|
||||
@@ -87,7 +84,6 @@
|
||||
|
||||
<!-- Service Import to Odoo, fiscal position changes tax not correspond -->
|
||||
<record id="demo_sup_invoice_6" model="account.move">
|
||||
<field name="name">FA-I 0001-00000333</field>
|
||||
<field name="partner_id" ref="res_partner_odoo"/>
|
||||
<field name="invoice_user_id" ref="base.user_demo"/>
|
||||
<field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/>
|
||||
@@ -101,7 +97,6 @@
|
||||
|
||||
<!-- Similar to last one but with line that have tax not correspond with negative amount -->
|
||||
<record id="demo_sup_invoice_7" model="account.move">
|
||||
<field name="name">FA-I 0001-00000334</field>
|
||||
<field name="partner_id" ref="res_partner_odoo"/>
|
||||
<field name="invoice_user_id" ref="base.user_demo"/>
|
||||
<field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/>
|
||||
@@ -116,7 +111,6 @@
|
||||
|
||||
<!-- Import Cleareance -->
|
||||
<record id="demo_despacho_1" model="account.move">
|
||||
<field name="name">GA-I 0001-00000605</field>
|
||||
<field name="partner_id" ref="l10n_ar.partner_afip"/>
|
||||
<field name="invoice_user_id" ref="base.user_demo"/>
|
||||
<field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/>
|
||||
@@ -222,6 +216,31 @@
|
||||
<field name="account_id" model="account.move.line" eval="obj().env.ref('product.product_category_all').property_account_income_categ_id.id"/>
|
||||
</record>
|
||||
|
||||
<record id="demo_sup_invoice_1" model="account.move">
|
||||
<field name="l10n_latam_document_number">0001-00000008</field>
|
||||
</record>
|
||||
<record id="demo_sup_invoice_2" model="account.move">
|
||||
<field name="l10n_latam_document_number">0002-00000123</field>
|
||||
</record>
|
||||
<record id="demo_sup_invoice_3" model="account.move">
|
||||
<field name="l10n_latam_document_number">0003-00000312</field>
|
||||
</record>
|
||||
<record id="demo_sup_invoice_4" model="account.move">
|
||||
<field name="l10n_latam_document_number">0001-00000200</field>
|
||||
</record>
|
||||
<record id="demo_sup_invoice_5" model="account.move">
|
||||
<field name="l10n_latam_document_number">0001-00000222</field>
|
||||
</record>
|
||||
<record id="demo_sup_invoice_6" model="account.move">
|
||||
<field name="l10n_latam_document_number">0001-00000333</field>
|
||||
</record>
|
||||
<record id="demo_sup_invoice_7" model="account.move">
|
||||
<field name="l10n_latam_document_number">0001-00000334</field>
|
||||
</record>
|
||||
<record id="demo_despacho_1" model="account.move">
|
||||
<field name="l10n_latam_document_number">16052IC04000605L</field>
|
||||
</record>
|
||||
|
||||
<function model="account.move" name="_onchange_partner_id" context="{'check_move_validity': False}">
|
||||
<value eval="[ref('demo_sup_invoice_1')]"/>
|
||||
</function>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<record id="demo_sup_refund_invoice_3" model="account.move.reversal">
|
||||
<field name="reason">Mercadería defectuosa</field>
|
||||
<field name="refund_method">refund</field>
|
||||
<field name="l10n_latam_document_number">0001-01234567</field>
|
||||
<field name="move_ids" eval="[(4, ref('demo_sup_invoice_3'), 0)]"/>
|
||||
</record>
|
||||
|
||||
@@ -14,6 +15,7 @@
|
||||
<record id="demo_sup_refund_invoice_4" model="account.move.reversal">
|
||||
<field name="reason">Venta cancelada</field>
|
||||
<field name="refund_method">cancel</field>
|
||||
<field name="l10n_latam_document_number">0001-01234566</field>
|
||||
<field name="move_ids" eval="[(4, ref('demo_sup_invoice_4'), 0)]"/>
|
||||
</record>
|
||||
|
||||
|
||||
+28
-38
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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') +
|
||||
':<br/><br/> - %s' % ('<br/>- '.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(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
|
||||
@@ -6,18 +6,6 @@
|
||||
<field name="name">account.journal.form</field>
|
||||
<field name="inherit_id" ref="l10n_latam_invoice_document.view_account_journal_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='code']/.." position="inside">
|
||||
<field name="l10n_ar_sequence_ids" nolabel="1" colspan="2" attrs="{'invisible': ['|', ('l10n_latam_use_documents', '=', False), ('l10n_latam_country_code', '!=', 'AR')]}">
|
||||
<tree create="false" delete="false" editable="top" default_order="id">
|
||||
<field name="name" readonly="True" string="Sequence"/>
|
||||
<field name="number_next_actual" string="Next Number"/>
|
||||
<field name="id" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</xpath>
|
||||
<field name="refund_sequence" position="attributes">
|
||||
<attribute name="attrs">{'invisible': ['|', ('type', 'not in', ['sale', 'purchase']), ('l10n_latam_use_documents', '=', True), ('l10n_latam_country_code', '=', 'AR')]}</attribute>
|
||||
</field>
|
||||
<field name="l10n_latam_use_documents" position="after">
|
||||
<field name="company_partner" invisible="1"/>
|
||||
<field name="l10n_ar_afip_pos_system" attrs="{'invisible':['|', '|', ('l10n_latam_country_code', '!=', 'AR'), ('l10n_latam_use_documents', '=', False), ('type', '!=', 'sale')], 'required':[('l10n_latam_country_code', '=', 'AR'), ('l10n_latam_use_documents', '=', True), ('type', '=', 'sale')]}"/>
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="sequence_view" model="ir.ui.view">
|
||||
<field name="name">ir.sequence.form</field>
|
||||
<field name="model">ir.sequence</field>
|
||||
<field name="inherit_id" ref="l10n_latam_invoice_document.sequence_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="l10n_latam_document_type_id" position="after">
|
||||
<field name="l10n_ar_letter"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sequence_view_tree" model="ir.ui.view">
|
||||
<field name="name">ir.sequence.tree</field>
|
||||
<field name="model">ir.sequence</field>
|
||||
<field name="inherit_id" ref="l10n_latam_invoice_document.sequence_view_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="l10n_latam_document_type_id" position="after">
|
||||
<field name="l10n_ar_letter"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_sequence_search" model="ir.ui.view">
|
||||
<field name="name">ir.sequence.search</field>
|
||||
<field name="model">ir.sequence</field>
|
||||
<field name="inherit_id" ref="l10n_latam_invoice_document.view_sequence_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="l10n_latam_document_type_id" position="after">
|
||||
<field name="l10n_ar_letter"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user