Skip to content

[FIX]product_replenishment_cost: remove logic from standard price#892

Open
jcadhoc wants to merge 1 commit intoingadhoc:19.0from
adhoc-dev:19.0-h-114526-jc
Open

[FIX]product_replenishment_cost: remove logic from standard price#892
jcadhoc wants to merge 1 commit intoingadhoc:19.0from
adhoc-dev:19.0-h-114526-jc

Conversation

@jcadhoc
Copy link
Copy Markdown
Contributor

@jcadhoc jcadhoc commented Apr 24, 2026

No description provided.

@roboadhoc
Copy link
Copy Markdown
Contributor

Pull request status dashboard

Copy link
Copy Markdown

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 elimina el fallback a standard_price cuando el precio calculado queda en 0, y consolida el cálculo de price_unit para compras usando net_price (coste con reglas de replenishment) cubriendo también el flujo de procurement donde el “supplier” puede llegar como res.partner.

Changes:

  • Se elimina la lógica que reemplazaba price_unit=0 por product.standard_price en integraciones con purchase_stock.
  • Se elimina el override específico en product_replenishment_cost_stock para preparar líneas desde procurement.
  • Se ajusta _prepare_purchase_order_line en product_replenishment_cost para calcular el seller y el price_unit usando net_price tanto si supplier es product.supplierinfo como si es res.partner.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
product_replenishment_cost_stock/models/stock_rule.py Deja de forzar fallback a standard_price cuando el price_unit queda en 0.
product_replenishment_cost_stock/models/purchase_order_line.py Elimina el override de _prepare_purchase_order_line_from_procurement que aplicaba fallback a standard_price.
product_replenishment_cost_stock/models/init.py Deja de importar el modelo eliminado.
product_replenishment_cost/models/purchase_order_line.py Reestructura _prepare_purchase_order_line para usar net_price también en el flujo con supplier como partner.

Comment on lines +56 to +60
if supplier._name == "product.supplierinfo":
seller = supplier
else:
seller = product_id.with_company(company_id)._select_seller(
partner_id=supplier,
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En _prepare_purchase_order_line, se quitó el chequeo supplier and ... y ahora se accede a supplier._name directamente. Si supplier llega como False/None (caso que antes estaba contemplado), esto va a lanzar AttributeError. Recomendación: volver a proteger el acceso (p. ej. tratar supplier falsy como “sin seller” y hacer return res o resolver el seller con _select_seller solo cuando corresponda).

Copilot uses AI. Check for mistakes.
Comment on lines +54 to 64
today = fields.Date.today()
# supplier can be product.supplierinfo (direct call) or res.partner (from procurement via purchase_stock)
if supplier._name == "product.supplierinfo":
seller = supplier
else:
seller = product_id.with_company(company_id)._select_seller(
partner_id=supplier,
quantity=product_qty,
date=po.date_order and po.date_order.date() or today,
uom_id=product_uom,
)
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La lógica nueva cubre explícitamente el caso en que supplier es res.partner (flujo de procurement/purchase_stock) seleccionando el seller con _select_seller, pero los tests actuales solo cubren creación de líneas que terminan pasando product.supplierinfo. Sería bueno agregar un test que invoque _prepare_purchase_order_line (o el flujo equivalente) con supplier como partner y verifique que se usa seller.net_price y conversiones de moneda/UoM cuando aplique.

Copilot generated this review using guidance from repository custom instructions.
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