-
Notifications
You must be signed in to change notification settings - Fork 72
[FIX] l10n_ar_demo: Fix use documents issue in demo data #810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 16.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,9 +15,9 @@ | |||||||||||||||
| old_load_manifest = module.load_manifest | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def load_manifest(module, mod_path=None): | ||||||||||||||||
| info = old_load_manifest(module, mod_path=mod_path) | ||||||||||||||||
| if module in ['l10n_ar', 'l10n_ar_edi', 'l10n_ar_website_sale']: | ||||||||||||||||
| def load_manifest(module_name, mod_path=None): | ||||||||||||||||
| info = old_load_manifest(module_name, mod_path=mod_path) | ||||||||||||||||
| if module_name in ['l10n_ar', 'l10n_ar_edi', 'l10n_ar_website_sale']: | ||||||||||||||||
| info['demo'] = [] | ||||||||||||||||
| return info | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -26,16 +26,41 @@ def load_manifest(module, mod_path=None): | |||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def _load_l10n_ar_demo_data(cr): | ||||||||||||||||
| """ | ||||||||||||||||
| Carga los datos demo de l10n_ar que fueron ocultados por load_manifest. | ||||||||||||||||
| Este hook se ejecuta antes de cargar los demos de l10n_ar_demo para asegurar | ||||||||||||||||
| que las dependencias (journals, productos, partners, etc) existan. | ||||||||||||||||
| """ | ||||||||||||||||
| env = api.Environment(cr, SUPERUSER_ID, {}) | ||||||||||||||||
| for module_name in ['l10n_ar', 'l10n_ar_edi', 'l10n_ar_website_sale']: | ||||||||||||||||
| _logger.info('Loading demo data from %s' % module_name) | ||||||||||||||||
| manifest_file = module.module_manifest(module.get_module_path(module_name)) | ||||||||||||||||
| f = tools.file_open(manifest_file, mode='rb') | ||||||||||||||||
| try: | ||||||||||||||||
| info = ast.literal_eval(tools.pycompat.to_text(f.read())) | ||||||||||||||||
| finally: | ||||||||||||||||
| f.close() | ||||||||||||||||
| for demo_data in info.get('demo'): | ||||||||||||||||
| _logger.info('Loading %s', (demo_data)) | ||||||||||||||||
| tools.convert_file(cr, module_name, demo_data, {}, 'init', True, 'demo', None) | ||||||||||||||||
| env.cr.commit() | ||||||||||||||||
|
|
||||||||||||||||
| # Verificar si los datos demo ya fueron cargados (para evitar recargas en upgrades) | ||||||||||||||||
| # Verificamos con company_exento que se crea en el primer archivo demo (exento_demo.xml) | ||||||||||||||||
| if env['ir.model.data'].search([('module', '=', 'l10n_ar'), ('name', '=', 'company_exento')], limit=1): | ||||||||||||||||
| _logger.info('Demo data from l10n_ar already loaded, skipping manual load') | ||||||||||||||||
| return | ||||||||||||||||
|
|
||||||||||||||||
| # Desactivar constraints problemáticas temporalmente durante la carga inicial | ||||||||||||||||
| # Esto es necesario porque los archivos demo de l10n_ar tienen problemas de orden | ||||||||||||||||
| AccountJournal = env.registry['account.journal'] | ||||||||||||||||
| orig_check1 = AccountJournal.check_use_document | ||||||||||||||||
| orig_check2 = AccountJournal._check_afip_configurations | ||||||||||||||||
|
Comment on lines
+45
to
+46
|
||||||||||||||||
| AccountJournal.check_use_document = lambda self: None | ||||||||||||||||
| AccountJournal._check_afip_configurations = lambda self: None | ||||||||||||||||
|
|
||||||||||||||||
| try: | ||||||||||||||||
| for module_name in ['l10n_ar', 'l10n_ar_edi', 'l10n_ar_website_sale']: | ||||||||||||||||
| _logger.info('Loading demo data from %s' % module_name) | ||||||||||||||||
| manifest_file = module.module_manifest(module.get_module_path(module_name)) | ||||||||||||||||
| f = tools.file_open(manifest_file, mode='rb') | ||||||||||||||||
| try: | ||||||||||||||||
| info = ast.literal_eval(tools.pycompat.to_text(f.read())) | ||||||||||||||||
| finally: | ||||||||||||||||
| f.close() | ||||||||||||||||
|
Comment on lines
+54
to
+58
|
||||||||||||||||
| f = tools.file_open(manifest_file, mode='rb') | |
| try: | |
| info = ast.literal_eval(tools.pycompat.to_text(f.read())) | |
| finally: | |
| f.close() | |
| with tools.file_open(manifest_file, mode='rb') as f: | |
| info = ast.literal_eval(tools.pycompat.to_text(f.read())) |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
El parámetro demo_data está envuelto en una tupla innecesaria (demo_data). Debería ser simplemente demo_data o demo_data, si se pretende una tupla. La sintaxis actual funciona porque los paréntesis no crean tuplas por sí solos.
| _logger.info('Loading %s', (demo_data)) | |
| _logger.info('Loading %s', demo_data) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
| <data> | ||
| <!-- Crear diarios de retenciones para las empresas demo --> | ||
| <!-- Estos normalmente se crean por account_chart_template._create_bank_journals --> | ||
| <!-- pero solo si l10n_ar_account_withholding está instalado cuando se aplica el chart template --> | ||
|
|
||
| <record id="withholding_journal_ri" model="account.journal"> | ||
| <field name="name">Retenciones</field> | ||
| <field name="type">cash</field> | ||
| <field name="company_id" ref="l10n_ar.company_ri"/> | ||
| <field name="code">RET</field> | ||
| </record> | ||
|
|
||
| <record id="withholding_journal_exento" model="account.journal"> | ||
| <field name="name">Retenciones</field> | ||
| <field name="type">cash</field> | ||
| <field name="company_id" ref="l10n_ar.company_exento"/> | ||
| <field name="code">RET</field> | ||
| </record> | ||
|
|
||
| <record id="withholding_journal_mono" model="account.journal"> | ||
| <field name="name">Retenciones</field> | ||
| <field name="type">cash</field> | ||
| <field name="company_id" ref="l10n_ar.company_mono"/> | ||
| <field name="code">RET</field> | ||
| </record> | ||
| </data> | ||
| </odoo> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acceder directamente al registro (
env.registry['account.journal']) para modificar métodos de clase es un patrón frágil. Si el modelo no existe o hay un error tipográfico en el nombre, fallará silenciosamente. Considera agregar validación:if 'account.journal' not in env.registry: _logger.warning('account.journal not found'); return.