-
Notifications
You must be signed in to change notification settings - Fork 132
[IMP] account_ux: Add branch_order to re order journal given more priority to branch journals if you are setting from a branch #853
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: 19.0
Are you sure you want to change the base?
Conversation
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.
Pull request overview
Este PR implementa una restricción para evitar que los diarios de compra que utilizan documentos de Latinoamérica (l10n_latam_use_documents) sean compartidos con sucursales (branches), manteniendo la política actual para diarios de tipo general y de venta.
Cambios principales:
- Se agrega una advertencia en el método
_onchange_shared_to_branchescuando se intenta compartir un diario de compra con documentos latinoamericanos - Se actualiza la lógica del método compute
_compute_shared_to_branchespara excluir automáticamente estos diarios de compra del compartido predeterminado
account_ux/models/account_journal.py
Outdated
| @api.depends("type", "l10n_latam_use_documents") | ||
| def _compute_shared_to_branches(self): | ||
| shared = self.filtered(lambda j: j.type in ["general", "purchase"]) | ||
| # Journals of type general are shared, and purchase journals that do not use l10n_latam documents | ||
| has_latam_documents = "l10n_latam_use_documents" in self._fields | ||
| shared = self.filtered( | ||
| lambda j: j.type == "general" | ||
| or (j.type == "purchase" and (not has_latam_documents or not j.l10n_latam_use_documents)) | ||
| ) | ||
| shared.shared_to_branches = True | ||
| (self - shared).shared_to_branches = False |
Copilot
AI
Dec 22, 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.
Este cambio modifica el comportamiento de un campo compute almacenado (shared_to_branches tiene store=True), por lo que se debe incrementar la versión del módulo en el __manifest__.py (de 19.0.1.3.0 a 19.0.1.4.0).
account_ux/models/account_journal.py
Outdated
| @api.depends("type", "l10n_latam_use_documents") | ||
| def _compute_shared_to_branches(self): | ||
| shared = self.filtered(lambda j: j.type in ["general", "purchase"]) | ||
| # Journals of type general are shared, and purchase journals that do not use l10n_latam documents | ||
| has_latam_documents = "l10n_latam_use_documents" in self._fields | ||
| shared = self.filtered( | ||
| lambda j: j.type == "general" | ||
| or (j.type == "purchase" and (not has_latam_documents or not j.l10n_latam_use_documents)) | ||
| ) | ||
| shared.shared_to_branches = True | ||
| (self - shared).shared_to_branches = False |
Copilot
AI
Dec 22, 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.
Al modificar la lógica del método _compute_shared_to_branches (campo compute almacenado), es necesario crear un script de migración post en migrations/19.0.1.4.0/post_recompute_shared_to_branches.py que recalcule el campo shared_to_branches para todos los diarios de tipo "purchase" existentes, especialmente aquellos que tienen l10n_latam_use_documents=True, ya que ahora deberían tener shared_to_branches=False. El script debe procesar los registros en lotes para evitar problemas de rendimiento.
account_ux/models/account_journal.py
Outdated
| } | ||
|
|
||
| @api.depends("type") | ||
| @api.depends("type", "l10n_latam_use_documents") |
Copilot
AI
Dec 22, 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 decorador @api.depends incluye l10n_latam_use_documents, pero este campo puede no existir si el módulo de localización latinoamericana no está instalado. En Odoo, los decoradores @api.depends con campos inexistentes pueden causar warnings o errores. Considera usar una verificación condicional para agregar esta dependencia solo si el campo existe, o documentar que este módulo requiere que el campo esté siempre presente cuando se usa la funcionalidad de sucursales.
| @api.depends("type", "l10n_latam_use_documents") | |
| @api.depends("type") |
8251691 to
074b718
Compare
074b718 to
709bc4c
Compare
…ority to branch journals if you are setting from a branch
709bc4c to
312ab75
Compare

No description provided.