Skip to content

Conversation

@rov-adhoc
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings January 5, 2026 17:51
@roboadhoc
Copy link

Pull request status dashboard

Copy link

Copilot AI left a 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_id que maneja el caso edge de sudo sin acceso a compañías
  • Asigna company_id desde sale_type_id.journal_id.company_id cuando 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"):
Copy link

Copilot AI Jan 5, 2026

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.

Suggested change
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"):

Copilot uses AI. Check for mistakes.
Comment on lines 18 to 26
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
Copy link

Copilot AI Jan 5, 2026

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).

Copilot generated this review using guidance from repository custom instructions.
Comment on lines 18 to 26
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
Copy link

Copilot AI Jan 5, 2026

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.

Copilot uses AI. Check for mistakes.
@maq-adhoc
Copy link
Contributor

@roboadhoc r+

roboadhoc pushed a commit that referenced this pull request Jan 6, 2026
…atation

closes #1525

Signed-off-by: Filoquin adhoc <maq@adhoc.com.ar>
@roboadhoc roboadhoc closed this Jan 6, 2026
@roboadhoc roboadhoc deleted the 18.0-h-107464-rov branch January 6, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants