-
Notifications
You must be signed in to change notification settings - Fork 69
[Fix] account_move: ensure company id is set when using invoice automatation #1525
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
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 corrige un problema donde company_id podía quedar vacío al usar automatización de facturas en modo sudo, cuando el usuario no tiene acceso a ninguna compañía. La solución sobrescribe _compute_company_id para asignar la compañía del journal del tipo de venta cuando el método padre no pueda determinarla.
- Agrega método
_compute_company_idque maneja el caso edge de sudo sin acceso a compañías - Asigna
company_iddesdesale_type_id.journal_id.company_idcuando sea necesario - Incluye comentario explicativo sobre cuándo se activa esta lógica
| # If company_id is empty after super (because _accessible_branches returned empty), | ||
| # assign the journal's company directly. This happens when in sudo mode and the user | ||
| # has no access to any company | ||
| for move in self.filtered(lambda m: not m.company_id and m.sale_type_id.journal_id and m.sale_type_id.invoicing_atomation != "none"): |
Copilot
AI
Jan 5, 2026
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 campo debería ser "invoicing_automation" en lugar de "invoicing_atomation" (falta la 'u'). Aunque este error de tipeo es consistente en todo el módulo (payment_atomation, picking_atomation, invoicing_atomation), debería corregirse en el modelo sale_order_type y luego actualizar todas las referencias, incluyendo esta.
| for move in self.filtered(lambda m: not m.company_id and m.sale_type_id.journal_id and m.sale_type_id.invoicing_atomation != "none"): | |
| for move in self.filtered(lambda m: not m.company_id and m.sale_type_id.journal_id and m.sale_type_id.invoicing_automation != "none"): |
| def _compute_company_id(self): | ||
| super()._compute_company_id() | ||
| # If company_id is empty after super (because _accessible_branches returned empty), | ||
| # assign the journal's company directly. This happens when in sudo mode and the user | ||
| # has no access to any company | ||
| for move in self.filtered(lambda m: not m.company_id and m.sale_type_id.journal_id and m.sale_type_id.invoicing_atomation != "none"): | ||
| move.company_id = move.sale_type_id.journal_id.company_id |
Copilot
AI
Jan 5, 2026
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.
Falta incrementar la versión en manifest.py. Este cambio agrega un nuevo método _compute_company_id que modifica el comportamiento del modelo account.move. Según las reglas del proyecto, cuando se modifican modelos (models/*.py), la versión debe incrementarse (por ejemplo, de 18.0.1.2.0 a 18.0.1.2.1).
| def _compute_company_id(self): | ||
| super()._compute_company_id() | ||
| # If company_id is empty after super (because _accessible_branches returned empty), | ||
| # assign the journal's company directly. This happens when in sudo mode and the user | ||
| # has no access to any company | ||
| for move in self.filtered(lambda m: not m.company_id and m.sale_type_id.journal_id and m.sale_type_id.invoicing_atomation != "none"): | ||
| move.company_id = move.sale_type_id.journal_id.company_id |
Copilot
AI
Jan 5, 2026
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 nuevo método _compute_company_id maneja un caso específico (modo sudo sin acceso a ninguna compañía) que no tiene cobertura de tests. Dado que el módulo ya cuenta con tests automatizados en tests/test_sale_order_type_automation.py, sería recomendable agregar un test que verifique este comportamiento edge case: cuando _accessible_branches retorna vacío y se debe asignar la compañía desde sale_type_id.journal_id.company_id.
211c730 to
0cda6ca
Compare
|
@roboadhoc r+ |
…atation closes #1525 Signed-off-by: Filoquin adhoc <maq@adhoc.com.ar>

No description provided.