Here is the solution for your issue:
Create and Action Refresh Stock - Compras for DETALLE_COMPRAS
Type: execute an Action on set of rows
for record of this table DETALLE_COMPRAS
reference table: Inventario
referenced rows : FILTER(INVENTARIO, ISNOTBLANK(CANTIDAD]))
Appearance / Prominence Don’t display
Creae the same for DETALLE_Ventas
Create third Action Refresh Stock for the table Inventario
Type set the values of some columns in this row
STOCK = [cantidad]
Appearance / Prominence Don’t display
from UX
DETALLE_COMPRAS_Form
go to behavior :
event action: choose Refresh Stock - Compras
DETALLE_VENTAS_Form
go to behavior :
event action: choose Refresh Stock - VENTAS